Skip to content

Commit 99ddd0c

Browse files
committed
DATACASS-587 - Adapt tests to AssertJ changes.
Update stubbing to call interface default methods for a mocked ResultSet to allow spliterator()/Stream usage.
1 parent 8055890 commit 99ddd0c

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/AsyncCqlTemplateUnitTests.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,7 @@
4343
import org.springframework.scheduling.annotation.AsyncResult;
4444
import org.springframework.util.concurrent.ListenableFuture;
4545

46-
import com.datastax.driver.core.BoundStatement;
47-
import com.datastax.driver.core.ColumnDefinitions;
48-
import com.datastax.driver.core.ConsistencyLevel;
49-
import com.datastax.driver.core.PreparedStatement;
50-
import com.datastax.driver.core.ResultSet;
51-
import com.datastax.driver.core.ResultSetFuture;
52-
import com.datastax.driver.core.Row;
53-
import com.datastax.driver.core.Session;
54-
import com.datastax.driver.core.SimpleStatement;
55-
import com.datastax.driver.core.Statement;
46+
import com.datastax.driver.core.*;
5647
import com.datastax.driver.core.exceptions.InvalidQueryException;
5748
import com.datastax.driver.core.exceptions.NoHostAvailableException;
5849
import com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy;
@@ -578,6 +569,7 @@ public void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
578569

579570
when(session.executeAsync(boundStatement)).thenReturn(new TestResultSetFuture(resultSet));
580571
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
572+
when(resultSet.spliterator()).thenCallRealMethod();
581573

582574
ListenableFuture<ResultSet> future = template
583575
.query(session -> new AsyncResult<PreparedStatement>(preparedStatement), ps -> {
@@ -773,6 +765,7 @@ private <T> void doTestStrings(Integer fetchSize, ConsistencyLevel consistencyLe
773765

774766
when(this.session.executeAsync((Statement) any())).thenReturn(new TestResultSetFuture(resultSet));
775767
when(this.resultSet.iterator()).thenReturn(Arrays.asList(row, row, row).iterator());
768+
when(this.resultSet.spliterator()).thenCallRealMethod();
776769

777770
when(this.row.getString(0)).thenReturn(results[0], results[1], results[2]);
778771

spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/CqlTemplateUnitTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ public void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
513513

514514
when(session.execute(boundStatement)).thenReturn(resultSet);
515515
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
516+
when(resultSet.spliterator()).thenCallRealMethod();
516517

517518
ResultSet resultSet = template.query(session -> preparedStatement, ps -> {
518519
ps.bind("a", "b");
@@ -684,6 +685,7 @@ private <T> void doTestStrings(Integer fetchSize, ConsistencyLevel consistencyLe
684685

685686
when(this.session.execute((Statement) any())).thenReturn(resultSet);
686687
when(this.resultSet.iterator()).thenReturn(Arrays.asList(row, row, row).iterator());
688+
when(this.resultSet.spliterator()).thenCallRealMethod();
687689

688690
when(this.row.getString(0)).thenReturn(results[0], results[1], results[2]);
689691
when(this.session.prepare(anyString())).thenReturn(preparedStatement);

0 commit comments

Comments
 (0)