Migrate to JUnit5
This commit is contained in:
@ -34,8 +34,18 @@
|
||||
<artifactId>intercepting-filter</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.iluwatar.intercepting.filter;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -22,9 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.intercepting.filter;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
@ -22,25 +22,22 @@
|
||||
*/
|
||||
package com.iluwatar.intercepting.filter;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.TestCase.assertSame;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
/**
|
||||
* Date: 12/13/15 - 2:17 PM
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class FilterTest {
|
||||
|
||||
private static final Order PERFECT_ORDER = new Order("name", "12345678901", "addr", "dep", "order");
|
||||
@ -50,8 +47,7 @@ public class FilterTest {
|
||||
private static final Order WRONG_CONTACT = new Order("name", "", "addr", "dep", "order");
|
||||
private static final Order WRONG_NAME = new Order("", "12345678901", "addr", "dep", "order");
|
||||
|
||||
@Parameters
|
||||
public static List<Object[]> getTestData() {
|
||||
static List<Object[]> getTestData() {
|
||||
final List<Object[]> testData = new ArrayList<>();
|
||||
testData.add(new Object[]{new NameFilter(), PERFECT_ORDER, ""});
|
||||
testData.add(new Object[]{new NameFilter(), WRONG_NAME, "Invalid name!"});
|
||||
@ -91,30 +87,19 @@ public class FilterTest {
|
||||
return testData;
|
||||
}
|
||||
|
||||
private final Filter filter;
|
||||
private final Order order;
|
||||
private final String result;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public FilterTest(Filter filter, Order order, String result) {
|
||||
this.filter = filter;
|
||||
this.order = order;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() throws Exception {
|
||||
final String result = this.filter.execute(this.order);
|
||||
@ParameterizedTest
|
||||
@MethodSource("getTestData")
|
||||
public void testExecute(Filter filter, Order order, String expectedResult) throws Exception {
|
||||
final String result = filter.execute(order);
|
||||
assertNotNull(result);
|
||||
assertEquals(this.result, result.trim());
|
||||
assertEquals(expectedResult, result.trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNext() throws Exception {
|
||||
assertNull(this.filter.getNext());
|
||||
assertSame(this.filter, this.filter.getLast());
|
||||
@ParameterizedTest
|
||||
@MethodSource("getTestData")
|
||||
public void testNext(Filter filter) throws Exception {
|
||||
assertNull(filter.getNext());
|
||||
assertSame(filter, filter.getLast());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,9 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.intercepting.filter;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Date: 12/13/15 - 2:57 PM
|
||||
|
Reference in New Issue
Block a user