@Test public void exceptionTransformedToGoogleAdsException() { GoogleAdsClient client = GoogleAdsClient.newBuilder() .setCredentials(fakeCredentials) .setDeveloperToken(DEVELOPER_TOKEN) .setTransportChannelProvider(localChannelProvider) .setEnableGeneratedCatalog(enabledGeneratedCatalog) .build(); Metadata.Key trailerKey = ApiCatalog.getDefault().getLatestVersion().getExceptionFactory().getTrailerKey(); Metadata trailers = new Metadata(); GoogleAdsFailure.Builder failure = GoogleAdsFailure.newBuilder(); failure.addErrors(GoogleAdsError.newBuilder().setMessage("Test error message")); trailers.put(trailerKey, failure.build().toByteArray()); StatusException rootCause = new StatusException(Status.UNKNOWN, trailers); mockService.addException(new ApiException(rootCause, GrpcStatusCode.of(Code.UNKNOWN), false)); try (GoogleAdsServiceClient googleAdsServiceClient = client.getLatestVersion().createGoogleAdsServiceClient()) { googleAdsServiceClient.search("123", "select blah"); } catch (GoogleAdsException ex) { } }
public static Builder newBuilder() { AutoValue_GoogleAdsClient.Builder clientBuilder = new AutoValue_GoogleAdsClient.Builder(); clientBuilder.setEnableGeneratedCatalog(true); InstantiatingGrpcChannelProvider transportChannelProvider = InstantiatingGrpcChannelProvider.newBuilder() .setInterceptorProvider( () -> ImmutableList.of( new LoggingInterceptor( new RequestLogger(), clientBuilder.getHeaders(), clientBuilder.getEndpoint()))) .setMaxInboundMetadataSize(16 * 1024 * 1024) .setMaxInboundMessageSize(64 * 1024 * 1024) .build(); clientBuilder .setEndpoint(DEFAULT_ENDPOINT) .setTransportChannelProvider(transportChannelProvider); return clientBuilder; }
GoogleAdsClient extends AbstractGoogleAdsClient { public static Builder newBuilder() { AutoValue_GoogleAdsClient.Builder clientBuilder = new AutoValue_GoogleAdsClient.Builder(); clientBuilder.setEnableGeneratedCatalog(true); InstantiatingGrpcChannelProvider transportChannelProvider = InstantiatingGrpcChannelProvider.newBuilder() .setInterceptorProvider( () -> ImmutableList.of( new LoggingInterceptor( new RequestLogger(), clientBuilder.getHeaders(), clientBuilder.getEndpoint()))) .setMaxInboundMetadataSize(16 * 1024 * 1024) .setMaxInboundMessageSize(64 * 1024 * 1024) .build(); clientBuilder .setEndpoint(DEFAULT_ENDPOINT) .setTransportChannelProvider(transportChannelProvider); return clientBuilder; } }
GoogleAdsClient extends AbstractGoogleAdsClient { public static Builder newBuilder() { AutoValue_GoogleAdsClient.Builder clientBuilder = new AutoValue_GoogleAdsClient.Builder(); clientBuilder.setEnableGeneratedCatalog(true); InstantiatingGrpcChannelProvider transportChannelProvider = InstantiatingGrpcChannelProvider.newBuilder() .setInterceptorProvider( () -> ImmutableList.of( new LoggingInterceptor( new RequestLogger(), clientBuilder.getHeaders(), clientBuilder.getEndpoint()))) .setMaxInboundMetadataSize(16 * 1024 * 1024) .setMaxInboundMessageSize(64 * 1024 * 1024) .build(); clientBuilder .setEndpoint(DEFAULT_ENDPOINT) .setTransportChannelProvider(transportChannelProvider); return clientBuilder; }  }
GoogleAdsClient extends AbstractGoogleAdsClient { public static Builder newBuilder() { AutoValue_GoogleAdsClient.Builder clientBuilder = new AutoValue_GoogleAdsClient.Builder(); clientBuilder.setEnableGeneratedCatalog(true); InstantiatingGrpcChannelProvider transportChannelProvider = InstantiatingGrpcChannelProvider.newBuilder() .setInterceptorProvider( () -> ImmutableList.of( new LoggingInterceptor( new RequestLogger(), clientBuilder.getHeaders(), clientBuilder.getEndpoint()))) .setMaxInboundMetadataSize(16 * 1024 * 1024) .setMaxInboundMessageSize(64 * 1024 * 1024) .build(); clientBuilder .setEndpoint(DEFAULT_ENDPOINT) .setTransportChannelProvider(transportChannelProvider); return clientBuilder; }  static Builder newBuilder(); abstract Credentials getCredentials(); abstract String getDeveloperToken(); abstract String getEndpoint(); @Nullable abstract Long getLoginCustomerId(); @Nullable abstract Long getLinkedCustomerId(); abstract Builder toBuilder(); }
GoogleAdsClient extends AbstractGoogleAdsClient { public static Builder newBuilder() { AutoValue_GoogleAdsClient.Builder clientBuilder = new AutoValue_GoogleAdsClient.Builder(); clientBuilder.setEnableGeneratedCatalog(true); InstantiatingGrpcChannelProvider transportChannelProvider = InstantiatingGrpcChannelProvider.newBuilder() .setInterceptorProvider( () -> ImmutableList.of( new LoggingInterceptor( new RequestLogger(), clientBuilder.getHeaders(), clientBuilder.getEndpoint()))) .setMaxInboundMetadataSize(16 * 1024 * 1024) .setMaxInboundMessageSize(64 * 1024 * 1024) .build(); clientBuilder .setEndpoint(DEFAULT_ENDPOINT) .setTransportChannelProvider(transportChannelProvider); return clientBuilder; }  static Builder newBuilder(); abstract Credentials getCredentials(); abstract String getDeveloperToken(); abstract String getEndpoint(); @Nullable abstract Long getLoginCustomerId(); @Nullable abstract Long getLinkedCustomerId(); abstract Builder toBuilder();  }