use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.
the class SpannerRepositoryImplTests method countTest.
@Test
public void countTest() {
SpannerOperations operations = mock(SpannerOperations.class);
new SimpleSpannerRepository(operations, Object.class).count();
verify(operations, times(1)).count(eq(Object.class));
}
use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.
the class SpannerRepositoryImplTests method saveTest.
@Test
public void saveTest() {
SpannerOperations operations = mock(SpannerOperations.class);
Object ob = new Object();
assertEquals(ob, new SimpleSpannerRepository(operations, Object.class).save(ob));
verify(operations, times(1)).upsert(eq(ob));
}
use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.
the class SpannerRepositoryImplTests method saveAllTest.
@Test
public void saveAllTest() {
SpannerOperations operations = mock(SpannerOperations.class);
Object ob = new Object();
Object ob2 = new Object();
Iterable<Object> ret = new SimpleSpannerRepository(operations, Object.class).saveAll(Arrays.asList(ob, ob2));
assertThat(ret, containsInAnyOrder(ob, ob2));
verify(operations, times(1)).upsert(eq(ob));
verify(operations, times(1)).upsert(eq(ob2));
}
use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.
the class SpannerRepositoryImplTests method findByIdTest.
@Test
public void findByIdTest() {
SpannerOperations operations = mock(SpannerOperations.class);
Key key = Key.of("key");
Object ret = new Object();
when(operations.find(eq(Object.class), eq(key))).thenReturn(ret);
assertEquals(ret, new SimpleSpannerRepository(operations, Object.class).findById(key).get());
verify(operations, times(1)).find(eq(Object.class), eq(key));
}
use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.
the class SpannerRepositoryImplTests method deleteAllTest.
@Test
public void deleteAllTest() {
SpannerOperations operations = mock(SpannerOperations.class);
new SimpleSpannerRepository(operations, Object.class).deleteAll();
verify(operations, times(1)).delete(eq(Object.class), eq(KeySet.all()));
}
Aggregations