Search in sources :

Example 1 with MockAsyncResultSet

use of com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet in project dsbulk by datastax.

the class ReadResultPublisherTest method mockPage.

private static CompletionStage<AsyncResultSet> mockPage(CompletionStage<AsyncResultSet> previous, int size) {
    CompletableFuture<AsyncResultSet> future = new CompletableFuture<>();
    ExecutionInfo executionInfo = mock(ExecutionInfo.class);
    when(executionInfo.getPagingState()).thenReturn(previous == null ? null : ByteBuffer.wrap(new byte[] { 1 }));
    future.complete(new MockAsyncResultSet(size, executionInfo, previous));
    previous = future;
    return previous;
}
Also used : MockAsyncResultSet(com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet) CompletableFuture(java.util.concurrent.CompletableFuture) MockAsyncResultSet(com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet) AsyncResultSet(com.datastax.oss.driver.api.core.cql.AsyncResultSet) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo)

Example 2 with MockAsyncResultSet

use of com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet in project dsbulk by datastax.

the class WriteResultPublisherTest method setUpSession.

private static CqlSession setUpSession() {
    CqlSession session = mock(CqlSession.class);
    CompletableFuture<AsyncResultSet> future = new CompletableFuture<>();
    ExecutionInfo executionInfo = mock(ExecutionInfo.class);
    future.complete(new MockAsyncResultSet(0, executionInfo, null));
    when(session.executeAsync(any(SimpleStatement.class))).thenReturn(future);
    return session;
}
Also used : MockAsyncResultSet(com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet) CompletableFuture(java.util.concurrent.CompletableFuture) MockAsyncResultSet(com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet) AsyncResultSet(com.datastax.oss.driver.api.core.cql.AsyncResultSet) SimpleStatement(com.datastax.oss.driver.api.core.cql.SimpleStatement) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo) CqlSession(com.datastax.oss.driver.api.core.CqlSession)

Aggregations

AsyncResultSet (com.datastax.oss.driver.api.core.cql.AsyncResultSet)2 ExecutionInfo (com.datastax.oss.driver.api.core.cql.ExecutionInfo)2 MockAsyncResultSet (com.datastax.oss.dsbulk.tests.driver.MockAsyncResultSet)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)1