use of org.springframework.cloud.gcp.data.spanner.core.mapping.event.AfterDeleteEvent in project spring-cloud-gcp by spring-cloud.
the class SpannerTemplateTests method deleteKeysTest.
@Test
public void deleteKeysTest() {
KeySet keys = KeySet.newBuilder().addKey(Key.of("key1")).addKey(Key.of("key2")).build();
Mutation mutation = Mutation.delete("custom_test_table", keys);
List<Mutation> mutations = Collections.singletonList(mutation);
when(this.mutationFactory.delete(eq(TestEntity.class), same(keys))).thenReturn(mutation);
verifyBeforeAndAfterEvents(new BeforeDeleteEvent(mutations, null, keys, TestEntity.class), new AfterDeleteEvent(mutations, null, keys, TestEntity.class), () -> this.spannerTemplate.delete(TestEntity.class, keys), x -> x.verify(this.databaseClient, times(1)).write(eq(Collections.singletonList(mutation))));
}
Aggregations