use of com.google.bigtable.admin.v2.AppProfile in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method updateAppProfileTest.
@Test
public void updateAppProfileTest() throws Exception {
AppProfile expectedResponse = AppProfile.newBuilder().setName(AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]").toString()).setEtag("etag3123477").setDescription("description-1724546052").build();
Operation resultOperation = Operation.newBuilder().setName("updateAppProfileTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableInstanceAdmin.addResponse(resultOperation);
AppProfile appProfile = AppProfile.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
AppProfile actualResponse = client.updateAppProfileAsync(appProfile, updateMask).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateAppProfileRequest actualRequest = ((UpdateAppProfileRequest) actualRequests.get(0));
Assert.assertEquals(appProfile, actualRequest.getAppProfile());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.AppProfile in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method createAppProfileExceptionTest2.
@Test
public void createAppProfileExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableInstanceAdmin.addException(exception);
try {
String parent = "parent-995424086";
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.bigtable.admin.v2.AppProfile in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method updateAppProfileExceptionTest.
@Test
public void updateAppProfileExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableInstanceAdmin.addException(exception);
try {
AppProfile appProfile = AppProfile.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateAppProfileAsync(appProfile, updateMask).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
use of com.google.bigtable.admin.v2.AppProfile in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method getAppProfileTest2.
@Test
public void getAppProfileTest2() throws Exception {
AppProfile expectedResponse = AppProfile.newBuilder().setName(AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]").toString()).setEtag("etag3123477").setDescription("description-1724546052").build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
String name = "name3373707";
AppProfile actualResponse = client.getAppProfile(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetAppProfileRequest actualRequest = ((GetAppProfileRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.AppProfile in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method listAppProfilesTest.
@Test
public void listAppProfilesTest() throws Exception {
AppProfile responsesElement = AppProfile.newBuilder().build();
ListAppProfilesResponse expectedResponse = ListAppProfilesResponse.newBuilder().setNextPageToken("").addAllAppProfiles(Arrays.asList(responsesElement)).build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
ListAppProfilesPagedResponse pagedListResponse = client.listAppProfiles(parent);
List<AppProfile> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getAppProfilesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListAppProfilesRequest actualRequest = ((ListAppProfilesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations