Migrate to JUnit5

This commit is contained in:
Artur Mogozov
2017-12-31 16:29:48 +09:00
parent a20e54d0a7
commit 6694d742a3
408 changed files with 2656 additions and 2165 deletions

View File

@ -22,7 +22,7 @@
*/
package com.iluwatar.hexagonal;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.

View File

@ -22,10 +22,10 @@
*/
package com.iluwatar.hexagonal.banking;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*

View File

@ -24,16 +24,16 @@ package com.iluwatar.hexagonal.banking;
import com.iluwatar.hexagonal.mongo.MongoConnectionPropertiesLoader;
import com.mongodb.MongoClient;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for Mongo banking adapter
*/
@Ignore
@Disabled
public class MongoBankTest {
private static final String TEST_DB = "lotteryDBTest";
@ -41,7 +41,7 @@ public class MongoBankTest {
private MongoBank mongoBank;
@Before
@BeforeEach
public void init() {
MongoConnectionPropertiesLoader.load();
MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"),

View File

@ -22,17 +22,16 @@
*/
package com.iluwatar.hexagonal.database;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import com.iluwatar.hexagonal.domain.LotteryTicket;
import com.iluwatar.hexagonal.domain.LotteryTicketId;
import com.iluwatar.hexagonal.test.LotteryTestUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
@ -43,7 +42,7 @@ public class InMemoryTicketRepositoryTest {
private final LotteryTicketRepository repository = new InMemoryTicketRepository();
@Before
@BeforeEach
public void clear() {
repository.deleteAll();
}

View File

@ -28,19 +28,19 @@ import com.iluwatar.hexagonal.domain.LotteryTicketId;
import com.iluwatar.hexagonal.domain.PlayerDetails;
import com.iluwatar.hexagonal.mongo.MongoConnectionPropertiesLoader;
import com.mongodb.MongoClient;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for Mongo based ticket repository
*/
@Ignore
@Disabled
public class MongoTicketRepositoryTest {
private static final String TEST_DB = "lotteryTestDB";
@ -49,7 +49,7 @@ public class MongoTicketRepositoryTest {
private MongoTicketRepository repository;
@Before
@BeforeEach
public void init() {
MongoConnectionPropertiesLoader.load();
MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"),

View File

@ -22,14 +22,15 @@
*/
package com.iluwatar.hexagonal.domain;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashSet;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
@ -49,11 +50,13 @@ public class LotteryNumbersTest {
assertTrue(numbers.getNumbers().contains(4));
}
@Test(expected = UnsupportedOperationException.class)
@Test
public void testNumbersCantBeModified() {
LotteryNumbers numbers = LotteryNumbers.create(
new HashSet<>(Arrays.asList(1, 2, 3, 4)));
numbers.getNumbers().add(5);
assertThrows(UnsupportedOperationException.class, () -> {
numbers.getNumbers().add(5);
});
}
@Test

View File

@ -22,24 +22,23 @@
*/
package com.iluwatar.hexagonal.domain;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.iluwatar.hexagonal.banking.WireTransfers;
import com.iluwatar.hexagonal.domain.LotteryTicketCheckResult.CheckResult;
import com.iluwatar.hexagonal.module.LotteryTestingModule;
import com.iluwatar.hexagonal.test.LotteryTestUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.iluwatar.hexagonal.module.LotteryTestingModule;
import org.junit.Before;
import org.junit.Test;
import com.iluwatar.hexagonal.banking.WireTransfers;
import com.iluwatar.hexagonal.domain.LotteryTicketCheckResult.CheckResult;
import com.iluwatar.hexagonal.test.LotteryTestUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
@ -60,7 +59,7 @@ public class LotteryTest {
this.injector = Guice.createInjector(new LotteryTestingModule());
}
@Before
@BeforeEach
public void setup() {
injector.injectMembers(this);
// add funds to the test player's bank account

View File

@ -22,12 +22,11 @@
*/
package com.iluwatar.hexagonal.domain;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Test;
import com.iluwatar.hexagonal.domain.LotteryTicketCheckResult.CheckResult;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
/**
*

View File

@ -22,10 +22,10 @@
*/
package com.iluwatar.hexagonal.domain;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for lottery ticket id

View File

@ -22,13 +22,13 @@
*/
package com.iluwatar.hexagonal.domain;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashSet;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Test Lottery Tickets for equality

View File

@ -22,10 +22,10 @@
*/
package com.iluwatar.hexagonal.domain;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
/**
*

View File

@ -25,16 +25,16 @@ package com.iluwatar.hexagonal.eventlog;
import com.iluwatar.hexagonal.domain.PlayerDetails;
import com.iluwatar.hexagonal.mongo.MongoConnectionPropertiesLoader;
import com.mongodb.MongoClient;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for Mongo event log
*/
@Ignore
@Disabled
public class MongoEventLogTest {
private static final String TEST_DB = "lotteryDBTest";
@ -42,7 +42,7 @@ public class MongoEventLogTest {
private MongoEventLog mongoEventLog;
@Before
@BeforeEach
public void init() {
MongoConnectionPropertiesLoader.load();
MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"),