use of com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet in project java-driver by datastax.
the class DeleteReactiveIT method should_delete_entity_reactive.
@Test
public void should_delete_entity_reactive() {
UUID id = FLAMETHROWER.getId();
assertThat(Flowable.fromPublisher(dao.findByIdReactive(id)).blockingSingle()).isNotNull();
ReactiveResultSet rs = dao.deleteEntityReactive(FLAMETHROWER);
ReactiveRow row = Flowable.fromPublisher(rs).singleElement().blockingGet();
assertThat(row).isNull();
assertThat(Flowable.fromPublisher(dao.findByIdReactive(id)).singleElement().blockingGet()).isNull();
}
use of com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet in project java-driver by datastax.
the class DeleteReactiveIT method should_delete_with_condition_reactive.
@Test
public void should_delete_with_condition_reactive() {
UUID id = FLAMETHROWER.getId();
assertThat(Flowable.fromPublisher(dao.findByIdReactive(id)).blockingSingle()).isNotNull();
{
ReactiveResultSet rs = dao.deleteIfDescriptionMatchesReactive(id, "foo");
ReactiveRow row = Flowable.fromPublisher(rs).blockingSingle();
assertThat(row.wasApplied()).isFalse();
assertThat(Flowable.fromPublisher(rs.wasApplied()).blockingSingle()).isFalse();
assertThat(row.getString("description")).isEqualTo(FLAMETHROWER.getDescription());
}
{
ReactiveResultSet rs = dao.deleteIfDescriptionMatchesReactive(id, FLAMETHROWER.getDescription());
ReactiveRow row = Flowable.fromPublisher(rs).blockingSingle();
assertThat(row.wasApplied()).isTrue();
assertThat(Flowable.fromPublisher(rs.wasApplied()).blockingSingle()).isTrue();
}
assertThat(Flowable.fromPublisher(dao.findByIdReactive(id)).singleElement().blockingGet()).isNull();
}
use of com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet in project java-driver by datastax.
the class InsertReactiveIT method should_insert_entity_if_not_exists_reactive.
@Test
public void should_insert_entity_if_not_exists_reactive() {
UUID id = FLAMETHROWER.getId();
assertThat(Flowable.fromPublisher(dao.findByIdReactive(id)).singleElement().blockingGet()).isNull();
{
ReactiveResultSet rs = dao.saveIfNotExistsReactive(FLAMETHROWER);
ReactiveRow row = Flowable.fromPublisher(rs).blockingSingle();
assertThat(row.wasApplied()).isTrue();
assertThat(Flowable.fromPublisher(rs.wasApplied()).blockingSingle()).isTrue();
}
assertThat(Flowable.fromPublisher(dao.findByIdReactive(id)).blockingSingle()).isNotNull().isEqualTo(FLAMETHROWER);
{
ReactiveResultSet rs = dao.saveIfNotExistsReactive(FLAMETHROWER);
ReactiveRow row = Flowable.fromPublisher(rs).singleElement().blockingGet();
assertThat(row.wasApplied()).isFalse();
assertThat(Flowable.fromPublisher(rs.wasApplied()).blockingSingle()).isFalse();
}
}
use of com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet in project java-driver by datastax.
the class QueryReactiveIT method should_query_reactive.
@Test
public void should_query_reactive() {
ReactiveResultSet rs = dao.findByIdReactive(1);
assertThat(Flowable.fromPublisher(rs).count().blockingGet()).isEqualTo(10);
}
use of com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet in project java-driver by datastax.
the class UpdateReactiveIT method should_not_update_entity_if_condition_is_not_met_reactive.
@Test
public void should_not_update_entity_if_condition_is_not_met_reactive() {
Flowable.fromPublisher(dao.updateReactive(new Product(FLAMETHROWER.getId(), "Description for length 10", new Dimensions(10, 1, 1)))).blockingSubscribe();
assertThat(Flowable.fromPublisher(dao.findByIdReactive(FLAMETHROWER.getId())).blockingSingle()).isNotNull().extracting("description").isEqualTo("Description for length 10");
ReactiveResultSet rs = dao.updateIfLengthReactive(new Product(FLAMETHROWER.getId(), "Other description", new Dimensions(1, 1, 1)), 20);
ReactiveRow row = Flowable.fromPublisher(rs).blockingSingle();
assertThat(row.wasApplied()).isFalse();
assertThat(row.getColumnDefinitions().contains("dimensions")).isTrue();
assertThat(Single.fromPublisher(rs.getColumnDefinitions()).blockingGet().contains("dimensions")).isTrue();
assertThat(Single.fromPublisher(rs.wasApplied()).blockingGet()).isFalse();
}
Aggregations