use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method createTableExceptionTest.
@Test
public void createTableExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String tableId = "tableId-1552905847";
Table table = Table.newBuilder().build();
client.createTable(parent, tableId, table);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method createTableExceptionTest2.
@Test
public void createTableExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
String parent = "parent-995424086";
String tableId = "tableId-1552905847";
Table table = Table.newBuilder().build();
client.createTable(parent, tableId, table);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method modifyColumnFamiliesTest.
@Test
public void modifyColumnFamiliesTest() 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]");
List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
Table actualResponse = client.modifyColumnFamilies(name, modifications);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ModifyColumnFamiliesRequest actualRequest = ((ModifyColumnFamiliesRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(modifications, actualRequest.getModificationsList());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method listTablesTest2.
@Test
public void listTablesTest2() throws Exception {
Table responsesElement = Table.newBuilder().build();
ListTablesResponse expectedResponse = ListTablesResponse.newBuilder().setNextPageToken("").addAllTables(Arrays.asList(responsesElement)).build();
mockBigtableTableAdmin.addResponse(expectedResponse);
String parent = "parent-995424086";
ListTablesPagedResponse pagedListResponse = client.listTables(parent);
List<Table> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTablesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTablesRequest actualRequest = ((ListTablesRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method createTableFromSnapshotTest.
@Test
public void createTableFromSnapshotTest() 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("createTableFromSnapshotTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableTableAdmin.addResponse(resultOperation);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String tableId = "tableId-1552905847";
SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
Table actualResponse = client.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateTableFromSnapshotRequest actualRequest = ((CreateTableFromSnapshotRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(tableId, actualRequest.getTableId());
Assert.assertEquals(sourceSnapshot.toString(), actualRequest.getSourceSnapshot());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations