Search in sources :

Example 1 with BigtableTableAdminClient

use of com.google.cloud.bigtable.grpc.BigtableTableAdminClient in project simple-bigtable by spotify.

the class BigtableMock method getMock.

public static Bigtable getMock(final String project, final String instance) {
    final BigtableDataClient dataClient = Mockito.mock(BigtableDataClient.class);
    final BigtableTableAdminClient tableAdminClient = Mockito.mock(BigtableTableAdminClient.class);
    final BigtableSession session = Mockito.mock(BigtableSession.class);
    try {
        Mockito.when(session.getDataClient()).thenReturn(dataClient);
        Mockito.when(session.getTableAdminClient()).thenReturn(tableAdminClient);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return new BigtableMock(session, project, instance);
}
Also used : BigtableTableAdminClient(com.google.cloud.bigtable.grpc.BigtableTableAdminClient) BigtableSession(com.google.cloud.bigtable.grpc.BigtableSession) IOException(java.io.IOException) BigtableDataClient(com.google.cloud.bigtable.grpc.BigtableDataClient)

Example 2 with BigtableTableAdminClient

use of com.google.cloud.bigtable.grpc.BigtableTableAdminClient in project simple-bigtable by spotify.

the class BigtableMock method getMock.

public static BigtableMock getMock() {
    final BigtableDataClient dataClient = Mockito.mock(BigtableDataClient.class);
    final BigtableTableAdminClient tableAdminClient = Mockito.mock(BigtableTableAdminClient.class);
    final BigtableSession session = Mockito.mock(BigtableSession.class);
    final BigtableOptions options = Mockito.mock(BigtableOptions.class);
    try {
        Mockito.when(session.getDataClient()).thenReturn(dataClient);
        Mockito.when(session.getTableAdminClient()).thenReturn(tableAdminClient);
        Mockito.when(session.getOptions()).thenReturn(options);
        Mockito.when(options.getInstanceName()).thenReturn(new BigtableInstanceName(PROJECT_ID, INSTANCE_ID));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return new BigtableMock(session, PROJECT_ID, INSTANCE_ID);
}
Also used : BigtableInstanceName(com.google.cloud.bigtable.grpc.BigtableInstanceName) BigtableOptions(com.google.cloud.bigtable.config.BigtableOptions) BigtableTableAdminClient(com.google.cloud.bigtable.grpc.BigtableTableAdminClient) BigtableSession(com.google.cloud.bigtable.grpc.BigtableSession) IOException(java.io.IOException) BigtableDataClient(com.google.cloud.bigtable.grpc.BigtableDataClient)

Aggregations

BigtableDataClient (com.google.cloud.bigtable.grpc.BigtableDataClient)2 BigtableSession (com.google.cloud.bigtable.grpc.BigtableSession)2 BigtableTableAdminClient (com.google.cloud.bigtable.grpc.BigtableTableAdminClient)2 IOException (java.io.IOException)2 BigtableOptions (com.google.cloud.bigtable.config.BigtableOptions)1 BigtableInstanceName (com.google.cloud.bigtable.grpc.BigtableInstanceName)1