Search in sources :

Example 6 with ReactiveResultSet

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();
}
Also used : ReactiveResultSet(com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet) MappedReactiveResultSet(com.datastax.dse.driver.api.mapper.reactive.MappedReactiveResultSet) ReactiveRow(com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow) UUID(java.util.UUID) Test(org.junit.Test)

Example 7 with ReactiveResultSet

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();
}
Also used : ReactiveResultSet(com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet) MappedReactiveResultSet(com.datastax.dse.driver.api.mapper.reactive.MappedReactiveResultSet) ReactiveRow(com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow) UUID(java.util.UUID) Test(org.junit.Test)

Example 8 with ReactiveResultSet

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();
    }
}
Also used : ReactiveResultSet(com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet) MappedReactiveResultSet(com.datastax.dse.driver.api.mapper.reactive.MappedReactiveResultSet) ReactiveRow(com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow) UUID(java.util.UUID) Test(org.junit.Test)

Example 9 with ReactiveResultSet

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);
}
Also used : ReactiveResultSet(com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet) MappedReactiveResultSet(com.datastax.dse.driver.api.mapper.reactive.MappedReactiveResultSet) Test(org.junit.Test)

Example 10 with ReactiveResultSet

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();
}
Also used : ReactiveResultSet(com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet) MappedReactiveResultSet(com.datastax.dse.driver.api.mapper.reactive.MappedReactiveResultSet) ReactiveRow(com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow) Test(org.junit.Test)

Aggregations

ReactiveResultSet (com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet)15 Test (org.junit.Test)15 ReactiveRow (com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow)13 MappedReactiveResultSet (com.datastax.dse.driver.api.mapper.reactive.MappedReactiveResultSet)9 ColumnDefinitions (com.datastax.oss.driver.api.core.cql.ColumnDefinitions)6 ExecutionInfo (com.datastax.oss.driver.api.core.cql.ExecutionInfo)6 UUID (java.util.UUID)5 EmptyColumnDefinitions (com.datastax.oss.driver.internal.core.cql.EmptyColumnDefinitions)4 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)3 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)2 CqlRequestAsyncProcessor (com.datastax.oss.driver.internal.core.cql.CqlRequestAsyncProcessor)2 RequestHandlerTestHarness (com.datastax.oss.driver.internal.core.cql.RequestHandlerTestHarness)2 DefaultSession (com.datastax.oss.driver.internal.core.session.DefaultSession)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)1 AsyncResultSet (com.datastax.oss.driver.api.core.cql.AsyncResultSet)1 BatchStatement (com.datastax.oss.driver.api.core.cql.BatchStatement)1 Statement (com.datastax.oss.driver.api.core.cql.Statement)1 PoolBehavior (com.datastax.oss.driver.internal.core.cql.PoolBehavior)1