Search in sources :

Example 11 with ColumnFamily

use of com.google.bigtable.admin.v2.ColumnFamily in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method getTableTest.

@Test
public void getTableTest() throws Exception {
    Table expectedResponse = Table.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).putAllClusterStates(new HashMap<String, Table.ClusterState>()).putAllColumnFamilies(new HashMap<String, ColumnFamily>()).setRestoreInfo(RestoreInfo.newBuilder().build()).build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
    Table actualResponse = client.getTable(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetTableRequest actualRequest = ((GetTableRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : TableName(com.google.bigtable.admin.v2.TableName) GetTableRequest(com.google.bigtable.admin.v2.GetTableRequest) Table(com.google.bigtable.admin.v2.Table) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) Test(org.junit.Test)

Example 12 with ColumnFamily

use of com.google.bigtable.admin.v2.ColumnFamily in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method restoreTableTest.

@Test
public void restoreTableTest() throws Exception {
    Table expectedResponse = Table.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).putAllClusterStates(new HashMap<String, Table.ClusterState>()).putAllColumnFamilies(new HashMap<String, ColumnFamily>()).setRestoreInfo(RestoreInfo.newBuilder().build()).build();
    Operation resultOperation = Operation.newBuilder().setName("restoreTableTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockBigtableTableAdmin.addResponse(resultOperation);
    RestoreTableRequest request = RestoreTableRequest.newBuilder().setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setTableId("tableId-1552905847").build();
    Table actualResponse = client.restoreTableAsync(request).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    RestoreTableRequest actualRequest = ((RestoreTableRequest) actualRequests.get(0));
    Assert.assertEquals(request.getParent(), actualRequest.getParent());
    Assert.assertEquals(request.getTableId(), actualRequest.getTableId());
    Assert.assertEquals(request.getBackup(), actualRequest.getBackup());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : RestoreTableRequest(com.google.bigtable.admin.v2.RestoreTableRequest) Table(com.google.bigtable.admin.v2.Table) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) Test(org.junit.Test)

Example 13 with ColumnFamily

use of com.google.bigtable.admin.v2.ColumnFamily in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method createTableTest.

@Test
public void createTableTest() throws Exception {
    Table expectedResponse = Table.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).putAllClusterStates(new HashMap<String, Table.ClusterState>()).putAllColumnFamilies(new HashMap<String, ColumnFamily>()).setRestoreInfo(RestoreInfo.newBuilder().build()).build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    String tableId = "tableId-1552905847";
    Table table = Table.newBuilder().build();
    Table actualResponse = client.createTable(parent, tableId, table);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateTableRequest actualRequest = ((CreateTableRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(tableId, actualRequest.getTableId());
    Assert.assertEquals(table, actualRequest.getTable());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) Table(com.google.bigtable.admin.v2.Table) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) CreateTableRequest(com.google.bigtable.admin.v2.CreateTableRequest) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) Test(org.junit.Test)

Example 14 with ColumnFamily

use of com.google.bigtable.admin.v2.ColumnFamily in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method createTableTest2.

@Test
public void createTableTest2() throws Exception {
    Table expectedResponse = Table.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).putAllClusterStates(new HashMap<String, Table.ClusterState>()).putAllColumnFamilies(new HashMap<String, ColumnFamily>()).setRestoreInfo(RestoreInfo.newBuilder().build()).build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    String tableId = "tableId-1552905847";
    Table table = Table.newBuilder().build();
    Table actualResponse = client.createTable(parent, tableId, table);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateTableRequest actualRequest = ((CreateTableRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(tableId, actualRequest.getTableId());
    Assert.assertEquals(table, actualRequest.getTable());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Table(com.google.bigtable.admin.v2.Table) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) CreateTableRequest(com.google.bigtable.admin.v2.CreateTableRequest) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) Test(org.junit.Test)

Example 15 with ColumnFamily

use of com.google.bigtable.admin.v2.ColumnFamily in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method getTableTest2.

@Test
public void getTableTest2() throws Exception {
    Table expectedResponse = Table.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).putAllClusterStates(new HashMap<String, Table.ClusterState>()).putAllColumnFamilies(new HashMap<String, ColumnFamily>()).setRestoreInfo(RestoreInfo.newBuilder().build()).build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    Table actualResponse = client.getTable(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetTableRequest actualRequest = ((GetTableRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : GetTableRequest(com.google.bigtable.admin.v2.GetTableRequest) Table(com.google.bigtable.admin.v2.Table) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) Test(org.junit.Test)

Aggregations

ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)19 Test (org.junit.Test)18 Table (com.google.bigtable.admin.v2.Table)13 AbstractMessage (com.google.protobuf.AbstractMessage)11 ByteString (com.google.protobuf.ByteString)11 HashMap (java.util.HashMap)11 GCRule (com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule)5 Operation (com.google.longrunning.Operation)5 CreateTableFromSnapshotRequest (com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest)4 InstanceName (com.google.bigtable.admin.v2.InstanceName)3 TableName (com.google.bigtable.admin.v2.TableName)3 GCRules (com.google.cloud.bigtable.admin.v2.models.GCRules)3 CreateTableRequest (com.google.bigtable.admin.v2.CreateTableRequest)2 GetTableRequest (com.google.bigtable.admin.v2.GetTableRequest)2 ModifyColumnFamiliesRequest (com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest)2 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)2 ArrayList (java.util.ArrayList)2 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)2 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)2 RestoreTableRequest (com.google.bigtable.admin.v2.RestoreTableRequest)1