Search in sources :

Example 1 with Result

use of com.datastax.oss.dsbulk.executor.api.result.Result in project dsbulk by datastax.

the class BulkExecutorITBase method verifyReads.

protected void verifyReads(int expectedSuccessful, int expectedFailed, Iterable<ReadResult> actual) {
    AtomicInteger i = new AtomicInteger();
    long actualSuccessful = Flux.fromIterable(actual).filter(Result::isSuccess).map(result -> result.getRow().orElseThrow(AssertionError::new)).map(row -> row.getInt("pk")).sort().doOnNext(pk -> {
        assertThat(pk).isEqualTo(i.get());
        i.getAndIncrement();
    }).count().blockOptional().orElse(0L);
    assertThat(actualSuccessful).isEqualTo(expectedSuccessful);
    long actualFailed = Flux.fromIterable(actual).filter(r -> !r.isSuccess()).doOnNext(r -> {
        assertThat(r.getRow().isPresent()).isFalse();
        assertThat(r.getError().isPresent()).isTrue();
        BulkExecutionException error = r.getError().get();
        verifyException(error);
    }).count().blockOptional().orElse(0L);
    assertThat(actualFailed).isEqualTo(expectedFailed);
}
Also used : SyntaxError(com.datastax.oss.driver.api.core.servererrors.SyntaxError) Strictness(org.mockito.quality.Strictness) ReadResult(com.datastax.oss.dsbulk.executor.api.result.ReadResult) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Result(com.datastax.oss.dsbulk.executor.api.result.Result) SimpleStatement(com.datastax.oss.driver.api.core.cql.SimpleStatement) ArgumentCaptor(org.mockito.ArgumentCaptor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) Flux(reactor.core.publisher.Flux) WriteResult(com.datastax.oss.dsbulk.executor.api.result.WriteResult) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) Assertions.fail(org.assertj.core.api.Assertions.fail) BulkExecutionException(com.datastax.oss.dsbulk.executor.api.exception.BulkExecutionException) Stream(java.util.stream.Stream) StreamSupport.stream(java.util.stream.StreamSupport.stream) MockitoSession(org.mockito.MockitoSession) Queue(java.util.Queue) Collections(java.util.Collections) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) BulkExecutionException(com.datastax.oss.dsbulk.executor.api.exception.BulkExecutionException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)1 SyntaxError (com.datastax.oss.driver.api.core.servererrors.SyntaxError)1 BulkExecutionException (com.datastax.oss.dsbulk.executor.api.exception.BulkExecutionException)1 ReadResult (com.datastax.oss.dsbulk.executor.api.result.ReadResult)1 Result (com.datastax.oss.dsbulk.executor.api.result.Result)1 WriteResult (com.datastax.oss.dsbulk.executor.api.result.WriteResult)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Queue (java.util.Queue)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 ExecutionException (java.util.concurrent.ExecutionException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Consumer (java.util.function.Consumer)1 Stream (java.util.stream.Stream)1 StreamSupport.stream (java.util.stream.StreamSupport.stream)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.fail (org.assertj.core.api.Assertions.fail)1 AfterEach (org.junit.jupiter.api.AfterEach)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1