Skip to content

Commit 7b58eb0

Browse files
committed
test: enhance count query tests for CassandraColumnManager
Improved the count query tests by adding assertions to check for NullPointerExceptions when passing null arguments, ensuring robustness and correctness of the count method implementation. Signed-off-by: Maximillian Arruda <[email protected]>
1 parent e8a23a0 commit 7b58eb0

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

jnosql-cassandra/src/test/java/org/eclipse/jnosql/databases/cassandra/communication/CassandraColumnManagerTest.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import static java.util.Collections.singletonMap;
4949
import static java.util.stream.Collectors.toList;
5050
import static org.assertj.core.api.Assertions.assertThat;
51+
import static org.assertj.core.api.SoftAssertions.assertSoftly;
5152
import static org.eclipse.jnosql.communication.driver.IntegrationTest.MATCHES;
5253
import static org.eclipse.jnosql.communication.driver.IntegrationTest.NAMED;
5354
import static org.eclipse.jnosql.communication.semistructured.DeleteQuery.delete;
@@ -455,11 +456,29 @@ void shouldCount() {
455456
void shouldCountBySelectQuery() {
456457
entityManager.insert(getColumnFamily());
457458
var query = select().from(Constants.COLUMN_FAMILY).where("id").eq(10L).build();
458-
assertThat(entityManager.count(query))
459-
.isEqualTo(1);
459+
assertSoftly(softly -> {
460+
461+
softly.assertThat(entityManager.count(query))
462+
.as("the implementation is returning an non expected value")
463+
.isEqualTo(1);
464+
465+
softly.assertThatThrownBy(() -> entityManager.count(query, null))
466+
.as("must throw NPE when call the count method passing null arguments")
467+
.isInstanceOf(NullPointerException.class);
468+
469+
softly.assertThatThrownBy(() -> entityManager.count(null, null))
470+
.as("must throw NPE when call the count method passing null arguments")
471+
.isInstanceOf(NullPointerException.class);
472+
473+
softly.assertThatThrownBy(() -> entityManager.count((SelectQuery) null))
474+
.as("must throw NPE when call the count method passing null arguments")
475+
.isInstanceOf(NullPointerException.class);
476+
477+
});
478+
460479
}
461480

462-
@Test
481+
@Test
463482
void shouldPagingState() {
464483
for (long index = 1; index <= 10; index++) {
465484
var columnFamily = getColumnFamily();
@@ -509,7 +528,7 @@ void shouldInsertNullValues(){
509528
family.add(Element.of("name", null));
510529
var columnEntity = entityManager.insert(family);
511530
var column = columnEntity.find("name");
512-
SoftAssertions.assertSoftly(soft -> {
531+
assertSoftly(soft -> {
513532
soft.assertThat(column).get().extracting(Element::name).isEqualTo("name");
514533
soft.assertThat(column).get().extracting(Element::get).isNull();
515534
});
@@ -522,7 +541,7 @@ void shouldUpdateNullValues(){
522541
family.addNull("name");
523542
var columnEntity = entityManager.update(family);
524543
var column = columnEntity.find("name");
525-
SoftAssertions.assertSoftly(soft -> {
544+
assertSoftly(soft -> {
526545
soft.assertThat(column).get().extracting(Element::name).isEqualTo("name");
527546
soft.assertThat(column).get().extracting(Element::get).isNull();
528547
});

0 commit comments

Comments
 (0)