Search in sources :

Example 6 with AppProfile

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) UpdateAppProfileRequest(com.google.bigtable.admin.v2.UpdateAppProfileRequest) AppProfile(com.google.bigtable.admin.v2.AppProfile) Operation(com.google.longrunning.Operation) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 7 with AppProfile

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.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) AppProfile(com.google.bigtable.admin.v2.AppProfile) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 8 with AppProfile

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());
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) AppProfile(com.google.bigtable.admin.v2.AppProfile) ExecutionException(java.util.concurrent.ExecutionException) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 9 with AppProfile

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()));
}
Also used : GetAppProfileRequest(com.google.bigtable.admin.v2.GetAppProfileRequest) AbstractMessage(com.google.protobuf.AbstractMessage) AppProfile(com.google.bigtable.admin.v2.AppProfile) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 10 with AppProfile

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()));
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) AbstractMessage(com.google.protobuf.AbstractMessage) ListAppProfilesPagedResponse(com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse) AppProfile(com.google.bigtable.admin.v2.AppProfile) ListAppProfilesRequest(com.google.bigtable.admin.v2.ListAppProfilesRequest) ListAppProfilesResponse(com.google.bigtable.admin.v2.ListAppProfilesResponse) Test(org.junit.Test)

Aggregations

AppProfile (com.google.bigtable.admin.v2.AppProfile)10 Test (org.junit.Test)10 AbstractMessage (com.google.protobuf.AbstractMessage)7 ByteString (com.google.protobuf.ByteString)6 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)3 GetAppProfileRequest (com.google.bigtable.admin.v2.GetAppProfileRequest)3 InstanceName (com.google.bigtable.admin.v2.InstanceName)3 ListAppProfilesRequest (com.google.bigtable.admin.v2.ListAppProfilesRequest)3 ListAppProfilesPagedResponse (com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse)3 StatusRuntimeException (io.grpc.StatusRuntimeException)3 CreateAppProfileRequest (com.google.bigtable.admin.v2.CreateAppProfileRequest)2 ListAppProfilesResponse (com.google.bigtable.admin.v2.ListAppProfilesResponse)2 AppProfile (com.google.cloud.bigtable.admin.v2.models.AppProfile)2 FieldMask (com.google.protobuf.FieldMask)2 ApiFuture (com.google.api.core.ApiFuture)1 AppProfileName (com.google.bigtable.admin.v2.AppProfileName)1 UpdateAppProfileRequest (com.google.bigtable.admin.v2.UpdateAppProfileRequest)1 ListAppProfilesPage (com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPage)1 ImmutableList (com.google.common.collect.ImmutableList)1 Operation (com.google.longrunning.Operation)1