com.google.api.gax.rpc.InvalidArgumentException Java Examples

The following examples show how to use com.google.api.gax.rpc.InvalidArgumentException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdGroupAdServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateAdGroupAdsExceptionTest2() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockAdGroupAdService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<AdGroupAdOperation> operations = new ArrayList<>();

    client.mutateAdGroupAds(customerId, operations);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #2
Source File: RecommendationServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void applyRecommendationExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockRecommendationService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<ApplyRecommendationOperation> operations = new ArrayList<>();
    boolean partialFailure = true;

    client.applyRecommendation(customerId, operations, partialFailure);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #3
Source File: AdGroupSimulationServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getAdGroupSimulationExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockAdGroupSimulationService.addException(exception);

  try {
    String formattedResourceName =
        AdGroupSimulationServiceClient.formatAdGroupSimulationName(
            "[CUSTOMER]", "[AD_GROUP_SIMULATION]");

    client.getAdGroupSimulation(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #4
Source File: AdGroupFeedServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateAdGroupFeedsExceptionTest2() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockAdGroupFeedService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<AdGroupFeedOperation> operations = new ArrayList<>();

    client.mutateAdGroupFeeds(customerId, operations);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #5
Source File: FeedItemServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateFeedItemsExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockFeedItemService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<FeedItemOperation> operations = new ArrayList<>();
    boolean partialFailure = true;
    boolean validateOnly = false;

    client.mutateFeedItems(customerId, operations, partialFailure, validateOnly);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #6
Source File: CampaignLabelServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateCampaignLabelsExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockCampaignLabelService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<CampaignLabelOperation> operations = new ArrayList<>();
    boolean partialFailure = true;
    boolean validateOnly = false;

    client.mutateCampaignLabels(customerId, operations, partialFailure, validateOnly);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #7
Source File: GeoTargetConstantServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getGeoTargetConstantExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockGeoTargetConstantService.addException(exception);

  try {
    String formattedResourceName =
        GeoTargetConstantServiceClient.formatGeoTargetConstantName("[GEO_TARGET_CONSTANT]");

    client.getGeoTargetConstant(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #8
Source File: DetailPlacementViewServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getDetailPlacementViewExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockDetailPlacementViewService.addException(exception);

  try {
    String formattedResourceName =
        DetailPlacementViewServiceClient.formatDetailPlacementViewName(
            "[CUSTOMER]", "[DETAIL_PLACEMENT_VIEW]");

    client.getDetailPlacementView(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #9
Source File: AdGroupBidModifierServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getAdGroupBidModifierExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockAdGroupBidModifierService.addException(exception);

  try {
    String formattedResourceName =
        AdGroupBidModifierServiceClient.formatAdGroupBidModifierName(
            "[CUSTOMER]", "[AD_GROUP_BID_MODIFIER]");

    client.getAdGroupBidModifier(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #10
Source File: MerchantCenterLinkServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateMerchantCenterLinkExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockMerchantCenterLinkService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    MerchantCenterLinkOperation operation = MerchantCenterLinkOperation.newBuilder().build();

    client.mutateMerchantCenterLink(customerId, operation);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #11
Source File: CustomerNegativeCriterionServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateCustomerNegativeCriteriaExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockCustomerNegativeCriterionService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<CustomerNegativeCriterionOperation> operations = new ArrayList<>();
    boolean partialFailure = true;
    boolean validateOnly = false;

    client.mutateCustomerNegativeCriteria(customerId, operations, partialFailure, validateOnly);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #12
Source File: UserListServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getUserListExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockUserListService.addException(exception);

  try {
    String formattedResourceName =
        UserListServiceClient.formatUserListName("[CUSTOMER]", "[USER_LIST]");

    client.getUserList(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #13
Source File: KeywordPlanServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateKeywordPlansExceptionTest2() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockKeywordPlanService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<KeywordPlanOperation> operations = new ArrayList<>();

    client.mutateKeywordPlans(customerId, operations);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #14
Source File: SharedCriterionServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getSharedCriterionExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockSharedCriterionService.addException(exception);

  try {
    String formattedResourceName =
        SharedCriterionServiceClient.formatSharedCriteriaName("[CUSTOMER]", "[SHARED_CRITERIA]");

    client.getSharedCriterion(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #15
Source File: GoogleAdsServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockGoogleAdsService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<MutateOperation> mutateOperations = new ArrayList<>();
    boolean partialFailure = true;
    boolean validateOnly = false;

    client.mutate(customerId, mutateOperations, partialFailure, validateOnly);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #16
Source File: CustomerExtensionSettingServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateCustomerExtensionSettingsExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockCustomerExtensionSettingService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<CustomerExtensionSettingOperation> operations = new ArrayList<>();
    boolean partialFailure = true;
    boolean validateOnly = false;

    client.mutateCustomerExtensionSettings(customerId, operations, partialFailure, validateOnly);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #17
Source File: LabelServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateLabelsExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockLabelService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<LabelOperation> operations = new ArrayList<>();
    boolean partialFailure = true;
    boolean validateOnly = false;

    client.mutateLabels(customerId, operations, partialFailure, validateOnly);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #18
Source File: SearchTermViewServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getSearchTermViewExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockSearchTermViewService.addException(exception);

  try {
    String formattedResourceName =
        SearchTermViewServiceClient.formatSearchTermViewName("[CUSTOMER]", "[SEARCH_TERM_VIEW]");

    client.getSearchTermView(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #19
Source File: AdGroupAdServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateAdGroupAdsExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockAdGroupAdService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<AdGroupAdOperation> operations = new ArrayList<>();
    boolean partialFailure = true;
    boolean validateOnly = false;

    client.mutateAdGroupAds(customerId, operations, partialFailure, validateOnly);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #20
Source File: ExtensionFeedItemServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateExtensionFeedItemsExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockExtensionFeedItemService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<ExtensionFeedItemOperation> operations = new ArrayList<>();
    boolean partialFailure = true;
    boolean validateOnly = false;

    client.mutateExtensionFeedItems(customerId, operations, partialFailure, validateOnly);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #21
Source File: CampaignBidModifierServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getCampaignBidModifierExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockCampaignBidModifierService.addException(exception);

  try {
    String formattedResourceName =
        CampaignBidModifierServiceClient.formatCampaignBidModifierName(
            "[CUSTOMER]", "[CAMPAIGN_BID_MODIFIER]");

    client.getCampaignBidModifier(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #22
Source File: CampaignSharedSetServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getCampaignSharedSetExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockCampaignSharedSetService.addException(exception);

  try {
    String formattedResourceName =
        CampaignSharedSetServiceClient.formatCampaignSharedSetName(
            "[CUSTOMER]", "[CAMPAIGN_SHARED_SET]");

    client.getCampaignSharedSet(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #23
Source File: AdServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateAdsExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockAdService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<AdOperation> operations = new ArrayList<>();

    client.mutateAds(customerId, operations);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #24
Source File: CampaignDraftServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void promoteCampaignDraftExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockCampaignDraftService.addException(exception);

  try {
    String formattedCampaignDraft =
        CampaignDraftServiceClient.formatCampaignDraftName("[CUSTOMER]", "[CAMPAIGN_DRAFT]");

    client.promoteCampaignDraftAsync(formattedCampaignDraft).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());
  }
}
 
Example #25
Source File: GeoTargetConstantServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void suggestGeoTargetConstantsExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockGeoTargetConstantService.addException(exception);

  try {
    StringValue locale = StringValue.newBuilder().build();
    StringValue countryCode = StringValue.newBuilder().build();

    client.suggestGeoTargetConstants(locale, countryCode);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #26
Source File: MutateJobServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getMutateJobExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockMutateJobService.addException(exception);

  try {
    String formattedResourceName =
        MutateJobServiceClient.formatMutateJobName("[CUSTOMER]", "[MUTATE_JOB]");

    client.getMutateJob(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #27
Source File: ConversionUploadServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void uploadClickConversionsExceptionTest2() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockConversionUploadService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<ClickConversion> conversions = new ArrayList<>();

    client.uploadClickConversions(customerId, conversions);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #28
Source File: CustomerNegativeCriterionServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void mutateCustomerNegativeCriteriaExceptionTest2() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockCustomerNegativeCriterionService.addException(exception);

  try {
    String customerId = "customerId-1772061412";
    List<CustomerNegativeCriterionOperation> operations = new ArrayList<>();

    client.mutateCustomerNegativeCriteria(customerId, operations);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #29
Source File: AdGroupFeedServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getAdGroupFeedExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockAdGroupFeedService.addException(exception);

  try {
    String formattedResourceName =
        AdGroupFeedServiceClient.formatAdGroupFeedName("[CUSTOMER]", "[AD_GROUP_FEED]");

    client.getAdGroupFeed(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}
 
Example #30
Source File: CurrencyConstantServiceClientTest.java    From google-ads-java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("all")
public void getCurrencyConstantExceptionTest() throws Exception {
  StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
  mockCurrencyConstantService.addException(exception);

  try {
    String formattedResourceName =
        CurrencyConstantServiceClient.formatCurrencyConstantName("[CURRENCY_CONSTANT]");

    client.getCurrencyConstant(formattedResourceName);
    Assert.fail("No exception raised");
  } catch (InvalidArgumentException e) {
    // Expected exception
  }
}