Skip to content

Commit 8e423d5

Browse files
committed
feat: add count test with SelectQuery
Implemented a test to verify the count functionality using SelectQuery, ensuring correct behavior and handling of null queries. Signed-off-by: Maximillian Arruda <[email protected]>
1 parent 8044995 commit 8e423d5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

jnosql-neo4j/src/test/java/org/eclipse/jnosql/databases/neo4j/communication/Neo4JDatabaseManagerTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.eclipse.jnosql.communication.semistructured.CriteriaCondition;
2323
import org.eclipse.jnosql.communication.semistructured.Element;
2424
import org.eclipse.jnosql.communication.semistructured.Elements;
25+
import org.eclipse.jnosql.communication.semistructured.SelectQuery;
2526
import org.eclipse.jnosql.mapping.semistructured.MappingQuery;
2627
import org.junit.jupiter.api.BeforeAll;
2728
import org.junit.jupiter.api.BeforeEach;
@@ -83,6 +84,24 @@ void shouldCount() {
8384
assertTrue(count > 0);
8485
}
8586

87+
@Test
88+
void shouldCountWithSelectQuery() {
89+
for (int index = 0; index < 10; index++) {
90+
var entity = getEntity();
91+
entity.add("index", index);
92+
entityManager.insert(entity);
93+
}
94+
var index = 4;
95+
var query = select().from(COLLECTION_NAME).where("index").gt(index).build();
96+
SoftAssertions.assertSoftly(softly -> {
97+
softly.assertThat(entityManager.count(query)).isEqualTo(5);
98+
99+
softly.assertThatThrownBy(() -> entityManager.count((SelectQuery) null))
100+
.as("Should not accept null SelectQuery")
101+
.isInstanceOf(NullPointerException.class);
102+
});
103+
}
104+
86105
@Test
87106
void shouldUpdate() {
88107
var entity = getEntity();

0 commit comments

Comments
 (0)