Search in sources :

Example 1 with BigtableInstanceName

use of com.google.cloud.bigtable.grpc.BigtableInstanceName 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

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