use of com.google.spanner.admin.instance.v1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method createAppProfileTest.
@Test
public void createAppProfileTest() throws Exception {
AppProfile expectedResponse = AppProfile.newBuilder().setName(AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]").toString()).setEtag("etag3123477").setDescription("description-1724546052").build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String appProfileId = "appProfileId704923523";
AppProfile appProfile = AppProfile.newBuilder().build();
AppProfile actualResponse = client.createAppProfile(parent, appProfileId, appProfile);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateAppProfileRequest actualRequest = ((CreateAppProfileRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(appProfileId, actualRequest.getAppProfileId());
Assert.assertEquals(appProfile, actualRequest.getAppProfile());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.spanner.admin.instance.v1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method deleteInstanceTest.
@Test
public void deleteInstanceTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
client.deleteInstance(name);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteInstanceRequest actualRequest = ((DeleteInstanceRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.spanner.admin.instance.v1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method createAppProfileExceptionTest.
@Test
public void createAppProfileExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableInstanceAdmin.addException(exception);
try {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String appProfileId = "appProfileId704923523";
AppProfile appProfile = AppProfile.newBuilder().build();
client.createAppProfile(parent, appProfileId, appProfile);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.spanner.admin.instance.v1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method listTablesTest.
@Test
public void listTablesTest() throws Exception {
Table responsesElement = Table.newBuilder().build();
ListTablesResponse expectedResponse = ListTablesResponse.newBuilder().setNextPageToken("").addAllTables(Arrays.asList(responsesElement)).build();
mockBigtableTableAdmin.addResponse(expectedResponse);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
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.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.spanner.admin.instance.v1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method createTableFromSnapshotTest2.
@Test
public void createTableFromSnapshotTest2() 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";
String sourceSnapshot = "sourceSnapshot-1078634753";
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, actualRequest.getSourceSnapshot());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations