use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class CassandraTemplateUnitTests method insertShouldInsertWithOptionsEntity.
// DATACASS-250
@Test
void insertShouldInsertWithOptionsEntity() {
InsertOptions insertOptions = InsertOptions.builder().withIfNotExists().build();
when(resultSet.wasApplied()).thenReturn(true);
User user = new User("heisenberg", "Walter", "White");
template.insert(user, insertOptions);
verify(session).execute(statementCaptor.capture());
assertThat(render(statementCaptor.getValue())).isEqualTo("INSERT INTO users (firstname,id,lastname) VALUES ('Walter','heisenberg','White') IF NOT EXISTS");
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class AsyncCassandraTemplateUnitTests method selectUsingCqlShouldReturnMappedResults.
// DATACASS-292
@Test
void selectUsingCqlShouldReturnMappedResults() {
when(resultSet.currentPage()).thenReturn(Collections.singleton(row));
when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true);
when(columnDefinitions.get(anyInt())).thenReturn(columnDefinition);
when(columnDefinitions.firstIndexOf("id")).thenReturn(0);
when(columnDefinitions.firstIndexOf("firstname")).thenReturn(1);
when(columnDefinitions.firstIndexOf("lastname")).thenReturn(2);
when(columnDefinition.getType()).thenReturn(DataTypes.TEXT);
when(row.getObject(0)).thenReturn("myid");
when(row.getObject(1)).thenReturn("Walter");
when(row.getObject(2)).thenReturn("White");
ListenableFuture<List<User>> list = template.select("SELECT * FROM users", User.class);
assertThat(getUninterruptibly(list)).hasSize(1).contains(new User("myid", "Walter", "White"));
verify(session).executeAsync(statementCaptor.capture());
assertThat(render(statementCaptor.getValue())).isEqualTo("SELECT * FROM users");
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class ConvertingReactiveCassandraRepositoryTests method setUp.
@BeforeEach
void setUp() throws Exception {
TableMetadata users = session.getKeyspace().flatMap(it -> session.getMetadata().getKeyspace(it)).flatMap(it -> it.getTable(CqlIdentifier.fromCql("users"))).get();
if (users.getIndexes().containsKey(CqlIdentifier.fromCql("IX_lastname"))) {
session.execute("CREATE INDEX IX_lastname ON users (lastname);");
Thread.sleep(500);
}
reactiveRepository.deleteAll().as(StepVerifier::create).verifyComplete();
dave = new User("42", "Dave", "Matthews");
oliver = new User("4", "Oliver August", "Matthews");
carter = new User("49", "Carter", "Beauford");
boyd = new User("45", "Boyd", "Tinsley");
reactiveRepository.saveAll(Arrays.asList(oliver, dave, carter, boyd)).as(StepVerifier::create).expectNextCount(4).verifyComplete();
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class SimpleReactiveCassandraRepositoryIntegrationTests method insertShouldDeferredWrite.
// DATACASS-335
@Test
void insertShouldDeferredWrite() {
User person = new User("36", "Homer", "Simpson");
repository.insert(person);
repository.findAll().as(StepVerifier::create).expectNextCount(0L).verifyComplete();
}
use of org.springframework.data.cassandra.domain.User in project spring-data-cassandra by spring-projects.
the class SimpleCassandraRepositoryIntegrationTests method insertEntityShouldInsertEntity.
// DATACASS-415
@Test
void insertEntityShouldInsertEntity() {
repository.deleteAll();
User User = new User("36", "Homer", "Simpson");
repository.insert(User);
assertThat(repository.count()).isEqualTo(1);
}
Aggregations