use of org.springframework.data.cassandra.domain.VersionedUser in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplateUnitTests method updateShouldUpdateVersionedEntity.
// DATACASS-618
@Test
void updateShouldUpdateVersionedEntity() {
when(reactiveResultSet.wasApplied()).thenReturn(true);
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
VersionedUser user = new VersionedUser("heisenberg", "Walter", "White");
user.setVersion(0L);
StepVerifier.create(template.update(user)).expectNext(user).verifyComplete();
verify(session).execute(statementCaptor.capture());
assertThat(render(statementCaptor.getValue())).isEqualTo("UPDATE vusers SET firstname='Walter', lastname='White', version=1 WHERE id='heisenberg' IF version=0");
assertThat(beforeConvert).isSameAs(user);
assertThat(beforeSave).isSameAs(user);
}
use of org.springframework.data.cassandra.domain.VersionedUser in project spring-data-cassandra by spring-projects.
the class AsyncCassandraTemplateUnitTests method insertShouldInsertVersionedEntity.
// DATACASS-618
@Test
void insertShouldInsertVersionedEntity() {
when(resultSet.wasApplied()).thenReturn(true);
VersionedUser user = new VersionedUser("heisenberg", "Walter", "White");
ListenableFuture<VersionedUser> future = template.insert(user);
assertThat(getUninterruptibly(future)).isEqualTo(user);
verify(session).executeAsync(statementCaptor.capture());
assertThat(render(statementCaptor.getValue())).isEqualTo("INSERT INTO vusers (firstname,id,lastname,version) VALUES ('Walter','heisenberg','White',0) IF NOT EXISTS");
assertThat(beforeConvert).isSameAs(user);
assertThat(beforeSave).isSameAs(user);
}
use of org.springframework.data.cassandra.domain.VersionedUser in project spring-data-cassandra by spring-projects.
the class CassandraTemplateUnitTests method updateShouldUpdateVersionedEntity.
// DATACASS-618
@Test
void updateShouldUpdateVersionedEntity() {
when(resultSet.wasApplied()).thenReturn(true);
VersionedUser user = new VersionedUser("heisenberg", "Walter", "White");
user.setVersion(0L);
template.update(user);
verify(session).execute(statementCaptor.capture());
assertThat(render(statementCaptor.getValue())).isEqualTo("UPDATE vusers SET firstname='Walter', lastname='White', version=1 WHERE id='heisenberg' IF version=0");
assertThat(beforeConvert).isSameAs(user);
assertThat(beforeSave).isSameAs(user);
}
use of org.springframework.data.cassandra.domain.VersionedUser in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplateUnitTests method insertShouldInsertVersionedEntity.
// DATACASS-618
@Test
void insertShouldInsertVersionedEntity() {
when(reactiveResultSet.wasApplied()).thenReturn(true);
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
VersionedUser user = new VersionedUser("heisenberg", "Walter", "White");
StepVerifier.create(template.insert(user)).expectNext(user).verifyComplete();
verify(session).execute(statementCaptor.capture());
assertThat(render(statementCaptor.getValue())).isEqualTo("INSERT INTO vusers (firstname,id,lastname,version) VALUES ('Walter','heisenberg','White',0) IF NOT EXISTS");
assertThat(beforeConvert).isSameAs(user);
assertThat(beforeSave).isSameAs(user);
}
use of org.springframework.data.cassandra.domain.VersionedUser in project spring-data-cassandra by spring-projects.
the class CassandraTemplateUnitTests method insertShouldInsertVersionedEntity.
// DATACASS-618
@Test
void insertShouldInsertVersionedEntity() {
when(resultSet.wasApplied()).thenReturn(true);
VersionedUser user = new VersionedUser("heisenberg", "Walter", "White");
template.insert(user);
verify(session).execute(statementCaptor.capture());
assertThat(render(statementCaptor.getValue())).isEqualTo("INSERT INTO vusers (firstname,id,lastname,version) VALUES ('Walter','heisenberg','White',0) IF NOT EXISTS");
assertThat(beforeConvert).isSameAs(user);
assertThat(beforeSave).isSameAs(user);
}
Aggregations