Skip to content

Commit 18b04db

Browse files
dependencies: remove mongodb uber artifact (iluwatar#2356)
1 parent 0793c50 commit 18b04db

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

caching/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
</dependency>
4747
<dependency>
4848
<groupId>org.mongodb</groupId>
49-
<artifactId>mongo-java-driver</artifactId>
49+
<artifactId>bson</artifactId>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.mongodb</groupId>
53+
<artifactId>mongodb-driver-legacy</artifactId>
5054
</dependency>
5155
</dependencies>
5256
<!--

caching/src/main/java/com/iluwatar/caching/database/MongoDb.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import com.mongodb.ServerAddress;
3838
import com.mongodb.client.MongoDatabase;
3939
import com.mongodb.client.model.UpdateOptions;
40-
import java.util.List;
4140
import lombok.extern.slf4j.Slf4j;
4241
import org.bson.Document;
4342

@@ -66,7 +65,7 @@ public void connect() {
6665
DATABASE_NAME,
6766
MONGO_PASSWORD.toCharArray());
6867
MongoClientOptions options = MongoClientOptions.builder().build();
69-
client = new MongoClient(new ServerAddress(), List.of(mongoCredential), options);
68+
client = new MongoClient(new ServerAddress(), mongoCredential, options);
7069
db = client.getDatabase(DATABASE_NAME);
7170
}
7271

