dependencies: remove mongodb uber artifact (#2356)

This commit is contained in:
Robert Volkmann
2022-12-04 09:55:33 +01:00
committed by GitHub
parent 0793c50363
commit 18b04db103
9 changed files with 28 additions and 28 deletions
+5 -1
View File
@@ -46,7 +46,11 @@
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<artifactId>bson</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-legacy</artifactId>
</dependency>
</dependencies>
<!--
@@ -37,7 +37,6 @@ import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.UpdateOptions;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
@@ -66,7 +65,7 @@ public class MongoDb implements DbManager {
DATABASE_NAME,
MONGO_PASSWORD.toCharArray());
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);
}
@@ -84,7 +84,6 @@ class MongoDbTest {
void writeToDb() {
MongoCollection<Document> mongoCollection = mock(MongoCollection.class);
when(db.getCollection(CachingConstants.USER_ACCOUNT)).thenReturn(mongoCollection);
doNothing().when(mongoCollection).insertOne(any(Document.class));
assertDoesNotThrow(()-> {mongoDb.writeToDb(userAccount);});
}
+5 -1
View File
@@ -45,7 +45,11 @@
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<artifactId>bson</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-legacy</artifactId>
</dependency>
</dependencies>
<build>
@@ -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
@@ -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());
}
}
-6
View File
@@ -43,7 +43,6 @@
<guava.version>19.0</guava.version>
<htmlunit.version>2.66.0</htmlunit.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>
<urm.version>2.0.0</urm.version>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
@@ -239,11 +238,6 @@
<artifactId>guice</artifactId>
<version>${guice.version}</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>${mongo-java-driver.version}</version>
</dependency>
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-lambda</artifactId>