Skip to content

Commit 6653975

Browse files
committed
test: add tests for the count method with bson query filter
Signed-off-by: Maximillian Arruda <[email protected]>
1 parent 54762aa commit 6653975

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/mapping/DefaultMongoDBTemplateTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,33 @@ public void shouldAggregateWithEntity() {
192192
Mockito.verify(manager).aggregate("Person", predicates);
193193
}
194194

195+
@Test
196+
public void shouldCountByFilterWithCollectionName() {
197+
var filter = eq("name", "Poliana");
198+
199+
template.count("Person", filter);
200+
201+
Mockito.verify(manager).count("Person", filter);
202+
}
203+
204+
@Test
205+
public void shouldCountByFilterWithEntity() {
206+
var filter = eq("name", "Poliana");
207+
208+
template.count(Person.class, filter);
209+
210+
Mockito.verify(manager).count("Person", filter);
211+
}
212+
213+
@Test
214+
public void shouldReturnErrorOnCountByFilterMethod() {
215+
var filter = eq("name", "Poliana");
216+
assertThrows(NullPointerException.class, () -> template.count((String) null, null));
217+
assertThrows(NullPointerException.class, () -> template.count((String) null, filter));
218+
assertThrows(NullPointerException.class, () -> template.count("Person", null));
219+
assertThrows(NullPointerException.class, () -> template.count((Class<Person>) null, null));
220+
assertThrows(NullPointerException.class, () -> template.count((Class<Person>) null, filter));
221+
assertThrows(NullPointerException.class, () -> template.count(Person.class, null));
222+
}
223+
195224
}

0 commit comments

Comments
 (0)