mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-19 21:25:38 +00:00
dependencies: remove mongodb uber artifact (#2356)
This commit is contained in:
@@ -89,7 +89,7 @@ public class MongoTicketRepository implements LotteryTicketRepository {
|
||||
database = mongoClient.getDatabase(dbName);
|
||||
ticketsCollection = database.getCollection(ticketsCollectionName);
|
||||
countersCollection = database.getCollection(countersCollectionName);
|
||||
if (countersCollection.count() <= 0) {
|
||||
if (countersCollection.countDocuments() <= 0) {
|
||||
initCounters();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class MongoBankTest {
|
||||
|
||||
@Test
|
||||
void testSetup() {
|
||||
assertEquals(0, mongoBank.getAccountsCollection().count());
|
||||
assertEquals(0, mongoBank.getAccountsCollection().countDocuments());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-4
@@ -62,8 +62,8 @@ class MongoTicketRepositoryTest {
|
||||
|
||||
@Test
|
||||
void testSetup() {
|
||||
assertEquals(1, repository.getCountersCollection().count());
|
||||
assertEquals(0, repository.getTicketsCollection().count());
|
||||
assertEquals(1, repository.getCountersCollection().countDocuments());
|
||||
assertEquals(0, repository.getTicketsCollection().countDocuments());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,7 +80,7 @@ class MongoTicketRepositoryTest {
|
||||
var random = LotteryNumbers.createRandom();
|
||||
var original = new LotteryTicket(new LotteryTicketId(), details, random);
|
||||
var saved = repository.save(original);
|
||||
assertEquals(1, repository.getTicketsCollection().count());
|
||||
assertEquals(1, repository.getTicketsCollection().countDocuments());
|
||||
assertTrue(saved.isPresent());
|
||||
// fetch the saved lottery ticket from database and check its contents
|
||||
var found = repository.findById(saved.get());
|
||||
@@ -92,6 +92,6 @@ class MongoTicketRepositoryTest {
|
||||
assertEquals(original.getLotteryNumbers(), ticket.getLotteryNumbers());
|
||||
// clear the collection
|
||||
repository.deleteAll();
|
||||
assertEquals(0, repository.getTicketsCollection().count());
|
||||
assertEquals(0, repository.getTicketsCollection().countDocuments());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,31 +56,31 @@ class MongoEventLogTest {
|
||||
|
||||
@Test
|
||||
void testSetup() {
|
||||
assertEquals(0, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(0, mongoEventLog.getEventsCollection().countDocuments());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFundTransfers() {
|
||||
var playerDetails = new PlayerDetails("john@wayne.com", "000-000", "03432534543");
|
||||
mongoEventLog.prizeError(playerDetails, 1000);
|
||||
assertEquals(1, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(1, mongoEventLog.getEventsCollection().countDocuments());
|
||||
mongoEventLog.prizeError(playerDetails, 1000);
|
||||
assertEquals(2, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(2, mongoEventLog.getEventsCollection().countDocuments());
|
||||
mongoEventLog.ticketDidNotWin(playerDetails);
|
||||
assertEquals(3, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(3, mongoEventLog.getEventsCollection().countDocuments());
|
||||
mongoEventLog.ticketDidNotWin(playerDetails);
|
||||
assertEquals(4, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(4, mongoEventLog.getEventsCollection().countDocuments());
|
||||
mongoEventLog.ticketSubmitError(playerDetails);
|
||||
assertEquals(5, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(5, mongoEventLog.getEventsCollection().countDocuments());
|
||||
mongoEventLog.ticketSubmitError(playerDetails);
|
||||
assertEquals(6, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(6, mongoEventLog.getEventsCollection().countDocuments());
|
||||
mongoEventLog.ticketSubmitted(playerDetails);
|
||||
assertEquals(7, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(7, mongoEventLog.getEventsCollection().countDocuments());
|
||||
mongoEventLog.ticketSubmitted(playerDetails);
|
||||
assertEquals(8, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(8, mongoEventLog.getEventsCollection().countDocuments());
|
||||
mongoEventLog.ticketWon(playerDetails, 1000);
|
||||
assertEquals(9, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(9, mongoEventLog.getEventsCollection().countDocuments());
|
||||
mongoEventLog.ticketWon(playerDetails, 1000);
|
||||
assertEquals(10, mongoEventLog.getEventsCollection().count());
|
||||
assertEquals(10, mongoEventLog.getEventsCollection().countDocuments());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user