use of org.springframework.cloud.gcp.data.spanner.test.domain.CommitTimestamps in project spring-cloud-gcp by spring-cloud.
the class CommitTimestampIntegrationTests method testCommitTimestamp.
@Test
public void testCommitTimestamp() {
final CommitTimestamps entity = new CommitTimestamps();
final String id = UUID.randomUUID().toString();
entity.id = id;
doWithFields(CommitTimestamps.class, f -> setField(f, entity, CommitTimestamp.of(f.getType())), ff -> !ff.isSynthetic() && Objects.isNull(ff.getAnnotation(PrimaryKey.class)));
final Timestamp committedAt = databaseClient.write(mutationFactory.insert(entity));
final CommitTimestamps fetched = spannerOperations.read(CommitTimestamps.class, Key.of(id));
doWithFields(CommitTimestamps.class, f -> assertThat(getField(f, fetched)).describedAs("Test of the field %s has tailed", f).isEqualTo(getConverter(f).convert(committedAt)), ff -> !ff.isSynthetic() && isNull(ff.getAnnotation(PrimaryKey.class)));
}
use of org.springframework.cloud.gcp.data.spanner.test.domain.CommitTimestamps in project spring-cloud-gcp by spring-cloud.
the class ConverterAwareMappingSpannerEntityWriterTests method testCommitTimestampsType.
@Test
public void testCommitTimestampsType() {
CommitTimestamps entity = new CommitTimestamps();
doWithFields(CommitTimestamps.class, f -> setField(f, entity, CommitTimestamp.of(f.getType())), ff -> !ff.isSynthetic() && Objects.isNull(ff.getAnnotation(PrimaryKey.class)));
WriteBuilder writeBuilder = Mutation.newInsertBuilder("commit_timestamps_table");
this.spannerEntityWriter.write(entity, writeBuilder::set);
Mutation mutation = writeBuilder.build();
assertThat(mutation.asMap().entrySet().stream().filter(e -> !"id".equals(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList())).allMatch(Value::isCommitTimestamp);
}
Aggregations