Migrate to JUnit5
This commit is contained in:
abstract-document
abstract-factory
adapter
aggregator-microservices
aggregator-service
information-microservice
inventory-microservice
api-gateway
api-gateway-service
image-microservice
price-microservice
async-method-invocation
balking
bridge
builder
business-delegate
caching
callback
chain
checkstyle.xmlcommand
composite
converter
cqrs
dao
data-bus
data-mapper
data-transfer-object
decorator
delegation
dependency-injection
double-checked-locking
double-dispatch
pom.xml
src
eip-aggregator
eip-splitter
eip-wire-tap
event-aggregator
event-asynchronous
event-driven-architecture
event-queue
event-sourcing
execute-around
extension-objects
pom.xml
src
facade
factory-kit
factory-method
feature-toggle
fluentinterface
flux
flyweight
front-controller
guarded-suspension
half-sync-half-async
hexagonal
pom.xml
src
test
java
com
iluwatar
hexagonal
intercepting-filter
interpreter
pom.xml
src
iterator
layers
pom.xml
src
lazy-loading
marker
mediator
memento
message-channel
model-view-controller
model-view-presenter
module
monad
monostate
multiton
mute-idiom
mutex
naked-objects
null-object
object-mother
object-pool
observer
pom.xml
src
page-object
partial-response
poison-pill
pom.xmlprivate-class-data
producer-consumer
promise
property
prototype
proxy
publish-subscribe
queue-load-leveling
reactor
reader-writer-lock
repository
resource-acquisition-is-initialization
retry
semaphore
servant
service-layer
service-locator
singleton
specification
state
step-builder
strategy
template-method
thread-pool
throttling
tls
pom.xml
src
tolerant-reader
twin
unit-of-work
value-object
visitor
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.iluwatar.front.controller;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@@ -22,9 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.front.controller;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
/**
|
||||
* Date: 12/13/15 - 1:35 PM
|
||||
|
@@ -23,40 +23,36 @@
|
||||
package com.iluwatar.front.controller;
|
||||
|
||||
import com.iluwatar.front.controller.utils.InMemoryAppender;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Date: 12/13/15 - 1:39 PM
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class CommandTest {
|
||||
|
||||
private InMemoryAppender appender;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
appender = new InMemoryAppender();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
appender.stop();
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static List<Object[]> data() {
|
||||
static List<Object[]> dataProvider() {
|
||||
final List<Object[]> parameters = new ArrayList<>();
|
||||
parameters.add(new Object[]{"Archer", "Displaying archers"});
|
||||
parameters.add(new Object[]{"Catapult", "Displaying catapults"});
|
||||
@@ -65,28 +61,12 @@ public class CommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* The view that's been tested
|
||||
*/
|
||||
private final String request;
|
||||
|
||||
/**
|
||||
* The expected display message
|
||||
*/
|
||||
private final String displayMessage;
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@link CommandTest} with the given view and expected message
|
||||
*
|
||||
* @param request The request that's been tested
|
||||
* @param displayMessage The expected display message
|
||||
*/
|
||||
public CommandTest(final String request, final String displayMessage) {
|
||||
this.displayMessage = displayMessage;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisplay() {
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testDisplay(String request, String displayMessage) {
|
||||
final FrontController frontController = new FrontController();
|
||||
assertEquals(0, appender.getLogSize());
|
||||
frontController.handleRequest(request);
|
||||
|
@@ -23,40 +23,36 @@
|
||||
package com.iluwatar.front.controller;
|
||||
|
||||
import com.iluwatar.front.controller.utils.InMemoryAppender;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Date: 12/13/15 - 1:39 PM
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class FrontControllerTest {
|
||||
|
||||
private InMemoryAppender appender;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
appender = new InMemoryAppender();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
appender.stop();
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static List<Object[]> data() {
|
||||
static List<Object[]> dataProvider() {
|
||||
final List<Object[]> parameters = new ArrayList<>();
|
||||
parameters.add(new Object[]{new ArcherCommand(), "Displaying archers"});
|
||||
parameters.add(new Object[]{new CatapultCommand(), "Displaying catapults"});
|
||||
@@ -65,30 +61,14 @@ public class FrontControllerTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* The view that's been tested
|
||||
*/
|
||||
private final Command command;
|
||||
|
||||
/**
|
||||
* The expected display message
|
||||
*/
|
||||
private final String displayMessage;
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@link FrontControllerTest} with the given view and expected message
|
||||
*
|
||||
* @param command The command that's been tested
|
||||
* @param displayMessage The expected display message
|
||||
*/
|
||||
public FrontControllerTest(final Command command, final String displayMessage) {
|
||||
this.displayMessage = displayMessage;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisplay() {
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testDisplay(Command command, String displayMessage) {
|
||||
assertEquals(0, appender.getLogSize());
|
||||
this.command.process();
|
||||
command.process();
|
||||
assertEquals(displayMessage, appender.getLastMessage());
|
||||
assertEquals(1, appender.getLogSize());
|
||||
}
|
||||
|
@@ -23,40 +23,36 @@
|
||||
package com.iluwatar.front.controller;
|
||||
|
||||
import com.iluwatar.front.controller.utils.InMemoryAppender;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Date: 12/13/15 - 1:39 PM
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class ViewTest {
|
||||
|
||||
private InMemoryAppender appender;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
appender = new InMemoryAppender();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
appender.stop();
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static List<Object[]> data() {
|
||||
static List<Object[]> dataProvider() {
|
||||
final List<Object[]> parameters = new ArrayList<>();
|
||||
parameters.add(new Object[]{new ArcherView(), "Displaying archers"});
|
||||
parameters.add(new Object[]{new CatapultView(), "Displaying catapults"});
|
||||
@@ -65,30 +61,14 @@ public class ViewTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* The view that's been tested
|
||||
*/
|
||||
private final View view;
|
||||
|
||||
/**
|
||||
* The expected display message
|
||||
*/
|
||||
private final String displayMessage;
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@link ViewTest} with the given view and expected message
|
||||
*
|
||||
* @param view The view that's been tested
|
||||
* @param displayMessage The expected display message
|
||||
*/
|
||||
public ViewTest(final View view, final String displayMessage) {
|
||||
this.displayMessage = displayMessage;
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisplay() {
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testDisplay(View view, String displayMessage) {
|
||||
assertEquals(0, appender.getLogSize());
|
||||
this.view.display();
|
||||
view.display();
|
||||
assertEquals(displayMessage, appender.getLastMessage());
|
||||
assertEquals(1, appender.getLogSize());
|
||||
}
|
||||
|
Reference in New Issue
Block a user