mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-17 02:59:23 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -24,18 +24,15 @@
|
||||
*/
|
||||
package com.iluwatar.hexagonal;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit test for simple App. */
|
||||
class AppTest {
|
||||
|
||||
@Test
|
||||
void shouldExecuteApplicationWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -29,9 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for banking
|
||||
*/
|
||||
/** Tests for banking */
|
||||
class InMemoryBankTest {
|
||||
|
||||
private final WireTransfers bank = new InMemoryBank();
|
||||
|
||||
+2
-7
@@ -39,9 +39,7 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for Mongo banking adapter
|
||||
*/
|
||||
/** Tests for Mongo banking adapter */
|
||||
class MongoBankTest {
|
||||
|
||||
private static final String TEST_DB = "lotteryDBTest";
|
||||
@@ -56,8 +54,6 @@ class MongoBankTest {
|
||||
|
||||
private static ServerAddress serverAddress;
|
||||
|
||||
|
||||
|
||||
@BeforeAll
|
||||
static void setUp() {
|
||||
mongodProcess = Mongod.instance().start(Version.Main.V7_0);
|
||||
@@ -73,7 +69,6 @@ class MongoBankTest {
|
||||
mongodProcess.close();
|
||||
}
|
||||
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
System.setProperty("mongo-host", serverAddress.getHost());
|
||||
@@ -97,4 +92,4 @@ class MongoBankTest {
|
||||
assertEquals(1, mongoBank.getFunds("000-000"));
|
||||
assertEquals(9, mongoBank.getFunds("111-111"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -31,9 +31,7 @@ import com.iluwatar.hexagonal.test.LotteryTestUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link LotteryTicketRepository}
|
||||
*/
|
||||
/** Tests for {@link LotteryTicketRepository} */
|
||||
class InMemoryTicketRepositoryTest {
|
||||
|
||||
private final LotteryTicketRepository repository = new InMemoryTicketRepository();
|
||||
|
||||
+6
-7
@@ -37,9 +37,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for Mongo based ticket repository
|
||||
*/
|
||||
/** Tests for Mongo based ticket repository */
|
||||
@Disabled
|
||||
class MongoTicketRepositoryTest {
|
||||
|
||||
@@ -52,12 +50,13 @@ class MongoTicketRepositoryTest {
|
||||
@BeforeEach
|
||||
void init() {
|
||||
MongoConnectionPropertiesLoader.load();
|
||||
var mongoClient = new MongoClient(System.getProperty("mongo-host"),
|
||||
Integer.parseInt(System.getProperty("mongo-port")));
|
||||
var mongoClient =
|
||||
new MongoClient(
|
||||
System.getProperty("mongo-host"), Integer.parseInt(System.getProperty("mongo-port")));
|
||||
mongoClient.dropDatabase(TEST_DB);
|
||||
mongoClient.close();
|
||||
repository = new MongoTicketRepository(TEST_DB, TEST_TICKETS_COLLECTION,
|
||||
TEST_COUNTERS_COLLECTION);
|
||||
repository =
|
||||
new MongoTicketRepository(TEST_DB, TEST_TICKETS_COLLECTION, TEST_COUNTERS_COLLECTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-3
@@ -32,9 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import java.util.Set;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link LotteryNumbers}
|
||||
*/
|
||||
/** Unit tests for {@link LotteryNumbers} */
|
||||
class LotteryNumbersTest {
|
||||
|
||||
@Test
|
||||
|
||||
+20
-17
@@ -39,18 +39,13 @@ import java.util.Set;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test the lottery system
|
||||
*/
|
||||
/** Test the lottery system */
|
||||
class LotteryTest {
|
||||
|
||||
private final Injector injector;
|
||||
@Inject
|
||||
private LotteryAdministration administration;
|
||||
@Inject
|
||||
private LotteryService service;
|
||||
@Inject
|
||||
private WireTransfers wireTransfers;
|
||||
@Inject private LotteryAdministration administration;
|
||||
@Inject private LotteryService service;
|
||||
@Inject private WireTransfers wireTransfers;
|
||||
|
||||
LotteryTest() {
|
||||
this.injector = Guice.createInjector(new LotteryTestingModule());
|
||||
@@ -70,14 +65,20 @@ class LotteryTest {
|
||||
assertEquals(0, administration.getAllSubmittedTickets().size());
|
||||
|
||||
// players submit the lottery tickets
|
||||
var ticket1 = service.submitTicket(LotteryTestUtils.createLotteryTicket("cvt@bbb.com",
|
||||
"123-12312", "+32425255", Set.of(1, 2, 3, 4)));
|
||||
var ticket1 =
|
||||
service.submitTicket(
|
||||
LotteryTestUtils.createLotteryTicket(
|
||||
"cvt@bbb.com", "123-12312", "+32425255", Set.of(1, 2, 3, 4)));
|
||||
assertTrue(ticket1.isPresent());
|
||||
var ticket2 = service.submitTicket(LotteryTestUtils.createLotteryTicket("ant@bac.com",
|
||||
"123-12312", "+32423455", Set.of(11, 12, 13, 14)));
|
||||
var ticket2 =
|
||||
service.submitTicket(
|
||||
LotteryTestUtils.createLotteryTicket(
|
||||
"ant@bac.com", "123-12312", "+32423455", Set.of(11, 12, 13, 14)));
|
||||
assertTrue(ticket2.isPresent());
|
||||
var ticket3 = service.submitTicket(LotteryTestUtils.createLotteryTicket("arg@boo.com",
|
||||
"123-12312", "+32421255", Set.of(6, 8, 13, 19)));
|
||||
var ticket3 =
|
||||
service.submitTicket(
|
||||
LotteryTestUtils.createLotteryTicket(
|
||||
"arg@boo.com", "123-12312", "+32421255", Set.of(6, 8, 13, 19)));
|
||||
assertTrue(ticket3.isPresent());
|
||||
assertEquals(3, administration.getAllSubmittedTickets().size());
|
||||
|
||||
@@ -85,8 +86,10 @@ class LotteryTest {
|
||||
var winningNumbers = administration.performLottery();
|
||||
|
||||
// cheat a bit for testing sake, use winning numbers to submit another ticket
|
||||
var ticket4 = service.submitTicket(LotteryTestUtils.createLotteryTicket("lucky@orb.com",
|
||||
"123-12312", "+12421255", winningNumbers.getNumbers()));
|
||||
var ticket4 =
|
||||
service.submitTicket(
|
||||
LotteryTestUtils.createLotteryTicket(
|
||||
"lucky@orb.com", "123-12312", "+12421255", winningNumbers.getNumbers()));
|
||||
assertTrue(ticket4.isPresent());
|
||||
assertEquals(4, administration.getAllSubmittedTickets().size());
|
||||
|
||||
|
||||
+1
-3
@@ -30,9 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import com.iluwatar.hexagonal.domain.LotteryTicketCheckResult.CheckResult;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link LotteryTicketCheckResult}
|
||||
*/
|
||||
/** Unit tests for {@link LotteryTicketCheckResult} */
|
||||
class LotteryTicketCheckResultTest {
|
||||
|
||||
@Test
|
||||
|
||||
+1
-3
@@ -29,9 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for lottery ticket id
|
||||
*/
|
||||
/** Tests for lottery ticket id */
|
||||
class LotteryTicketIdTest {
|
||||
|
||||
@Test
|
||||
|
||||
+1
-3
@@ -30,9 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import java.util.Set;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test Lottery Tickets for equality
|
||||
*/
|
||||
/** Test Lottery Tickets for equality */
|
||||
class LotteryTicketTest {
|
||||
|
||||
@Test
|
||||
|
||||
+1
-3
@@ -29,9 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link PlayerDetails}
|
||||
*/
|
||||
/** Unit tests for {@link PlayerDetails} */
|
||||
class PlayerDetailsTest {
|
||||
|
||||
@Test
|
||||
|
||||
+4
-5
@@ -33,9 +33,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for Mongo event log
|
||||
*/
|
||||
/** Tests for Mongo event log */
|
||||
@Disabled
|
||||
class MongoEventLogTest {
|
||||
|
||||
@@ -47,8 +45,9 @@ class MongoEventLogTest {
|
||||
@BeforeEach
|
||||
void init() {
|
||||
MongoConnectionPropertiesLoader.load();
|
||||
var mongoClient = new MongoClient(System.getProperty("mongo-host"),
|
||||
Integer.parseInt(System.getProperty("mongo-port")));
|
||||
var mongoClient =
|
||||
new MongoClient(
|
||||
System.getProperty("mongo-host"), Integer.parseInt(System.getProperty("mongo-port")));
|
||||
mongoClient.dropDatabase(TEST_DB);
|
||||
mongoClient.close();
|
||||
mongoEventLog = new MongoEventLog(TEST_DB, TEST_EVENTS_COLLECTION);
|
||||
|
||||
+3
-5
@@ -30,9 +30,7 @@ import com.iluwatar.hexagonal.domain.LotteryTicketId;
|
||||
import com.iluwatar.hexagonal.domain.PlayerDetails;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Utilities for lottery tests
|
||||
*/
|
||||
/** Utilities for lottery tests */
|
||||
public class LotteryTestUtils {
|
||||
|
||||
/**
|
||||
@@ -45,8 +43,8 @@ public class LotteryTestUtils {
|
||||
/**
|
||||
* @return lottery ticket
|
||||
*/
|
||||
public static LotteryTicket createLotteryTicket(String email, String account, String phone,
|
||||
Set<Integer> givenNumbers) {
|
||||
public static LotteryTicket createLotteryTicket(
|
||||
String email, String account, String phone, Set<Integer> givenNumbers) {
|
||||
var details = new PlayerDetails(email, account, phone);
|
||||
var numbers = LotteryNumbers.create(givenNumbers);
|
||||
return new LotteryTicket(new LotteryTicketId(), details, numbers);
|
||||
|
||||
Reference in New Issue
Block a user