use of com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow in project java-driver by datastax.
the class DefaultReactiveResultSetIT method should_write_batch_cas.
@Test
public void should_write_batch_cas() {
BatchStatement batch = createCASBatch();
CqlSession session = sessionRule.session();
// execute batch for the first time: all inserts should succeed and the server should return
// only one acknowledgement row with just the [applied] column = true
ReactiveResultSet rs = session.executeReactive(batch);
List<ReactiveRow> results = Flowable.fromPublisher(rs).toList().blockingGet();
assertThat(results).hasSize(1);
ReactiveRow row = results.get(0);
assertThat(row.getExecutionInfo()).isNotNull();
assertThat(row.getColumnDefinitions()).hasSize(1);
assertThat(row.wasApplied()).isTrue();
assertThat(row.getBoolean("[applied]")).isTrue();
List<ExecutionInfo> execInfos = Flowable.<ExecutionInfo>fromPublisher(rs.getExecutionInfos()).toList().blockingGet();
assertThat(execInfos).hasSize(1).containsExactly(row.getExecutionInfo());
List<ColumnDefinitions> colDefs = Flowable.<ColumnDefinitions>fromPublisher(rs.getColumnDefinitions()).toList().blockingGet();
assertThat(colDefs).hasSize(1).containsExactly(row.getColumnDefinitions());
List<Boolean> wasApplied = Flowable.fromPublisher(rs.wasApplied()).toList().blockingGet();
assertThat(wasApplied).hasSize(1).containsExactly(row.wasApplied());
// delete 5 out of 10 rows
partiallyDeleteInsertedRows();
// re-execute same statement: server should return 5 rows for the 5 failed inserts, each one
// with [applied] = false
rs = session.executeReactive(batch);
results = Flowable.fromPublisher(rs).toList().blockingGet();
assertThat(results).hasSize(5);
for (int i = 0; i < 5; i++) {
row = results.get(i);
assertThat(row.getExecutionInfo()).isNotNull();
assertThat(row.getColumnDefinitions()).hasSize(4);
assertThat(row.wasApplied()).isFalse();
assertThat(row.getBoolean("[applied]")).isFalse();
assertThat(row.getInt("pk")).isEqualTo(0);
assertThat(row.getInt("cc")).isEqualTo(i);
assertThat(row.getInt("v")).isEqualTo(i + 1);
}
execInfos = Flowable.<ExecutionInfo>fromPublisher(rs.getExecutionInfos()).toList().blockingGet();
assertThat(execInfos).hasSize(1).containsExactly(row.getExecutionInfo());
colDefs = Flowable.<ColumnDefinitions>fromPublisher(rs.getColumnDefinitions()).toList().blockingGet();
assertThat(colDefs).hasSize(1).containsExactly(row.getColumnDefinitions());
wasApplied = Flowable.fromPublisher(rs.wasApplied()).toList().blockingGet();
assertThat(wasApplied).hasSize(1).containsExactly(row.wasApplied());
}
use of com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow in project java-driver by datastax.
the class DriverBlockHoundIntegrationIT method should_not_detect_blocking_call_on_asynchronous_execution.
@Test
public void should_not_detect_blocking_call_on_asynchronous_execution() {
try (CqlSession session = SessionUtils.newSession(SIMULACRON_RULE)) {
Flux<ReactiveRow> rows = Flux.range(0, 1000).flatMap(i -> Flux.from(session.executeReactive("SELECT c1, c2 FROM ks.t1")).subscribeOn(Schedulers.parallel()));
StepVerifier.create(rows).expectNextCount(1000).expectComplete().verify();
}
}
Aggregations