Search in sources :

Example 1 with DefaultBridgedReactiveSession

use of org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession in project spring-data-cassandra by spring-projects.

the class ReactiveCassandraTemplateIntegrationTests method setUp.

@BeforeEach
void setUp() {
    MappingCassandraConverter converter = new MappingCassandraConverter();
    CassandraTemplate cassandraTemplate = new CassandraTemplate(this.session, converter);
    DefaultBridgedReactiveSession session = new DefaultBridgedReactiveSession(this.session);
    template = new ReactiveCassandraTemplate(new ReactiveCqlTemplate(session), converter);
    prepareTemplate(template);
    SchemaTestUtils.potentiallyCreateTableFor(User.class, cassandraTemplate);
    SchemaTestUtils.potentiallyCreateTableFor(UserToken.class, cassandraTemplate);
    SchemaTestUtils.truncate(User.class, cassandraTemplate);
    SchemaTestUtils.truncate(UserToken.class, cassandraTemplate);
}
Also used : DefaultBridgedReactiveSession(org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession) MappingCassandraConverter(org.springframework.data.cassandra.core.convert.MappingCassandraConverter) ReactiveCqlTemplate(org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with DefaultBridgedReactiveSession

use of org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession in project spring-data-cassandra by spring-projects.

the class ReactiveCassandraApplication method main.

public static void main(String[] args) {
    CqlSession cqlSession = CqlSession.builder().withKeyspace("mykeyspace").build();
    ReactiveCassandraOperations template = new ReactiveCassandraTemplate(new DefaultBridgedReactiveSession(cqlSession));
    Mono<Person> jonDoe = template.insert(newPerson("Jon Doe", 40));
    jonDoe.flatMap(it -> template.selectOne(Query.query(Criteria.where("id").is(it.getId())), Person.class)).doOnNext(it -> LOG.info(it.toString())).then(template.truncate(Person.class)).block();
    cqlSession.close();
}
Also used : DefaultBridgedReactiveSession(org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession) Criteria(org.springframework.data.cassandra.core.query.Criteria) CqlSession(com.datastax.oss.driver.api.core.CqlSession) ReactiveCassandraTemplate(org.springframework.data.cassandra.core.ReactiveCassandraTemplate) Mono(reactor.core.publisher.Mono) Log(org.apache.commons.logging.Log) UUID(java.util.UUID) LogFactory(org.apache.commons.logging.LogFactory) Query(org.springframework.data.cassandra.core.query.Query) ReactiveCassandraOperations(org.springframework.data.cassandra.core.ReactiveCassandraOperations) ReactiveCassandraOperations(org.springframework.data.cassandra.core.ReactiveCassandraOperations) CqlSession(com.datastax.oss.driver.api.core.CqlSession) ReactiveCassandraTemplate(org.springframework.data.cassandra.core.ReactiveCassandraTemplate) DefaultBridgedReactiveSession(org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession)

Example 3 with DefaultBridgedReactiveSession

use of org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession in project spring-data-cassandra by spring-projects.

the class ReactiveCqlTemplateIntegrationTests method before.

@BeforeEach
void before() {
    reactiveSession = new DefaultBridgedReactiveSession(getSession());
    if (initialized.compareAndSet(false, true)) {
        getSession().execute("CREATE TABLE IF NOT EXISTS user (id text PRIMARY KEY, username text);");
    }
    getSession().execute("TRUNCATE user;");
    getSession().execute("INSERT INTO user (id, username) VALUES ('WHITE', 'Walter');");
    template = new ReactiveCqlTemplate(new DefaultReactiveSessionFactory(reactiveSession));
    cassandraVersion = CassandraVersion.get(getSession());
}
Also used : DefaultReactiveSessionFactory(org.springframework.data.cassandra.core.cql.session.DefaultReactiveSessionFactory) DefaultBridgedReactiveSession(org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with DefaultBridgedReactiveSession

use of org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession in project spring-data-cassandra by spring-projects.

the class ReactiveCassandraBatchTemplateIntegrationTests method setUp.

@BeforeEach
void setUp() {
    MappingCassandraConverter converter = new MappingCassandraConverter();
    CassandraTemplate cassandraTemplate = new CassandraTemplate(this.session, converter);
    DefaultBridgedReactiveSession session = new DefaultBridgedReactiveSession(this.session);
    template = new ReactiveCassandraTemplate(new ReactiveCqlTemplate(session), converter);
    SchemaTestUtils.potentiallyCreateTableFor(Group.class, cassandraTemplate);
    SchemaTestUtils.potentiallyCreateTableFor(FlatGroup.class, cassandraTemplate);
    SchemaTestUtils.truncate(Group.class, cassandraTemplate);
    SchemaTestUtils.truncate(FlatGroup.class, cassandraTemplate);
    // 
    this.template.insert(walter).then(this.template.insert(mike)).as(// 
    StepVerifier::create).expectNextCount(// 
    1).verifyComplete();
}
Also used : StepVerifier(reactor.test.StepVerifier) DefaultBridgedReactiveSession(org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession) MappingCassandraConverter(org.springframework.data.cassandra.core.convert.MappingCassandraConverter) ReactiveCqlTemplate(org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with DefaultBridgedReactiveSession

use of org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession in project spring-data-cassandra by spring-projects.

the class ReactiveOptimisticLockingIntegrationTests method setUp.

@BeforeEach
void setUp() {
    MappingCassandraConverter converter = new MappingCassandraConverter();
    converter.afterPropertiesSet();
    template = new ReactiveCassandraTemplate(new DefaultBridgedReactiveSession(session), converter);
    CassandraTemplate syncTemplate = new CassandraTemplate(new CqlTemplate(session), converter);
    SchemaTestUtils.potentiallyCreateTableFor(VersionedEntity.class, syncTemplate);
    SchemaTestUtils.truncate(VersionedEntity.class, syncTemplate);
}
Also used : CqlTemplate(org.springframework.data.cassandra.core.cql.CqlTemplate) DefaultBridgedReactiveSession(org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession) MappingCassandraConverter(org.springframework.data.cassandra.core.convert.MappingCassandraConverter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DefaultBridgedReactiveSession (org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession)9 BeforeEach (org.junit.jupiter.api.BeforeEach)8 ReactiveCassandraTemplate (org.springframework.data.cassandra.core.ReactiveCassandraTemplate)3 MappingCassandraConverter (org.springframework.data.cassandra.core.convert.MappingCassandraConverter)3 ReactiveCqlTemplate (org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate)2 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 PreparedStatement (com.datastax.oss.driver.api.core.cql.PreparedStatement)1 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)1 Statement (com.datastax.oss.driver.api.core.cql.Statement)1 UUID (java.util.UUID)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 CassandraTemplate (org.springframework.data.cassandra.core.CassandraTemplate)1 ReactiveCassandraOperations (org.springframework.data.cassandra.core.ReactiveCassandraOperations)1 CqlTemplate (org.springframework.data.cassandra.core.cql.CqlTemplate)1 DefaultReactiveSessionFactory (org.springframework.data.cassandra.core.cql.session.DefaultReactiveSessionFactory)1 Criteria (org.springframework.data.cassandra.core.query.Criteria)1 Query (org.springframework.data.cassandra.core.query.Query)1 TypeWithMapId (org.springframework.data.cassandra.domain.TypeWithMapId)1 User (org.springframework.data.cassandra.domain.User)1