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);
}
Aggregations