Search in sources :

Example 6 with SpannerOperations

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));
}
Also used : SpannerOperations(org.springframework.cloud.gcp.data.spanner.core.SpannerOperations) Test(org.junit.Test)

Example 7 with SpannerOperations

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));
}
Also used : SpannerOperations(org.springframework.cloud.gcp.data.spanner.core.SpannerOperations) Test(org.junit.Test)

Example 8 with SpannerOperations

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));
}
Also used : SpannerOperations(org.springframework.cloud.gcp.data.spanner.core.SpannerOperations) Test(org.junit.Test)

Example 9 with SpannerOperations

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));
}
Also used : SpannerOperations(org.springframework.cloud.gcp.data.spanner.core.SpannerOperations) Key(com.google.cloud.spanner.Key) Test(org.junit.Test)

Example 10 with SpannerOperations

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()));
}
Also used : SpannerOperations(org.springframework.cloud.gcp.data.spanner.core.SpannerOperations) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 SpannerOperations (org.springframework.cloud.gcp.data.spanner.core.SpannerOperations)15 Key (com.google.cloud.spanner.Key)3 KeySet (com.google.cloud.spanner.KeySet)1 Pageable (org.springframework.data.domain.Pageable)1 Sort (org.springframework.data.domain.Sort)1