Skip to content

Commit 386b2f2

Browse files
committed
implements at mongodb
1 parent 46f11e7 commit 386b2f2

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

mongodb-driver/src/test/java/org/jnosql/diana/mongodb/document/MongoDBDocumentCollectionManagerAsyncTest.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
import java.util.Map;
3333
import java.util.Random;
3434
import java.util.concurrent.atomic.AtomicBoolean;
35+
import java.util.concurrent.atomic.AtomicLong;
3536
import java.util.concurrent.atomic.AtomicReference;
37+
import java.util.function.Consumer;
3638

3739
import static org.awaitility.Awaitility.await;
3840
import static org.hamcrest.Matchers.notNullValue;
@@ -80,15 +82,16 @@ public void shouldThrowExceptionWhenInsertWithTTL() {
8082

8183
@Test
8284
public void shouldThrowExceptionWhenInsertWithTTLWithCallback() {
83-
assertThrows(UnsupportedOperationException.class, () -> entityManager.insert(getEntity(), Duration.ofSeconds(10), r -> {}));
85+
assertThrows(UnsupportedOperationException.class, () -> entityManager.insert(getEntity(), Duration.ofSeconds(10), r -> {
86+
}));
8487
}
8588

8689
@Test
8790
public void shouldUpdateAsync() throws InterruptedException {
8891

8992
Random random = new Random();
9093
long id = random.nextLong();
91-
94+
9295
AtomicBoolean condition = new AtomicBoolean(false);
9396
AtomicReference<DocumentEntity> reference = new AtomicReference<>();
9497
DocumentEntity entity = getEntity();
@@ -192,6 +195,23 @@ public void shouldRemoveEntity() {
192195
entityManager.delete(deleteQuery);
193196
}
194197

198+
@Test
199+
public void shouldCount() throws InterruptedException {
200+
AtomicBoolean condition = new AtomicBoolean(false);
201+
AtomicLong value = new AtomicLong(0);
202+
DocumentEntity entity = getEntity();
203+
entityManager.insert(entity, c -> condition.set(true));
204+
await().untilTrue(condition);
205+
condition.set(false);
206+
Consumer<Long> callback = l -> {
207+
condition.set(true);
208+
value.set(l);
209+
};
210+
entityManager.count(COLLECTION_NAME, callback);
211+
await().untilTrue(condition);
212+
assertTrue(value.get() > 0);
213+
}
214+
195215
private DocumentEntity getEntity() {
196216
DocumentEntity entity = DocumentEntity.of(COLLECTION_NAME);
197217
Map<String, Object> map = new HashMap<>();

mongodb-driver/src/test/java/org/jnosql/diana/mongodb/document/MongoDBDocumentCollectionManagerTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ public void shouldRetrieveListSubdocumentList() {
404404
assertTrue(contacts.stream().allMatch(d -> d.size() == 3));
405405
}
406406

407+
@Test
408+
public void shouldCount() {
409+
DocumentEntity entity = entityManager.insert(getEntity());
410+
assertTrue(entityManager.count(COLLECTION_NAME) > 0);
411+
}
412+
407413
private DocumentEntity createSubdocumentList() {
408414
DocumentEntity entity = DocumentEntity.of("AppointmentBook");
409415
entity.add(Document.of("_id", new Random().nextInt()));

0 commit comments

Comments
 (0)