use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplateIntegrationTests method insertShouldCreateEntityWithLwt.
// DATACASS-250, DATACASS-573
@Test
void insertShouldCreateEntityWithLwt() {
InsertOptions lwtOptions = InsertOptions.builder().withIfNotExists().build();
User user = new User("heisenberg", "Walter", "White");
Mono<EntityWriteResult<User>> inserted = template.insert(user, lwtOptions);
inserted.as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual.wasApplied()).isTrue();
assertThat(actual.getEntity()).isSameAs(user);
}).verifyComplete();
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplateIntegrationTests method shouldInsertEntityAndCountByQuery.
// DATACASS-335
@Test
void shouldInsertEntityAndCountByQuery() {
User user = new User("heisenberg", "Walter", "White");
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
//
template.count(Query.query(where("id").is("heisenberg")), User.class).as(StepVerifier::create).expectNext(//
1L).verifyComplete();
//
template.count(Query.query(where("id").is("foo")), User.class).as(StepVerifier::create).expectNext(//
0L).verifyComplete();
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplateIntegrationTests method shouldInsertAndExistsByQueryEntities.
// DATACASS-335
@Test
void shouldInsertAndExistsByQueryEntities() {
User user = new User("heisenberg", "Walter", "White");
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
//
template.exists(Query.query(where("id").is("heisenberg")), User.class).as(StepVerifier::create).expectNext(//
true).verifyComplete();
//
template.exists(Query.query(where("id").is("foo")), User.class).as(StepVerifier::create).expectNext(//
false).verifyComplete();
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplateIntegrationTests method updateShouldUpdateEntity.
// DATACASS-335
@Test
void updateShouldUpdateEntity() {
User user = new User("heisenberg", "Walter", "White");
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
user.setFirstname("Walter Hartwell");
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
verifyUser(user.getId()).expectNext(user).verifyComplete();
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplateIntegrationTests method deleteShouldRemoveEntity.
// DATACASS-335
@Test
void deleteShouldRemoveEntity() {
User user = new User("heisenberg", "Walter", "White");
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
template.delete(user).as(StepVerifier::create).expectNext(user).verifyComplete();
verifyUser(user.getId()).verifyComplete();
}
Aggregations