/** * * * <pre> * The list of requested app profiles. * </pre> * * <code>repeated .google.bigtable.admin.v2.AppProfile app_profiles = 1;</code> */ public Builder addAppProfiles(com.google.bigtable.admin.v2.AppProfile.Builder builderForValue) { if (appProfilesBuilder_ == null) { ensureAppProfilesIsMutable(); appProfiles_.add(builderForValue.build()); onChanged(); } else { appProfilesBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * The list of requested app profiles. * </pre> * * <code>repeated .google.bigtable.admin.v2.AppProfile app_profiles = 1;</code> */ public Builder addAppProfiles( int index, com.google.bigtable.admin.v2.AppProfile.Builder builderForValue) { if (appProfilesBuilder_ == null) { ensureAppProfilesIsMutable(); appProfiles_.add(index, builderForValue.build()); onChanged(); } else { appProfilesBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The list of requested app profiles. * </pre> * * <code>repeated .google.bigtable.admin.v2.AppProfile app_profiles = 1;</code> */ public Builder setAppProfiles( int index, com.google.bigtable.admin.v2.AppProfile.Builder builderForValue) { if (appProfilesBuilder_ == null) { ensureAppProfilesIsMutable(); appProfiles_.set(index, builderForValue.build()); onChanged(); } else { appProfilesBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The list of requested app profiles. * </pre> * * <code>repeated .google.bigtable.admin.v2.AppProfile app_profiles = 1;</code> */ public Builder addAppProfiles( int index, com.google.bigtable.admin.v2.AppProfile.Builder builderForValue) { if (appProfilesBuilder_ == null) { ensureAppProfilesIsMutable(); appProfiles_.add(index, builderForValue.build()); onChanged(); } else { appProfilesBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The list of requested app profiles. * </pre> * * <code>repeated .google.bigtable.admin.v2.AppProfile app_profiles = 1;</code> */ public Builder addAppProfiles(com.google.bigtable.admin.v2.AppProfile.Builder builderForValue) { if (appProfilesBuilder_ == null) { ensureAppProfilesIsMutable(); appProfiles_.add(builderForValue.build()); onChanged(); } else { appProfilesBuilder_.addMessage(builderForValue.build()); } return this; } /**
com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny .getDefaultInstance()) .build());
com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny .getDefaultInstance()) .build();
@Test public void testUpdateAppProfile() { // Setup com.google.bigtable.admin.v2.UpdateAppProfileRequest expectedRequest = com.google.bigtable.admin.v2.UpdateAppProfileRequest.newBuilder() .setAppProfile( com.google.bigtable.admin.v2.AppProfile.newBuilder() .setName(APP_PROFILE_NAME) .setDescription("updated description")) .setUpdateMask(FieldMask.newBuilder().addPaths("description")) .build(); com.google.bigtable.admin.v2.AppProfile expectedResponse = com.google.bigtable.admin.v2.AppProfile.newBuilder() .setName(APP_PROFILE_NAME) .setDescription("updated description") .setMultiClusterRoutingUseAny( com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny .getDefaultInstance()) .build(); mockOperationResult(mockUpdateAppProfileCallable, expectedRequest, expectedResponse); // Execute AppProfile actualResult = adminClient.updateAppProfile( UpdateAppProfileRequest.of(INSTANCE_ID, APP_PROFILE_ID) .setDescription("updated description")); // Verify assertThat(actualResult).isEqualTo(AppProfile.fromProto(expectedResponse)); }
@Test @SuppressWarnings("all") public void createAppProfileTest() { String name = "name3373707"; String etag = "etag3123477"; String description = "description-1724546052"; AppProfile expectedResponse = AppProfile.newBuilder().setName(name).setEtag(etag).setDescription(description).build(); mockBigtableInstanceAdmin.addResponse(expectedResponse); InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); String appProfileId = "appProfileId1262094415"; AppProfile appProfile = AppProfile.newBuilder().build(); AppProfile actualResponse = client.createAppProfile(parent, appProfileId, appProfile); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockBigtableInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateAppProfileRequest actualRequest = (CreateAppProfileRequest) actualRequests.get(0); Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); Assert.assertEquals(appProfileId, actualRequest.getAppProfileId()); Assert.assertEquals(appProfile, actualRequest.getAppProfile()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void listAppProfilesTest() { String nextPageToken = ""; AppProfile appProfilesElement = AppProfile.newBuilder().build(); List<AppProfile> appProfiles = Arrays.asList(appProfilesElement); ListAppProfilesResponse expectedResponse = ListAppProfilesResponse.newBuilder() .setNextPageToken(nextPageToken) .addAllAppProfiles(appProfiles) .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<GeneratedMessageV3> actualRequests = mockBigtableInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); ListAppProfilesRequest actualRequest = (ListAppProfilesRequest) actualRequests.get(0); Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void updateAppProfileTest() throws Exception { String name = "name3373707"; String etag = "etag3123477"; String description = "description-1724546052"; AppProfile expectedResponse = AppProfile.newBuilder().setName(name).setEtag(etag).setDescription(description).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<GeneratedMessageV3> 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())); }
@Test public void testGetAppProfile() { // Setup com.google.bigtable.admin.v2.GetAppProfileRequest expectedRequest = com.google.bigtable.admin.v2.GetAppProfileRequest.newBuilder() .setName(APP_PROFILE_NAME) .build(); com.google.bigtable.admin.v2.AppProfile expectedResponse = com.google.bigtable.admin.v2.AppProfile.newBuilder() .setName(APP_PROFILE_NAME) .setDescription("my description") .setMultiClusterRoutingUseAny( com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny .getDefaultInstance()) .build(); Mockito.when(mockGetAppProfileCallable.futureCall(expectedRequest)) .thenReturn(ApiFutures.immediateFuture(expectedResponse)); // Execute AppProfile actualResult = adminClient.getAppProfile(INSTANCE_ID, APP_PROFILE_ID); // Verify assertThat(actualResult).isEqualTo(AppProfile.fromProto(expectedResponse)); }
/** * * * <pre> * The app profile to be created. * Fields marked `OutputOnly` will be ignored. * </pre> * * <code>.google.bigtable.admin.v2.AppProfile app_profile = 3;</code> */ public Builder setAppProfile(com.google.bigtable.admin.v2.AppProfile.Builder builderForValue) { if (appProfileBuilder_ == null) { appProfile_ = builderForValue.build(); onChanged(); } else { appProfileBuilder_.setMessage(builderForValue.build()); } return this; } /**
@Test @SuppressWarnings("all") public void getAppProfileTest() { String name2 = "name2-1052831874"; String etag = "etag3123477"; String description = "description-1724546052"; AppProfile expectedResponse = AppProfile.newBuilder().setName(name2).setEtag(etag).setDescription(description).build(); mockBigtableInstanceAdmin.addResponse(expectedResponse); AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]"); AppProfile actualResponse = client.getAppProfile(name); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockBigtableInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetAppProfileRequest actualRequest = (GetAppProfileRequest) actualRequests.get(0); Assert.assertEquals(name, AppProfileName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test public void testUpdateExisting() { com.google.bigtable.admin.v2.AppProfile existingProto = com.google.bigtable.admin.v2.AppProfile.newBuilder() .setName("projects/my-project/instances/my-instance/appProfiles/my-profile") .setEtag("my-etag") .setDescription("description") .setMultiClusterRoutingUseAny(MultiClusterRoutingUseAny.getDefaultInstance()) .build(); AppProfile existingWrapper = AppProfile.fromProto(existingProto); UpdateAppProfileRequest updateWrapper = UpdateAppProfileRequest.of(existingWrapper).setDescription("new description"); assertThat(updateWrapper.toProto("my-project")) .isEqualTo( com.google.bigtable.admin.v2.UpdateAppProfileRequest.newBuilder() .setAppProfile(existingProto.toBuilder().setDescription("new description")) .setUpdateMask(FieldMask.newBuilder().addPaths("description")) .build()); } }
/** * * * <pre> * The app profile which will (partially) replace the current value. * </pre> * * <code>.google.bigtable.admin.v2.AppProfile app_profile = 1;</code> */ public Builder setAppProfile(com.google.bigtable.admin.v2.AppProfile.Builder builderForValue) { if (appProfileBuilder_ == null) { appProfile_ = builderForValue.build(); onChanged(); } else { appProfileBuilder_.setMessage(builderForValue.build()); } return this; } /**
@Test @SuppressWarnings("all") public void createAppProfileExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockBigtableInstanceAdmin.addException(exception); try { InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); String appProfileId = "appProfileId1262094415"; AppProfile appProfile = AppProfile.newBuilder().build(); client.createAppProfile(parent, appProfileId, appProfile); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateAppProfileExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(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()); } }
@Test public void testNoPolicyError() { Exception actualException = null; try { AppProfile.fromProto(TEST_PROTO.toBuilder().clearSingleClusterRouting().build()); } catch (Exception e) { actualException = e; } assertThat(actualException).isInstanceOf(IllegalArgumentException.class); } }
@Test public void testNoNameError() { Exception actualException = null; try { AppProfile.fromProto(TEST_PROTO.toBuilder().setName("").build()); } catch (Exception e) { actualException = e; } assertThat(actualException).isInstanceOf(IllegalArgumentException.class); }