use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class AsyncCassandraTemplateIntegrationTests method shouldInsertEntityAndExistsByQuery.
// DATACASS-512
@Test
void shouldInsertEntityAndExistsByQuery() {
User user = new User("heisenberg", "Walter", "White");
getUninterruptibly(template.insert(user));
assertThat(getUninterruptibly(template.exists(Query.query(where("id").is("heisenberg")), User.class))).isTrue();
assertThat(getUninterruptibly(template.exists(Query.query(where("id").is("foo")), User.class))).isFalse();
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class CassandraTemplateIntegrationTests method updateShouldRemoveFields.
// DATACASS-182
@Test
void updateShouldRemoveFields() {
User user = new User("heisenberg", "Walter", "White");
template.insert(user);
user.setFirstname(null);
template.update(user);
User loaded = template.selectOneById(user.getId(), User.class);
assertThat(loaded.getFirstname()).isNull();
assertThat(loaded.getId()).isEqualTo("heisenberg");
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class CassandraTemplateIntegrationTests method stream.
// DATACASS-182
@Test
void stream() {
User user = new User("heisenberg", "Walter", "White");
template.insert(user);
Stream<User> stream = template.stream("SELECT * FROM users", User.class);
assertThat(stream.collect(Collectors.toList())).hasSize(1).contains(user);
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class CassandraTemplateIntegrationTests method updateShouldUpdateEntityWithLwt.
// DATACASS-292
@Test
void updateShouldUpdateEntityWithLwt() {
UpdateOptions lwtOptions = UpdateOptions.builder().withIfExists().build();
User user = new User("heisenberg", "Walter", "White");
template.insert(user);
user.setFirstname("Walter Hartwell");
WriteResult lwt = template.update(user, lwtOptions);
assertThat(lwt.wasApplied()).isTrue();
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class CassandraTemplateIntegrationTests method insertShouldNotUpdateEntityWithLwt.
// DATACASS-250, DATACASS-573
@Test
void insertShouldNotUpdateEntityWithLwt() {
InsertOptions lwtOptions = InsertOptions.builder().withIfNotExists().build();
User user = new User("heisenberg", "Walter", "White");
template.insert(user, lwtOptions);
user.setFirstname("Walter Hartwell");
EntityWriteResult<User> lwt = template.insert(user, lwtOptions);
assertThat(lwt.wasApplied()).isFalse();
assertThat(template.selectOneById(user.getId(), User.class).getFirstname()).isEqualTo("Walter");
}
Aggregations