caching/src/test/java/com/iluwatar/caching/database/MongoDbTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ void readFromDb() {
8484
void writeToDb() {
8585
MongoCollection<Document> mongoCollection = mock(MongoCollection.class);
8686
when(db.getCollection(CachingConstants.USER_ACCOUNT)).thenReturn(mongoCollection);
87-
doNothing().when(mongoCollection).insertOne(any(Document.class));
8887
assertDoesNotThrow(()-> {mongoDb.writeToDb(userAccount);});
8988
}
9089

hexagonal/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@
4545
</dependency>
4646
<dependency>
4747
<groupId>org.mongodb</groupId>
48-
<artifactId>mongo-java-driver</artifactId>
48+
<artifactId>bson</artifactId>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.mongodb</groupId>
52+
<artifactId>mongodb-driver-legacy</artifactId>
4953
</dependency>
5054
</dependencies>
5155
<build>

hexagonal/src/main/java/com/iluwatar/hexagonal/database/MongoTicketRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void connect(String dbName, String ticketsCollectionName,
8989
database = mongoClient.getDatabase(dbName);
9090
ticketsCollection = database.getCollection(ticketsCollectionName);
9191
countersCollection = database.getCollection(countersCollectionName);
92-
if (countersCollection.count() <= 0) {
92+
if (countersCollection.countDocuments() <= 0) {
9393
initCounters();
9494
}
9595
}

hexagonal/src/test/java/com/iluwatar/hexagonal/banking/MongoBankTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void init() {
5555

5656
@Test
5757
void testSetup() {
58-
assertEquals(0, mongoBank.getAccountsCollection().count());
58+
assertEquals(0, mongoBank.getAccountsCollection().countDocuments());
5959
}
6060

6161
@Test

hexagonal/src/test/java/com/iluwatar/hexagonal/database/MongoTicketRepositoryTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ void init() {
6262

6363
@Test
6464
void testSetup() {
65-
assertEquals(1, repository.getCountersCollection().count());
66-
assertEquals(0, repository.getTicketsCollection().count());
65+
assertEquals(1, repository.getCountersCollection().countDocuments());
66+
assertEquals(0, repository.getTicketsCollection().countDocuments());
6767
}
6868

6969
@Test
@@ -80,7 +80,7 @@ void testCrudOperations() {
8080
var random = LotteryNumbers.createRandom();
8181
var original = new LotteryTicket(new LotteryTicketId(), details, random);
8282
var saved = repository.save(original);
83-
assertEquals(1, repository.getTicketsCollection().count());
83+
assertEquals(1, repository.getTicketsCollection().countDocuments());
8484
assertTrue(saved.isPresent());
8585
// fetch the saved lottery ticket from database and check its contents
8686
var found = repository.findById(saved.get());
@@ -92,6 +92,6 @@ void testCrudOperations() {
9292
assertEquals(original.getLotteryNumbers(), ticket.getLotteryNumbers());
9393
// clear the collection
9494
repository.deleteAll();
95-
assertEquals(0, repository.getTicketsCollection().count());
95+
assertEquals(0, repository.getTicketsCollection().countDocuments());
9696
}
9797
}

hexagonal/src/test/java/com/iluwatar/hexagonal/eventlog/MongoEventLogTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,31 @@ void init() {
5656

5757
@Test
5858
void testSetup() {
59-
assertEquals(0, mongoEventLog.getEventsCollection().count());
59+
assertEquals(0, mongoEventLog.getEventsCollection().countDocuments());
6060
}
6161

6262
@Test
6363
void testFundTransfers() {
6464
var playerDetails = new PlayerDetails("[email protected]", "000-000", "03432534543");
6565
mongoEventLog.prizeError(playerDetails, 1000);
66-
assertEquals(1, mongoEventLog.getEventsCollection().count());
66+
assertEquals(1, mongoEventLog.getEventsCollection().countDocuments());
6767
mongoEventLog.prizeError(playerDetails, 1000);
68-
assertEquals(2, mongoEventLog.getEventsCollection().count());
68+
assertEquals(2, mongoEventLog.getEventsCollection().countDocuments());
6969
mongoEventLog.ticketDidNotWin(playerDetails);
70-
assertEquals(3, mongoEventLog.getEventsCollection().count());
70+
assertEquals(3, mongoEventLog.getEventsCollection().countDocuments());
7171
mongoEventLog.ticketDidNotWin(playerDetails);
72-
assertEquals(4, mongoEventLog.getEventsCollection().count());
72+
assertEquals(4, mongoEventLog.getEventsCollection().countDocuments());
7373
mongoEventLog.ticketSubmitError(playerDetails);
74-
assertEquals(5, mongoEventLog.getEventsCollection().count());
74+
assertEquals(5, mongoEventLog.getEventsCollection().countDocuments());
7575
mongoEventLog.ticketSubmitError(playerDetails);
76-
assertEquals(6, mongoEventLog.getEventsCollection().count());
76+
assertEquals(6, mongoEventLog.getEventsCollection().countDocuments());
7777
mongoEventLog.ticketSubmitted(playerDetails);
78-
assertEquals(7, mongoEventLog.getEventsCollection().count());
78+
assertEquals(7, mongoEventLog.getEventsCollection().countDocuments());
7979
mongoEventLog.ticketSubmitted(playerDetails);
80-
assertEquals(8, mongoEventLog.getEventsCollection().count());
80+
assertEquals(8, mongoEventLog.getEventsCollection().countDocuments());
8181
mongoEventLog.ticketWon(playerDetails, 1000);
82-
assertEquals(9, mongoEventLog.getEventsCollection().count());
82+
assertEquals(9, mongoEventLog.getEventsCollection().countDocuments());
8383
mongoEventLog.ticketWon(playerDetails, 1000);
84-
assertEquals(10, mongoEventLog.getEventsCollection().count());
84+
assertEquals(10, mongoEventLog.getEventsCollection().countDocuments());
8585
}
8686
}

pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
<guava.version>19.0</guava.version>
4444
<htmlunit.version>2.66.0</htmlunit.version>
4545
<guice.version>4.0</guice.version>
46-
<mongo-java-driver.version>3.12.8</mongo-java-driver.version>
4746
<system-lambda.version>1.1.0</system-lambda.version>
4847
<urm.version>2.0.0</urm.version>
4948
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
@@ -239,11 +238,6 @@
239238
<artifactId>guice</artifactId>
240239
<version>${guice.version}</version>
241240
</dependency>
242-
<dependency>
243-
<groupId>org.mongodb</groupId>
244-
<artifactId>mongo-java-driver</artifactId>
245-
<version>${mongo-java-driver.version}</version>
246-
</dependency>
247241
<dependency>
248242
<groupId>com.github.stefanbirkner</groupId>
249243
<artifactId>system-lambda</artifactId>

0 commit comments

Comments
 (0)