mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 10:18:39 +00:00
dependencies: remove mongodb uber artifact (#2356)
This commit is contained in:
1 parent
0793c50363
commit
18b04db103
9 files changed
+28
-28
No files matched your search
+5
-1
@@ -46,7 +46,11 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<artifactId>mongo-java-driver</artifactId>
|
<artifactId>bson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>mongodb-driver-legacy</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import com.mongodb.MongoCredential;
|
|||||||
import com.mongodb.ServerAddress;
|
import com.mongodb.ServerAddress;
|
||||||
import com.mongodb.client.MongoDatabase;
|
import com.mongodb.client.MongoDatabase;
|
||||||
import com.mongodb.client.model.UpdateOptions;
|
import com.mongodb.client.model.UpdateOptions;
|
||||||
import java.util.List;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
|
||||||
@@ -66,7 +65,7 @@ public class MongoDb implements DbManager {
|
|||||||
DATABASE_NAME,
|
DATABASE_NAME,
|
||||||
MONGO_PASSWORD.toCharArray());
|
MONGO_PASSWORD.toCharArray());
|
||||||
MongoClientOptions options = MongoClientOptions.builder().build();
|
MongoClientOptions options = MongoClientOptions.builder().build();
|
||||||
client = new MongoClient(new ServerAddress(), List.of(mongoCredential), options);
|
client = new MongoClient(new ServerAddress(), mongoCredential, options);
|
||||||
db = client.getDatabase(DATABASE_NAME);
|
db = client.getDatabase(DATABASE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ class MongoDbTest {
|
|||||||
void writeToDb() {
|
void writeToDb() {
|
||||||
MongoCollection<Document> mongoCollection = mock(MongoCollection.class);
|
MongoCollection<Document> mongoCollection = mock(MongoCollection.class);
|
||||||
when(db.getCollection(CachingConstants.USER_ACCOUNT)).thenReturn(mongoCollection);
|
when(db.getCollection(CachingConstants.USER_ACCOUNT)).thenReturn(mongoCollection);
|
||||||
doNothing().when(mongoCollection).insertOne(any(Document.class));
|
|
||||||
assertDoesNotThrow(()-> {mongoDb.writeToDb(userAccount);});
|
assertDoesNotThrow(()-> {mongoDb.writeToDb(userAccount);});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -45,7 +45,11 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<artifactId>mongo-java-driver</artifactId>
|
<artifactId>bson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>mongodb-driver-legacy</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class MongoTicketRepository implements LotteryTicketRepository {
|
|||||||
database = mongoClient.getDatabase(dbName);
|
database = mongoClient.getDatabase(dbName);
|
||||||
ticketsCollection = database.getCollection(ticketsCollectionName);
|
ticketsCollection = database.getCollection(ticketsCollectionName);
|
||||||
countersCollection = database.getCollection(countersCollectionName);
|
countersCollection = database.getCollection(countersCollectionName);
|
||||||
if (countersCollection.count() <= 0) {
|
if (countersCollection.countDocuments() <= 0) {
|
||||||
initCounters();
|
initCounters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class MongoBankTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSetup() {
|
void testSetup() {
|
||||||
assertEquals(0, mongoBank.getAccountsCollection().count());
|
assertEquals(0, mongoBank.getAccountsCollection().countDocuments());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+4
-4
@@ -62,8 +62,8 @@ class MongoTicketRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSetup() {
|
void testSetup() {
|
||||||
assertEquals(1, repository.getCountersCollection().count());
|
assertEquals(1, repository.getCountersCollection().countDocuments());
|
||||||
assertEquals(0, repository.getTicketsCollection().count());
|
assertEquals(0, repository.getTicketsCollection().countDocuments());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -80,7 +80,7 @@ class MongoTicketRepositoryTest {
|
|||||||
var random = LotteryNumbers.createRandom();
|
var random = LotteryNumbers.createRandom();
|
||||||
var original = new LotteryTicket(new LotteryTicketId(), details, random);
|
var original = new LotteryTicket(new LotteryTicketId(), details, random);
|
||||||
var saved = repository.save(original);
|
var saved = repository.save(original);
|
||||||
assertEquals(1, repository.getTicketsCollection().count());
|
assertEquals(1, repository.getTicketsCollection().countDocuments());
|
||||||
assertTrue(saved.isPresent());
|
assertTrue(saved.isPresent());
|
||||||
// fetch the saved lottery ticket from database and check its contents
|
// fetch the saved lottery ticket from database and check its contents
|
||||||
var found = repository.findById(saved.get());
|
var found = repository.findById(saved.get());
|
||||||
@@ -92,6 +92,6 @@ class MongoTicketRepositoryTest {
|
|||||||
assertEquals(original.getLotteryNumbers(), ticket.getLotteryNumbers());
|
assertEquals(original.getLotteryNumbers(), ticket.getLotteryNumbers());
|
||||||
// clear the collection
|
// clear the collection
|
||||||
repository.deleteAll();
|
repository.deleteAll();
|
||||||
assertEquals(0, repository.getTicketsCollection().count());
|
assertEquals(0, repository.getTicketsCollection().countDocuments());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,31 +56,31 @@ class MongoEventLogTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSetup() {
|
void testSetup() {
|
||||||
assertEquals(0, mongoEventLog.getEventsCollection().count());
|
assertEquals(0, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFundTransfers() {
|
void testFundTransfers() {
|
||||||
var playerDetails = new PlayerDetails("john@wayne.com", "000-000", "03432534543");
|
var playerDetails = new PlayerDetails("john@wayne.com", "000-000", "03432534543");
|
||||||
mongoEventLog.prizeError(playerDetails, 1000);
|
mongoEventLog.prizeError(playerDetails, 1000);
|
||||||
assertEquals(1, mongoEventLog.getEventsCollection().count());
|
assertEquals(1, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
mongoEventLog.prizeError(playerDetails, 1000);
|
mongoEventLog.prizeError(playerDetails, 1000);
|
||||||
assertEquals(2, mongoEventLog.getEventsCollection().count());
|
assertEquals(2, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
mongoEventLog.ticketDidNotWin(playerDetails);
|
mongoEventLog.ticketDidNotWin(playerDetails);
|
||||||
assertEquals(3, mongoEventLog.getEventsCollection().count());
|
assertEquals(3, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
mongoEventLog.ticketDidNotWin(playerDetails);
|
mongoEventLog.ticketDidNotWin(playerDetails);
|
||||||
assertEquals(4, mongoEventLog.getEventsCollection().count());
|
assertEquals(4, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
mongoEventLog.ticketSubmitError(playerDetails);
|
mongoEventLog.ticketSubmitError(playerDetails);
|
||||||
assertEquals(5, mongoEventLog.getEventsCollection().count());
|
assertEquals(5, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
mongoEventLog.ticketSubmitError(playerDetails);
|
mongoEventLog.ticketSubmitError(playerDetails);
|
||||||
assertEquals(6, mongoEventLog.getEventsCollection().count());
|
assertEquals(6, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
mongoEventLog.ticketSubmitted(playerDetails);
|
mongoEventLog.ticketSubmitted(playerDetails);
|
||||||
assertEquals(7, mongoEventLog.getEventsCollection().count());
|
assertEquals(7, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
mongoEventLog.ticketSubmitted(playerDetails);
|
mongoEventLog.ticketSubmitted(playerDetails);
|
||||||
assertEquals(8, mongoEventLog.getEventsCollection().count());
|
assertEquals(8, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
mongoEventLog.ticketWon(playerDetails, 1000);
|
mongoEventLog.ticketWon(playerDetails, 1000);
|
||||||
assertEquals(9, mongoEventLog.getEventsCollection().count());
|
assertEquals(9, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
mongoEventLog.ticketWon(playerDetails, 1000);
|
mongoEventLog.ticketWon(playerDetails, 1000);
|
||||||
assertEquals(10, mongoEventLog.getEventsCollection().count());
|
assertEquals(10, mongoEventLog.getEventsCollection().countDocuments());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,6 @@
|
|||||||
<guava.version>19.0</guava.version>
|
<guava.version>19.0</guava.version>
|
||||||
<htmlunit.version>2.66.0</htmlunit.version>
|
<htmlunit.version>2.66.0</htmlunit.version>
|
||||||
<guice.version>4.0</guice.version>
|
<guice.version>4.0</guice.version>
|
||||||
<mongo-java-driver.version>3.12.8</mongo-java-driver.version>
|
|
||||||
<system-lambda.version>1.1.0</system-lambda.version>
|
<system-lambda.version>1.1.0</system-lambda.version>
|
||||||
<urm.version>2.0.0</urm.version>
|
<urm.version>2.0.0</urm.version>
|
||||||
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
|
||||||
@@ -239,11 +238,6 @@
|
|||||||
<artifactId>guice</artifactId>
|
<artifactId>guice</artifactId>
|
||||||
<version>${guice.version}</version>
|
<version>${guice.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.mongodb</groupId>
|
|
||||||
<artifactId>mongo-java-driver</artifactId>
|
|
||||||
<version>${mongo-java-driver.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.stefanbirkner</groupId>
|
<groupId>com.github.stefanbirkner</groupId>
|
||||||
<artifactId>system-lambda</artifactId>
|
<artifactId>system-lambda</artifactId>
|
||||||
|
|||||||
Reference in new issue
Block a user