use of org.springframework.cloud.gcp.data.spanner.test.domain.Trade in project spring-cloud-gcp by spring-cloud.
the class SpannerRepositoryIntegrationTests method queryOptionalSingleValueTest.
@Test
public void queryOptionalSingleValueTest() {
Trade trade = Trade.aTrade(null, 0);
this.spannerOperations.insert(trade);
Optional<String> nonEmpty = tradeRepository.fetchSymbolById(trade.getId());
assertThat(nonEmpty.isPresent()).isTrue();
assertThat(nonEmpty.get()).isEqualTo("ABCD");
Optional<String> empty = tradeRepository.fetchSymbolById(trade.getId() + "doesNotExist");
assertThat(empty.isPresent()).isFalse();
}
use of org.springframework.cloud.gcp.data.spanner.test.domain.Trade in project spring-cloud-gcp by spring-cloud.
the class SpannerRepositoryIntegrationTests method existsTest.
@Test
public void existsTest() {
Trade trade = Trade.aTrade();
this.tradeRepository.save(trade);
SpannerPersistentEntity<?> persistentEntity = this.spannerMappingContext.getPersistentEntity(Trade.class);
PersistentPropertyAccessor accessor = persistentEntity.getPropertyAccessor(trade);
PersistentProperty idProperty = persistentEntity.getIdProperty();
Key key = (Key) accessor.getProperty(idProperty);
assertThat(this.tradeRepository.existsById(key)).isTrue();
this.tradeRepository.delete(trade);
assertThat(this.tradeRepository.existsById(key)).isFalse();
}
Aggregations