Search in sources :

Example 1 with SpannerOperations

use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.

the class SpannerRepositoryImplTests method deleteManyObsTest.

@Test
public void deleteManyObsTest() {
    SpannerOperations operations = mock(SpannerOperations.class);
    Iterable<String> obs = Arrays.asList("ob1", "ob2");
    doAnswer(invocation -> {
        Iterable<String> toDelete = invocation.getArgument(1);
        assertThat(toDelete, containsInAnyOrder("ob1", "ob2"));
        return null;
    }).when(operations).delete(eq(String.class), same(obs));
    new SimpleSpannerRepository(operations, Object.class).deleteAll(obs);
}
Also used : SpannerOperations(org.springframework.cloud.gcp.data.spanner.core.SpannerOperations) Test(org.junit.Test)

Example 2 with SpannerOperations

use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.

the class SpannerRepositoryImplTests method findAllTest.

@Test
public void findAllTest() {
    SpannerOperations operations = mock(SpannerOperations.class);
    new SimpleSpannerRepository(operations, Object.class).findAll();
    verify(operations, times(1)).findAll(eq(Object.class));
}
Also used : SpannerOperations(org.springframework.cloud.gcp.data.spanner.core.SpannerOperations) Test(org.junit.Test)

Example 3 with SpannerOperations

use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.

the class SpannerRepositoryImplTests method existsByIdTestFound.

@Test
public void existsByIdTestFound() {
    SpannerOperations operations = mock(SpannerOperations.class);
    Key key = Key.of("key");
    Object ret = new Object();
    when(operations.find(eq(Object.class), eq(key))).thenReturn(ret);
    assertTrue(new SimpleSpannerRepository(operations, Object.class).existsById(key));
}
Also used : SpannerOperations(org.springframework.cloud.gcp.data.spanner.core.SpannerOperations) Key(com.google.cloud.spanner.Key) Test(org.junit.Test)

Example 4 with SpannerOperations

use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.

the class SpannerRepositoryImplTests method deleteByIdTest.

@Test
public void deleteByIdTest() {
    SpannerOperations operations = mock(SpannerOperations.class);
    Key key = Key.of("key");
    new SimpleSpannerRepository(operations, Object.class).deleteById(key);
    verify(operations, times(1)).delete(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 5 with SpannerOperations

use of org.springframework.cloud.gcp.data.spanner.core.SpannerOperations in project spring-cloud-gcp by spring-cloud.

the class SpannerRepositoryImplTests method deleteTest.

@Test
public void deleteTest() {
    SpannerOperations operations = mock(SpannerOperations.class);
    Object ob = new Object();
    new SimpleSpannerRepository(operations, Object.class).delete(ob);
    verify(operations, times(1)).delete(eq(ob));
}
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