@java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
static FieldMask toFieldMask(InstanceField... fields) { FieldMask.Builder builder = FieldMask.newBuilder(); for (InstanceField field : fields) { builder.addPaths(field.getSelector()); } return builder.build(); } }
@Test @SuppressWarnings("all") public void updateCryptoKeyVersionExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockKeyManagementService.addException(exception); try { CryptoKeyVersion cryptoKeyVersion = CryptoKeyVersion.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateCryptoKeyVersion(cryptoKeyVersion, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateQueueExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockCloudTasks.addException(exception); try { Queue queue = Queue.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateQueue(queue, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateProductSetExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockProductSearch.addException(exception); try { ProductSet productSet = ProductSet.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateProductSet(productSet, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateDeviceExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockDeviceManager.addException(exception); try { Device device = Device.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateDevice(device, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateProductSetExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockProductSearch.addException(exception); try { ProductSet productSet = ProductSet.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateProductSet(productSet, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateQueueExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockCloudTasks.addException(exception); try { Queue queue = Queue.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateQueue(queue, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateProductExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockProductSearch.addException(exception); try { Product product = Product.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateProduct(product, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateScanConfigExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockWebSecurityScanner.addException(exception); try { ScanConfig scanConfig = ScanConfig.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateScanConfig(scanConfig, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateTransferConfigExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockDataTransferService.addException(exception); try { TransferConfig transferConfig = TransferConfig.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateTransferConfig(transferConfig, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateCryptoKeyExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockKeyManagementService.addException(exception); try { CryptoKey cryptoKey = CryptoKey.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateCryptoKey(cryptoKey, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateNotificationChannelExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { FieldMask updateMask = FieldMask.newBuilder().build(); NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); client.updateNotificationChannel(updateMask, notificationChannel); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateJobExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockCloudScheduler.addException(exception); try { Job job = Job.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateJob(job, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateDeviceRegistryExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockDeviceManager.addException(exception); try { DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateDeviceRegistry(deviceRegistry, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateProductExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockProductSearch.addException(exception); try { Product product = Product.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateProduct(product, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateIntentExceptionTest2() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockIntents.addException(exception); try { Intent intent = Intent.newBuilder().build(); String languageCode = "languageCode-412800396"; FieldMask updateMask = FieldMask.newBuilder().build(); client.updateIntent(intent, languageCode, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void updateAlertPolicyExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockAlertPolicyService.addException(exception); try { FieldMask updateMask = FieldMask.newBuilder().build(); AlertPolicy alertPolicy = AlertPolicy.newBuilder().build(); client.updateAlertPolicy(updateMask, alertPolicy); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } } }
@Test @SuppressWarnings("all") public void updateNoteExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockGrafeasV1Beta1.addException(exception); try { NoteName name = NoteName.of("[PROJECT]", "[NOTE]"); Note note = Note.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateNote(name, note, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test public void testType() { UpdateInstanceRequest input = UpdateInstanceRequest.of("my-instance").setProductionType(); PartialUpdateInstanceRequest actual = input.toProto("my-project"); PartialUpdateInstanceRequest expected = PartialUpdateInstanceRequest.newBuilder() .setUpdateMask(FieldMask.newBuilder().addPaths("type")) .setInstance( Instance.newBuilder() .setName("projects/my-project/instances/my-instance") .setType(Type.PRODUCTION)) .build(); assertThat(actual).isEqualTo(expected); } }