diff --git a/google-cloud-dlp/pom.xml b/google-cloud-dlp/pom.xml index 338ad2b9..3cde5a20 100644 --- a/google-cloud-dlp/pom.xml +++ b/google-cloud-dlp/pom.xml @@ -58,6 +58,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -76,12 +80,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceClient.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceClient.java index fe6fa997..2a7392d8 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceClient.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceClient.java @@ -173,6 +173,20 @@ * DlpServiceClient dlpServiceClient = DlpServiceClient.create(dlpServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * DlpServiceSettings dlpServiceSettings =
+ *     DlpServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DlpServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DlpServiceClient dlpServiceClient = DlpServiceClient.create(dlpServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceSettings.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceSettings.java index 28499295..e5574d63 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceSettings.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceSettings.java @@ -27,6 +27,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -345,11 +346,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DlpServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return DlpServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DlpServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DlpServiceStubSettings.defaultTransportChannelProvider(); } @@ -359,11 +367,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DlpServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -401,6 +415,11 @@ private static Builder createDefault() { return new Builder(DlpServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DlpServiceStubSettings.newHttpJsonBuilder()); + } + public DlpServiceStubSettings.Builder getStubSettingsBuilder() { return ((DlpServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStubSettings.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStubSettings.java index db101fc6..da9bfec3 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStubSettings.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStubSettings.java @@ -31,6 +31,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -717,6 +720,11 @@ public DlpServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDlpServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDlpServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -749,18 +757,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(DlpServiceStubSettings.class)) @@ -768,11 +783,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(DlpServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DlpServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -1114,6 +1148,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .inspectContentSettings() diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/HttpJsonDlpServiceCallableFactory.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/HttpJsonDlpServiceCallableFactory.java new file mode 100644 index 00000000..65d19fac --- /dev/null +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/HttpJsonDlpServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.dlp.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the DlpService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDlpServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/HttpJsonDlpServiceStub.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/HttpJsonDlpServiceStub.java new file mode 100644 index 00000000..627f54d0 --- /dev/null +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/HttpJsonDlpServiceStub.java @@ -0,0 +1,2157 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.dlp.v2.stub; + +import static com.google.cloud.dlp.v2.DlpServiceClient.ListDeidentifyTemplatesPagedResponse; +import static com.google.cloud.dlp.v2.DlpServiceClient.ListDlpJobsPagedResponse; +import static com.google.cloud.dlp.v2.DlpServiceClient.ListInspectTemplatesPagedResponse; +import static com.google.cloud.dlp.v2.DlpServiceClient.ListJobTriggersPagedResponse; +import static com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.privacy.dlp.v2.ActivateJobTriggerRequest; +import com.google.privacy.dlp.v2.CancelDlpJobRequest; +import com.google.privacy.dlp.v2.CreateDeidentifyTemplateRequest; +import com.google.privacy.dlp.v2.CreateDlpJobRequest; +import com.google.privacy.dlp.v2.CreateInspectTemplateRequest; +import com.google.privacy.dlp.v2.CreateJobTriggerRequest; +import com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest; +import com.google.privacy.dlp.v2.DeidentifyContentRequest; +import com.google.privacy.dlp.v2.DeidentifyContentResponse; +import com.google.privacy.dlp.v2.DeidentifyTemplate; +import com.google.privacy.dlp.v2.DeleteDeidentifyTemplateRequest; +import com.google.privacy.dlp.v2.DeleteDlpJobRequest; +import com.google.privacy.dlp.v2.DeleteInspectTemplateRequest; +import com.google.privacy.dlp.v2.DeleteJobTriggerRequest; +import com.google.privacy.dlp.v2.DeleteStoredInfoTypeRequest; +import com.google.privacy.dlp.v2.DlpJob; +import com.google.privacy.dlp.v2.FinishDlpJobRequest; +import com.google.privacy.dlp.v2.GetDeidentifyTemplateRequest; +import com.google.privacy.dlp.v2.GetDlpJobRequest; +import com.google.privacy.dlp.v2.GetInspectTemplateRequest; +import com.google.privacy.dlp.v2.GetJobTriggerRequest; +import com.google.privacy.dlp.v2.GetStoredInfoTypeRequest; +import com.google.privacy.dlp.v2.HybridInspectDlpJobRequest; +import com.google.privacy.dlp.v2.HybridInspectJobTriggerRequest; +import com.google.privacy.dlp.v2.HybridInspectResponse; +import com.google.privacy.dlp.v2.InspectContentRequest; +import com.google.privacy.dlp.v2.InspectContentResponse; +import com.google.privacy.dlp.v2.InspectTemplate; +import com.google.privacy.dlp.v2.JobTrigger; +import com.google.privacy.dlp.v2.ListDeidentifyTemplatesRequest; +import com.google.privacy.dlp.v2.ListDeidentifyTemplatesResponse; +import com.google.privacy.dlp.v2.ListDlpJobsRequest; +import com.google.privacy.dlp.v2.ListDlpJobsResponse; +import com.google.privacy.dlp.v2.ListInfoTypesRequest; +import com.google.privacy.dlp.v2.ListInfoTypesResponse; +import com.google.privacy.dlp.v2.ListInspectTemplatesRequest; +import com.google.privacy.dlp.v2.ListInspectTemplatesResponse; +import com.google.privacy.dlp.v2.ListJobTriggersRequest; +import com.google.privacy.dlp.v2.ListJobTriggersResponse; +import com.google.privacy.dlp.v2.ListStoredInfoTypesRequest; +import com.google.privacy.dlp.v2.ListStoredInfoTypesResponse; +import com.google.privacy.dlp.v2.RedactImageRequest; +import com.google.privacy.dlp.v2.RedactImageResponse; +import com.google.privacy.dlp.v2.ReidentifyContentRequest; +import com.google.privacy.dlp.v2.ReidentifyContentResponse; +import com.google.privacy.dlp.v2.StoredInfoType; +import com.google.privacy.dlp.v2.UpdateDeidentifyTemplateRequest; +import com.google.privacy.dlp.v2.UpdateInspectTemplateRequest; +import com.google.privacy.dlp.v2.UpdateJobTriggerRequest; +import com.google.privacy.dlp.v2.UpdateStoredInfoTypeRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the DlpService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDlpServiceStub extends DlpServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + inspectContentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/InspectContent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/content:inspect", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/content:inspect") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(InspectContentResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + redactImageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/RedactImage") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/image:redact", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/image:redact") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RedactImageResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deidentifyContentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/DeidentifyContent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/content:deidentify", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/content:deidentify") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DeidentifyContentResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + reidentifyContentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/ReidentifyContent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/content:reidentify", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/content:reidentify") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReidentifyContentResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listInfoTypesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/ListInfoTypes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/infoTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=locations/*}/infoTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + serializer.putQueryParam(fields, "locationId", request.getLocationId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInfoTypesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createInspectTemplateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/CreateInspectTemplate") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=organizations/*}/inspectTemplates", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=organizations/*/locations/*}/inspectTemplates", + "/v2/{parent=projects/*}/inspectTemplates", + "/v2/{parent=projects/*/locations/*}/inspectTemplates") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(InspectTemplate.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateInspectTemplateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/UpdateInspectTemplate") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=organizations/*/inspectTemplates/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=organizations/*/locations/*/inspectTemplates/*}", + "/v2/{name=projects/*/inspectTemplates/*}", + "/v2/{name=projects/*/locations/*/inspectTemplates/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(InspectTemplate.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInspectTemplateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/GetInspectTemplate") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=organizations/*/inspectTemplates/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=organizations/*/locations/*/inspectTemplates/*}", + "/v2/{name=projects/*/inspectTemplates/*}", + "/v2/{name=projects/*/locations/*/inspectTemplates/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(InspectTemplate.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListInspectTemplatesRequest, ListInspectTemplatesResponse> + listInspectTemplatesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/ListInspectTemplates") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=organizations/*}/inspectTemplates", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=organizations/*/locations/*}/inspectTemplates", + "/v2/{parent=projects/*}/inspectTemplates", + "/v2/{parent=projects/*/locations/*}/inspectTemplates") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "locationId", request.getLocationId()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInspectTemplatesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteInspectTemplateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/DeleteInspectTemplate") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=organizations/*/inspectTemplates/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=organizations/*/locations/*/inspectTemplates/*}", + "/v2/{name=projects/*/inspectTemplates/*}", + "/v2/{name=projects/*/locations/*/inspectTemplates/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDeidentifyTemplateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/CreateDeidentifyTemplate") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=organizations/*}/deidentifyTemplates", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=organizations/*/locations/*}/deidentifyTemplates", + "/v2/{parent=projects/*}/deidentifyTemplates", + "/v2/{parent=projects/*/locations/*}/deidentifyTemplates") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DeidentifyTemplate.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateDeidentifyTemplateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/UpdateDeidentifyTemplate") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=organizations/*/deidentifyTemplates/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=organizations/*/locations/*/deidentifyTemplates/*}", + "/v2/{name=projects/*/deidentifyTemplates/*}", + "/v2/{name=projects/*/locations/*/deidentifyTemplates/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DeidentifyTemplate.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDeidentifyTemplateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/GetDeidentifyTemplate") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=organizations/*/deidentifyTemplates/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=organizations/*/locations/*/deidentifyTemplates/*}", + "/v2/{name=projects/*/deidentifyTemplates/*}", + "/v2/{name=projects/*/locations/*/deidentifyTemplates/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DeidentifyTemplate.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListDeidentifyTemplatesRequest, ListDeidentifyTemplatesResponse> + listDeidentifyTemplatesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/ListDeidentifyTemplates") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=organizations/*}/deidentifyTemplates", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=organizations/*/locations/*}/deidentifyTemplates", + "/v2/{parent=projects/*}/deidentifyTemplates", + "/v2/{parent=projects/*/locations/*}/deidentifyTemplates") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "locationId", request.getLocationId()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDeidentifyTemplatesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteDeidentifyTemplateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/DeleteDeidentifyTemplate") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=organizations/*/deidentifyTemplates/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=organizations/*/locations/*/deidentifyTemplates/*}", + "/v2/{name=projects/*/deidentifyTemplates/*}", + "/v2/{name=projects/*/locations/*/deidentifyTemplates/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createJobTriggerMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/CreateJobTrigger") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/jobTriggers", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*}/jobTriggers", + "/v2/{parent=organizations/*/locations/*}/jobTriggers") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(JobTrigger.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateJobTriggerMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/UpdateJobTrigger") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/jobTriggers/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/jobTriggers/*}", + "/v2/{name=organizations/*/locations/*/jobTriggers/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(JobTrigger.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + hybridInspectJobTriggerMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/HybridInspectJobTrigger") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/locations/*/jobTriggers/*}:hybridInspect", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(HybridInspectResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getJobTriggerMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/GetJobTrigger") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/jobTriggers/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/jobTriggers/*}", + "/v2/{name=organizations/*/locations/*/jobTriggers/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(JobTrigger.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listJobTriggersMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/ListJobTriggers") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/jobTriggers", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*}/jobTriggers", + "/v2/{parent=organizations/*/locations/*}/jobTriggers") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "locationId", request.getLocationId()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "type", request.getType()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListJobTriggersResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteJobTriggerMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/DeleteJobTrigger") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/jobTriggers/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/jobTriggers/*}", + "/v2/{name=organizations/*/locations/*/jobTriggers/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + activateJobTriggerMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/ActivateJobTrigger") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/jobTriggers/*}:activate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/jobTriggers/*}:activate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DlpJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDlpJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/CreateDlpJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/dlpJobs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/dlpJobs") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DlpJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDlpJobsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/ListDlpJobs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/dlpJobs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*}/dlpJobs", + "/v2/{parent=organizations/*/locations/*}/dlpJobs") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "locationId", request.getLocationId()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "type", request.getType()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDlpJobsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getDlpJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/GetDlpJob") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/dlpJobs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/dlpJobs/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DlpJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteDlpJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/DeleteDlpJob") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/dlpJobs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/dlpJobs/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + cancelDlpJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/CancelDlpJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/dlpJobs/*}:cancel", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/dlpJobs/*}:cancel") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createStoredInfoTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/CreateStoredInfoType") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=organizations/*}/storedInfoTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=organizations/*/locations/*}/storedInfoTypes", + "/v2/{parent=projects/*}/storedInfoTypes", + "/v2/{parent=projects/*/locations/*}/storedInfoTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(StoredInfoType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateStoredInfoTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/UpdateStoredInfoType") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=organizations/*/storedInfoTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=organizations/*/locations/*/storedInfoTypes/*}", + "/v2/{name=projects/*/storedInfoTypes/*}", + "/v2/{name=projects/*/locations/*/storedInfoTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(StoredInfoType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getStoredInfoTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/GetStoredInfoType") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=organizations/*/storedInfoTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=organizations/*/locations/*/storedInfoTypes/*}", + "/v2/{name=projects/*/storedInfoTypes/*}", + "/v2/{name=projects/*/locations/*/storedInfoTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(StoredInfoType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listStoredInfoTypesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/ListStoredInfoTypes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=organizations/*}/storedInfoTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=organizations/*/locations/*}/storedInfoTypes", + "/v2/{parent=projects/*}/storedInfoTypes", + "/v2/{parent=projects/*/locations/*}/storedInfoTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "locationId", request.getLocationId()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListStoredInfoTypesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteStoredInfoTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/DeleteStoredInfoType") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=organizations/*/storedInfoTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=organizations/*/locations/*/storedInfoTypes/*}", + "/v2/{name=projects/*/storedInfoTypes/*}", + "/v2/{name=projects/*/locations/*/storedInfoTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + hybridInspectDlpJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/HybridInspectDlpJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/locations/*/dlpJobs/*}:hybridInspect", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(HybridInspectResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + finishDlpJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.privacy.dlp.v2.DlpService/FinishDlpJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/locations/*/dlpJobs/*}:finish", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable inspectContentCallable; + private final UnaryCallable redactImageCallable; + private final UnaryCallable + deidentifyContentCallable; + private final UnaryCallable + reidentifyContentCallable; + private final UnaryCallable listInfoTypesCallable; + private final UnaryCallable + createInspectTemplateCallable; + private final UnaryCallable + updateInspectTemplateCallable; + private final UnaryCallable + getInspectTemplateCallable; + private final UnaryCallable + listInspectTemplatesCallable; + private final UnaryCallable + listInspectTemplatesPagedCallable; + private final UnaryCallable deleteInspectTemplateCallable; + private final UnaryCallable + createDeidentifyTemplateCallable; + private final UnaryCallable + updateDeidentifyTemplateCallable; + private final UnaryCallable + getDeidentifyTemplateCallable; + private final UnaryCallable + listDeidentifyTemplatesCallable; + private final UnaryCallable + listDeidentifyTemplatesPagedCallable; + private final UnaryCallable + deleteDeidentifyTemplateCallable; + private final UnaryCallable createJobTriggerCallable; + private final UnaryCallable updateJobTriggerCallable; + private final UnaryCallable + hybridInspectJobTriggerCallable; + private final UnaryCallable getJobTriggerCallable; + private final UnaryCallable + listJobTriggersCallable; + private final UnaryCallable + listJobTriggersPagedCallable; + private final UnaryCallable deleteJobTriggerCallable; + private final UnaryCallable activateJobTriggerCallable; + private final UnaryCallable createDlpJobCallable; + private final UnaryCallable listDlpJobsCallable; + private final UnaryCallable + listDlpJobsPagedCallable; + private final UnaryCallable getDlpJobCallable; + private final UnaryCallable deleteDlpJobCallable; + private final UnaryCallable cancelDlpJobCallable; + private final UnaryCallable + createStoredInfoTypeCallable; + private final UnaryCallable + updateStoredInfoTypeCallable; + private final UnaryCallable getStoredInfoTypeCallable; + private final UnaryCallable + listStoredInfoTypesCallable; + private final UnaryCallable + listStoredInfoTypesPagedCallable; + private final UnaryCallable deleteStoredInfoTypeCallable; + private final UnaryCallable + hybridInspectDlpJobCallable; + private final UnaryCallable finishDlpJobCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDlpServiceStub create(DlpServiceStubSettings settings) + throws IOException { + return new HttpJsonDlpServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDlpServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDlpServiceStub( + DlpServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDlpServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDlpServiceStub( + DlpServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDlpServiceStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonDlpServiceStub(DlpServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDlpServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDlpServiceStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonDlpServiceStub( + DlpServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + inspectContentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(inspectContentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings redactImageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(redactImageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deidentifyContentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deidentifyContentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + reidentifyContentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(reidentifyContentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listInfoTypesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInfoTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createInspectTemplateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createInspectTemplateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateInspectTemplateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateInspectTemplateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getInspectTemplateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInspectTemplateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listInspectTemplatesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listInspectTemplatesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteInspectTemplateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteInspectTemplateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createDeidentifyTemplateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDeidentifyTemplateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateDeidentifyTemplateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDeidentifyTemplateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getDeidentifyTemplateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDeidentifyTemplateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listDeidentifyTemplatesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listDeidentifyTemplatesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteDeidentifyTemplateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDeidentifyTemplateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createJobTriggerTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createJobTriggerMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateJobTriggerTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateJobTriggerMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + hybridInspectJobTriggerTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(hybridInspectJobTriggerMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getJobTriggerTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getJobTriggerMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listJobTriggersTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listJobTriggersMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteJobTriggerTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteJobTriggerMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings activateJobTriggerTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(activateJobTriggerMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createDlpJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDlpJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listDlpJobsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDlpJobsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getDlpJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDlpJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteDlpJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDlpJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings cancelDlpJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(cancelDlpJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createStoredInfoTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createStoredInfoTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateStoredInfoTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateStoredInfoTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getStoredInfoTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getStoredInfoTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listStoredInfoTypesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listStoredInfoTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteStoredInfoTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteStoredInfoTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + hybridInspectDlpJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(hybridInspectDlpJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings finishDlpJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(finishDlpJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.inspectContentCallable = + callableFactory.createUnaryCallable( + inspectContentTransportSettings, settings.inspectContentSettings(), clientContext); + this.redactImageCallable = + callableFactory.createUnaryCallable( + redactImageTransportSettings, settings.redactImageSettings(), clientContext); + this.deidentifyContentCallable = + callableFactory.createUnaryCallable( + deidentifyContentTransportSettings, + settings.deidentifyContentSettings(), + clientContext); + this.reidentifyContentCallable = + callableFactory.createUnaryCallable( + reidentifyContentTransportSettings, + settings.reidentifyContentSettings(), + clientContext); + this.listInfoTypesCallable = + callableFactory.createUnaryCallable( + listInfoTypesTransportSettings, settings.listInfoTypesSettings(), clientContext); + this.createInspectTemplateCallable = + callableFactory.createUnaryCallable( + createInspectTemplateTransportSettings, + settings.createInspectTemplateSettings(), + clientContext); + this.updateInspectTemplateCallable = + callableFactory.createUnaryCallable( + updateInspectTemplateTransportSettings, + settings.updateInspectTemplateSettings(), + clientContext); + this.getInspectTemplateCallable = + callableFactory.createUnaryCallable( + getInspectTemplateTransportSettings, + settings.getInspectTemplateSettings(), + clientContext); + this.listInspectTemplatesCallable = + callableFactory.createUnaryCallable( + listInspectTemplatesTransportSettings, + settings.listInspectTemplatesSettings(), + clientContext); + this.listInspectTemplatesPagedCallable = + callableFactory.createPagedCallable( + listInspectTemplatesTransportSettings, + settings.listInspectTemplatesSettings(), + clientContext); + this.deleteInspectTemplateCallable = + callableFactory.createUnaryCallable( + deleteInspectTemplateTransportSettings, + settings.deleteInspectTemplateSettings(), + clientContext); + this.createDeidentifyTemplateCallable = + callableFactory.createUnaryCallable( + createDeidentifyTemplateTransportSettings, + settings.createDeidentifyTemplateSettings(), + clientContext); + this.updateDeidentifyTemplateCallable = + callableFactory.createUnaryCallable( + updateDeidentifyTemplateTransportSettings, + settings.updateDeidentifyTemplateSettings(), + clientContext); + this.getDeidentifyTemplateCallable = + callableFactory.createUnaryCallable( + getDeidentifyTemplateTransportSettings, + settings.getDeidentifyTemplateSettings(), + clientContext); + this.listDeidentifyTemplatesCallable = + callableFactory.createUnaryCallable( + listDeidentifyTemplatesTransportSettings, + settings.listDeidentifyTemplatesSettings(), + clientContext); + this.listDeidentifyTemplatesPagedCallable = + callableFactory.createPagedCallable( + listDeidentifyTemplatesTransportSettings, + settings.listDeidentifyTemplatesSettings(), + clientContext); + this.deleteDeidentifyTemplateCallable = + callableFactory.createUnaryCallable( + deleteDeidentifyTemplateTransportSettings, + settings.deleteDeidentifyTemplateSettings(), + clientContext); + this.createJobTriggerCallable = + callableFactory.createUnaryCallable( + createJobTriggerTransportSettings, settings.createJobTriggerSettings(), clientContext); + this.updateJobTriggerCallable = + callableFactory.createUnaryCallable( + updateJobTriggerTransportSettings, settings.updateJobTriggerSettings(), clientContext); + this.hybridInspectJobTriggerCallable = + callableFactory.createUnaryCallable( + hybridInspectJobTriggerTransportSettings, + settings.hybridInspectJobTriggerSettings(), + clientContext); + this.getJobTriggerCallable = + callableFactory.createUnaryCallable( + getJobTriggerTransportSettings, settings.getJobTriggerSettings(), clientContext); + this.listJobTriggersCallable = + callableFactory.createUnaryCallable( + listJobTriggersTransportSettings, settings.listJobTriggersSettings(), clientContext); + this.listJobTriggersPagedCallable = + callableFactory.createPagedCallable( + listJobTriggersTransportSettings, settings.listJobTriggersSettings(), clientContext); + this.deleteJobTriggerCallable = + callableFactory.createUnaryCallable( + deleteJobTriggerTransportSettings, settings.deleteJobTriggerSettings(), clientContext); + this.activateJobTriggerCallable = + callableFactory.createUnaryCallable( + activateJobTriggerTransportSettings, + settings.activateJobTriggerSettings(), + clientContext); + this.createDlpJobCallable = + callableFactory.createUnaryCallable( + createDlpJobTransportSettings, settings.createDlpJobSettings(), clientContext); + this.listDlpJobsCallable = + callableFactory.createUnaryCallable( + listDlpJobsTransportSettings, settings.listDlpJobsSettings(), clientContext); + this.listDlpJobsPagedCallable = + callableFactory.createPagedCallable( + listDlpJobsTransportSettings, settings.listDlpJobsSettings(), clientContext); + this.getDlpJobCallable = + callableFactory.createUnaryCallable( + getDlpJobTransportSettings, settings.getDlpJobSettings(), clientContext); + this.deleteDlpJobCallable = + callableFactory.createUnaryCallable( + deleteDlpJobTransportSettings, settings.deleteDlpJobSettings(), clientContext); + this.cancelDlpJobCallable = + callableFactory.createUnaryCallable( + cancelDlpJobTransportSettings, settings.cancelDlpJobSettings(), clientContext); + this.createStoredInfoTypeCallable = + callableFactory.createUnaryCallable( + createStoredInfoTypeTransportSettings, + settings.createStoredInfoTypeSettings(), + clientContext); + this.updateStoredInfoTypeCallable = + callableFactory.createUnaryCallable( + updateStoredInfoTypeTransportSettings, + settings.updateStoredInfoTypeSettings(), + clientContext); + this.getStoredInfoTypeCallable = + callableFactory.createUnaryCallable( + getStoredInfoTypeTransportSettings, + settings.getStoredInfoTypeSettings(), + clientContext); + this.listStoredInfoTypesCallable = + callableFactory.createUnaryCallable( + listStoredInfoTypesTransportSettings, + settings.listStoredInfoTypesSettings(), + clientContext); + this.listStoredInfoTypesPagedCallable = + callableFactory.createPagedCallable( + listStoredInfoTypesTransportSettings, + settings.listStoredInfoTypesSettings(), + clientContext); + this.deleteStoredInfoTypeCallable = + callableFactory.createUnaryCallable( + deleteStoredInfoTypeTransportSettings, + settings.deleteStoredInfoTypeSettings(), + clientContext); + this.hybridInspectDlpJobCallable = + callableFactory.createUnaryCallable( + hybridInspectDlpJobTransportSettings, + settings.hybridInspectDlpJobSettings(), + clientContext); + this.finishDlpJobCallable = + callableFactory.createUnaryCallable( + finishDlpJobTransportSettings, settings.finishDlpJobSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(inspectContentMethodDescriptor); + methodDescriptors.add(redactImageMethodDescriptor); + methodDescriptors.add(deidentifyContentMethodDescriptor); + methodDescriptors.add(reidentifyContentMethodDescriptor); + methodDescriptors.add(listInfoTypesMethodDescriptor); + methodDescriptors.add(createInspectTemplateMethodDescriptor); + methodDescriptors.add(updateInspectTemplateMethodDescriptor); + methodDescriptors.add(getInspectTemplateMethodDescriptor); + methodDescriptors.add(listInspectTemplatesMethodDescriptor); + methodDescriptors.add(deleteInspectTemplateMethodDescriptor); + methodDescriptors.add(createDeidentifyTemplateMethodDescriptor); + methodDescriptors.add(updateDeidentifyTemplateMethodDescriptor); + methodDescriptors.add(getDeidentifyTemplateMethodDescriptor); + methodDescriptors.add(listDeidentifyTemplatesMethodDescriptor); + methodDescriptors.add(deleteDeidentifyTemplateMethodDescriptor); + methodDescriptors.add(createJobTriggerMethodDescriptor); + methodDescriptors.add(updateJobTriggerMethodDescriptor); + methodDescriptors.add(hybridInspectJobTriggerMethodDescriptor); + methodDescriptors.add(getJobTriggerMethodDescriptor); + methodDescriptors.add(listJobTriggersMethodDescriptor); + methodDescriptors.add(deleteJobTriggerMethodDescriptor); + methodDescriptors.add(activateJobTriggerMethodDescriptor); + methodDescriptors.add(createDlpJobMethodDescriptor); + methodDescriptors.add(listDlpJobsMethodDescriptor); + methodDescriptors.add(getDlpJobMethodDescriptor); + methodDescriptors.add(deleteDlpJobMethodDescriptor); + methodDescriptors.add(cancelDlpJobMethodDescriptor); + methodDescriptors.add(createStoredInfoTypeMethodDescriptor); + methodDescriptors.add(updateStoredInfoTypeMethodDescriptor); + methodDescriptors.add(getStoredInfoTypeMethodDescriptor); + methodDescriptors.add(listStoredInfoTypesMethodDescriptor); + methodDescriptors.add(deleteStoredInfoTypeMethodDescriptor); + methodDescriptors.add(hybridInspectDlpJobMethodDescriptor); + methodDescriptors.add(finishDlpJobMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable inspectContentCallable() { + return inspectContentCallable; + } + + @Override + public UnaryCallable redactImageCallable() { + return redactImageCallable; + } + + @Override + public UnaryCallable + deidentifyContentCallable() { + return deidentifyContentCallable; + } + + @Override + public UnaryCallable + reidentifyContentCallable() { + return reidentifyContentCallable; + } + + @Override + public UnaryCallable listInfoTypesCallable() { + return listInfoTypesCallable; + } + + @Override + public UnaryCallable + createInspectTemplateCallable() { + return createInspectTemplateCallable; + } + + @Override + public UnaryCallable + updateInspectTemplateCallable() { + return updateInspectTemplateCallable; + } + + @Override + public UnaryCallable getInspectTemplateCallable() { + return getInspectTemplateCallable; + } + + @Override + public UnaryCallable + listInspectTemplatesCallable() { + return listInspectTemplatesCallable; + } + + @Override + public UnaryCallable + listInspectTemplatesPagedCallable() { + return listInspectTemplatesPagedCallable; + } + + @Override + public UnaryCallable deleteInspectTemplateCallable() { + return deleteInspectTemplateCallable; + } + + @Override + public UnaryCallable + createDeidentifyTemplateCallable() { + return createDeidentifyTemplateCallable; + } + + @Override + public UnaryCallable + updateDeidentifyTemplateCallable() { + return updateDeidentifyTemplateCallable; + } + + @Override + public UnaryCallable + getDeidentifyTemplateCallable() { + return getDeidentifyTemplateCallable; + } + + @Override + public UnaryCallable + listDeidentifyTemplatesCallable() { + return listDeidentifyTemplatesCallable; + } + + @Override + public UnaryCallable + listDeidentifyTemplatesPagedCallable() { + return listDeidentifyTemplatesPagedCallable; + } + + @Override + public UnaryCallable deleteDeidentifyTemplateCallable() { + return deleteDeidentifyTemplateCallable; + } + + @Override + public UnaryCallable createJobTriggerCallable() { + return createJobTriggerCallable; + } + + @Override + public UnaryCallable updateJobTriggerCallable() { + return updateJobTriggerCallable; + } + + @Override + public UnaryCallable + hybridInspectJobTriggerCallable() { + return hybridInspectJobTriggerCallable; + } + + @Override + public UnaryCallable getJobTriggerCallable() { + return getJobTriggerCallable; + } + + @Override + public UnaryCallable listJobTriggersCallable() { + return listJobTriggersCallable; + } + + @Override + public UnaryCallable + listJobTriggersPagedCallable() { + return listJobTriggersPagedCallable; + } + + @Override + public UnaryCallable deleteJobTriggerCallable() { + return deleteJobTriggerCallable; + } + + @Override + public UnaryCallable activateJobTriggerCallable() { + return activateJobTriggerCallable; + } + + @Override + public UnaryCallable createDlpJobCallable() { + return createDlpJobCallable; + } + + @Override + public UnaryCallable listDlpJobsCallable() { + return listDlpJobsCallable; + } + + @Override + public UnaryCallable listDlpJobsPagedCallable() { + return listDlpJobsPagedCallable; + } + + @Override + public UnaryCallable getDlpJobCallable() { + return getDlpJobCallable; + } + + @Override + public UnaryCallable deleteDlpJobCallable() { + return deleteDlpJobCallable; + } + + @Override + public UnaryCallable cancelDlpJobCallable() { + return cancelDlpJobCallable; + } + + @Override + public UnaryCallable createStoredInfoTypeCallable() { + return createStoredInfoTypeCallable; + } + + @Override + public UnaryCallable updateStoredInfoTypeCallable() { + return updateStoredInfoTypeCallable; + } + + @Override + public UnaryCallable getStoredInfoTypeCallable() { + return getStoredInfoTypeCallable; + } + + @Override + public UnaryCallable + listStoredInfoTypesCallable() { + return listStoredInfoTypesCallable; + } + + @Override + public UnaryCallable + listStoredInfoTypesPagedCallable() { + return listStoredInfoTypesPagedCallable; + } + + @Override + public UnaryCallable deleteStoredInfoTypeCallable() { + return deleteStoredInfoTypeCallable; + } + + @Override + public UnaryCallable + hybridInspectDlpJobCallable() { + return hybridInspectDlpJobCallable; + } + + @Override + public UnaryCallable finishDlpJobCallable() { + return finishDlpJobCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-dlp/src/test/java/com/google/cloud/dlp/v2/DlpServiceClientHttpJsonTest.java b/google-cloud-dlp/src/test/java/com/google/cloud/dlp/v2/DlpServiceClientHttpJsonTest.java new file mode 100644 index 00000000..deeff4d3 --- /dev/null +++ b/google-cloud-dlp/src/test/java/com/google/cloud/dlp/v2/DlpServiceClientHttpJsonTest.java @@ -0,0 +1,4449 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.dlp.v2; + +import static com.google.cloud.dlp.v2.DlpServiceClient.ListDeidentifyTemplatesPagedResponse; +import static com.google.cloud.dlp.v2.DlpServiceClient.ListDlpJobsPagedResponse; +import static com.google.cloud.dlp.v2.DlpServiceClient.ListInspectTemplatesPagedResponse; +import static com.google.cloud.dlp.v2.DlpServiceClient.ListJobTriggersPagedResponse; +import static com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dlp.v2.stub.HttpJsonDlpServiceStub; +import com.google.common.collect.Lists; +import com.google.privacy.dlp.v2.ActivateJobTriggerRequest; +import com.google.privacy.dlp.v2.ByteContentItem; +import com.google.privacy.dlp.v2.CancelDlpJobRequest; +import com.google.privacy.dlp.v2.ContentItem; +import com.google.privacy.dlp.v2.DeidentifyConfig; +import com.google.privacy.dlp.v2.DeidentifyContentRequest; +import com.google.privacy.dlp.v2.DeidentifyContentResponse; +import com.google.privacy.dlp.v2.DeidentifyTemplate; +import com.google.privacy.dlp.v2.DeidentifyTemplateName; +import com.google.privacy.dlp.v2.DlpJob; +import com.google.privacy.dlp.v2.DlpJobName; +import com.google.privacy.dlp.v2.DlpJobType; +import com.google.privacy.dlp.v2.Error; +import com.google.privacy.dlp.v2.FinishDlpJobRequest; +import com.google.privacy.dlp.v2.HybridInspectResponse; +import com.google.privacy.dlp.v2.InfoTypeDescription; +import com.google.privacy.dlp.v2.InspectConfig; +import com.google.privacy.dlp.v2.InspectContentRequest; +import com.google.privacy.dlp.v2.InspectContentResponse; +import com.google.privacy.dlp.v2.InspectJobConfig; +import com.google.privacy.dlp.v2.InspectResult; +import com.google.privacy.dlp.v2.InspectTemplate; +import com.google.privacy.dlp.v2.InspectTemplateName; +import com.google.privacy.dlp.v2.JobTrigger; +import com.google.privacy.dlp.v2.JobTriggerName; +import com.google.privacy.dlp.v2.ListDeidentifyTemplatesResponse; +import com.google.privacy.dlp.v2.ListDlpJobsResponse; +import com.google.privacy.dlp.v2.ListInfoTypesResponse; +import com.google.privacy.dlp.v2.ListInspectTemplatesResponse; +import com.google.privacy.dlp.v2.ListJobTriggersResponse; +import com.google.privacy.dlp.v2.ListStoredInfoTypesResponse; +import com.google.privacy.dlp.v2.LocationName; +import com.google.privacy.dlp.v2.OrganizationLocationName; +import com.google.privacy.dlp.v2.OrganizationName; +import com.google.privacy.dlp.v2.ProjectName; +import com.google.privacy.dlp.v2.RedactImageRequest; +import com.google.privacy.dlp.v2.RedactImageResponse; +import com.google.privacy.dlp.v2.ReidentifyContentRequest; +import com.google.privacy.dlp.v2.ReidentifyContentResponse; +import com.google.privacy.dlp.v2.RiskAnalysisJobConfig; +import com.google.privacy.dlp.v2.StoredInfoType; +import com.google.privacy.dlp.v2.StoredInfoTypeConfig; +import com.google.privacy.dlp.v2.StoredInfoTypeName; +import com.google.privacy.dlp.v2.StoredInfoTypeVersion; +import com.google.privacy.dlp.v2.TransformationOverview; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DlpServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static DlpServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDlpServiceStub.getMethodDescriptors(), DlpServiceSettings.getDefaultEndpoint()); + DlpServiceSettings settings = + DlpServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DlpServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DlpServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void inspectContentTest() throws Exception { + InspectContentResponse expectedResponse = + InspectContentResponse.newBuilder().setResult(InspectResult.newBuilder().build()).build(); + mockService.addResponse(expectedResponse); + + InspectContentRequest request = + InspectContentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .setItem(ContentItem.newBuilder().build()) + .setInspectTemplateName("inspectTemplateName1828857433") + .setLocationId("locationId1541836720") + .build(); + + InspectContentResponse actualResponse = client.inspectContent(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void inspectContentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InspectContentRequest request = + InspectContentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .setItem(ContentItem.newBuilder().build()) + .setInspectTemplateName("inspectTemplateName1828857433") + .setLocationId("locationId1541836720") + .build(); + client.inspectContent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void redactImageTest() throws Exception { + RedactImageResponse expectedResponse = + RedactImageResponse.newBuilder() + .setRedactedImage(ByteString.EMPTY) + .setExtractedText("extractedText-106686931") + .setInspectResult(InspectResult.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + RedactImageRequest request = + RedactImageRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLocationId("locationId1541836720") + .setInspectConfig(InspectConfig.newBuilder().build()) + .addAllImageRedactionConfigs(new ArrayList()) + .setIncludeFindings(true) + .setByteItem(ByteContentItem.newBuilder().build()) + .build(); + + RedactImageResponse actualResponse = client.redactImage(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void redactImageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RedactImageRequest request = + RedactImageRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLocationId("locationId1541836720") + .setInspectConfig(InspectConfig.newBuilder().build()) + .addAllImageRedactionConfigs(new ArrayList()) + .setIncludeFindings(true) + .setByteItem(ByteContentItem.newBuilder().build()) + .build(); + client.redactImage(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deidentifyContentTest() throws Exception { + DeidentifyContentResponse expectedResponse = + DeidentifyContentResponse.newBuilder() + .setItem(ContentItem.newBuilder().build()) + .setOverview(TransformationOverview.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + DeidentifyContentRequest request = + DeidentifyContentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .setItem(ContentItem.newBuilder().build()) + .setInspectTemplateName("inspectTemplateName1828857433") + .setDeidentifyTemplateName("deidentifyTemplateName-1374666414") + .setLocationId("locationId1541836720") + .build(); + + DeidentifyContentResponse actualResponse = client.deidentifyContent(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deidentifyContentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeidentifyContentRequest request = + DeidentifyContentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .setItem(ContentItem.newBuilder().build()) + .setInspectTemplateName("inspectTemplateName1828857433") + .setDeidentifyTemplateName("deidentifyTemplateName-1374666414") + .setLocationId("locationId1541836720") + .build(); + client.deidentifyContent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void reidentifyContentTest() throws Exception { + ReidentifyContentResponse expectedResponse = + ReidentifyContentResponse.newBuilder() + .setItem(ContentItem.newBuilder().build()) + .setOverview(TransformationOverview.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ReidentifyContentRequest request = + ReidentifyContentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setReidentifyConfig(DeidentifyConfig.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .setItem(ContentItem.newBuilder().build()) + .setInspectTemplateName("inspectTemplateName1828857433") + .setReidentifyTemplateName("reidentifyTemplateName157316612") + .setLocationId("locationId1541836720") + .build(); + + ReidentifyContentResponse actualResponse = client.reidentifyContent(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reidentifyContentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReidentifyContentRequest request = + ReidentifyContentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setReidentifyConfig(DeidentifyConfig.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .setItem(ContentItem.newBuilder().build()) + .setInspectTemplateName("inspectTemplateName1828857433") + .setReidentifyTemplateName("reidentifyTemplateName157316612") + .setLocationId("locationId1541836720") + .build(); + client.reidentifyContent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInfoTypesTest() throws Exception { + ListInfoTypesResponse expectedResponse = + ListInfoTypesResponse.newBuilder() + .addAllInfoTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListInfoTypesResponse actualResponse = client.listInfoTypes(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listInfoTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "parent-995424086"; + client.listInfoTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createInspectTemplateTest() throws Exception { + InspectTemplate expectedResponse = + InspectTemplate.newBuilder() + .setName( + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + + InspectTemplate actualResponse = client.createInspectTemplate(parent, inspectTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInspectTemplateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + client.createInspectTemplate(parent, inspectTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createInspectTemplateTest2() throws Exception { + InspectTemplate expectedResponse = + InspectTemplate.newBuilder() + .setName( + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + + InspectTemplate actualResponse = client.createInspectTemplate(parent, inspectTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInspectTemplateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + client.createInspectTemplate(parent, inspectTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createInspectTemplateTest3() throws Exception { + InspectTemplate expectedResponse = + InspectTemplate.newBuilder() + .setName( + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + + InspectTemplate actualResponse = client.createInspectTemplate(parent, inspectTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInspectTemplateExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + client.createInspectTemplate(parent, inspectTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createInspectTemplateTest4() throws Exception { + InspectTemplate expectedResponse = + InspectTemplate.newBuilder() + .setName( + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + + InspectTemplate actualResponse = client.createInspectTemplate(parent, inspectTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInspectTemplateExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + client.createInspectTemplate(parent, inspectTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createInspectTemplateTest5() throws Exception { + InspectTemplate expectedResponse = + InspectTemplate.newBuilder() + .setName( + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + + InspectTemplate actualResponse = client.createInspectTemplate(parent, inspectTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInspectTemplateExceptionTest5() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + client.createInspectTemplate(parent, inspectTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateInspectTemplateTest() throws Exception { + InspectTemplate expectedResponse = + InspectTemplate.newBuilder() + .setName( + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InspectTemplateName name = + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + InspectTemplate actualResponse = + client.updateInspectTemplate(name, inspectTemplate, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateInspectTemplateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InspectTemplateName name = + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]"); + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateInspectTemplate(name, inspectTemplate, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateInspectTemplateTest2() throws Exception { + InspectTemplate expectedResponse = + InspectTemplate.newBuilder() + .setName( + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-353/inspectTemplates/inspectTemplate-353"; + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + InspectTemplate actualResponse = + client.updateInspectTemplate(name, inspectTemplate, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateInspectTemplateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-353/inspectTemplates/inspectTemplate-353"; + InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateInspectTemplate(name, inspectTemplate, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInspectTemplateTest() throws Exception { + InspectTemplate expectedResponse = + InspectTemplate.newBuilder() + .setName( + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InspectTemplateName name = + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]"); + + InspectTemplate actualResponse = client.getInspectTemplate(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getInspectTemplateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InspectTemplateName name = + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]"); + client.getInspectTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInspectTemplateTest2() throws Exception { + InspectTemplate expectedResponse = + InspectTemplate.newBuilder() + .setName( + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInspectConfig(InspectConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-353/inspectTemplates/inspectTemplate-353"; + + InspectTemplate actualResponse = client.getInspectTemplate(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getInspectTemplateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-353/inspectTemplates/inspectTemplate-353"; + client.getInspectTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInspectTemplatesTest() throws Exception { + InspectTemplate responsesElement = InspectTemplate.newBuilder().build(); + ListInspectTemplatesResponse expectedResponse = + ListInspectTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllInspectTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListInspectTemplatesPagedResponse pagedListResponse = client.listInspectTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInspectTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listInspectTemplatesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listInspectTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInspectTemplatesTest2() throws Exception { + InspectTemplate responsesElement = InspectTemplate.newBuilder().build(); + ListInspectTemplatesResponse expectedResponse = + ListInspectTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllInspectTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + + ListInspectTemplatesPagedResponse pagedListResponse = client.listInspectTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInspectTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listInspectTemplatesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + client.listInspectTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInspectTemplatesTest3() throws Exception { + InspectTemplate responsesElement = InspectTemplate.newBuilder().build(); + ListInspectTemplatesResponse expectedResponse = + ListInspectTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllInspectTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListInspectTemplatesPagedResponse pagedListResponse = client.listInspectTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInspectTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listInspectTemplatesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listInspectTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInspectTemplatesTest4() throws Exception { + InspectTemplate responsesElement = InspectTemplate.newBuilder().build(); + ListInspectTemplatesResponse expectedResponse = + ListInspectTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllInspectTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListInspectTemplatesPagedResponse pagedListResponse = client.listInspectTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInspectTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listInspectTemplatesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listInspectTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInspectTemplatesTest5() throws Exception { + InspectTemplate responsesElement = InspectTemplate.newBuilder().build(); + ListInspectTemplatesResponse expectedResponse = + ListInspectTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllInspectTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListInspectTemplatesPagedResponse pagedListResponse = client.listInspectTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInspectTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listInspectTemplatesExceptionTest5() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listInspectTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteInspectTemplateTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + InspectTemplateName name = + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]"); + + client.deleteInspectTemplate(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteInspectTemplateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InspectTemplateName name = + InspectTemplateName.ofOrganizationInspectTemplateName( + "[ORGANIZATION]", "[INSPECT_TEMPLATE]"); + client.deleteInspectTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteInspectTemplateTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-353/inspectTemplates/inspectTemplate-353"; + + client.deleteInspectTemplate(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteInspectTemplateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-353/inspectTemplates/inspectTemplate-353"; + client.deleteInspectTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeidentifyTemplateTest() throws Exception { + DeidentifyTemplate expectedResponse = + DeidentifyTemplate.newBuilder() + .setName( + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + + DeidentifyTemplate actualResponse = client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDeidentifyTemplateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeidentifyTemplateTest2() throws Exception { + DeidentifyTemplate expectedResponse = + DeidentifyTemplate.newBuilder() + .setName( + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + + DeidentifyTemplate actualResponse = client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDeidentifyTemplateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeidentifyTemplateTest3() throws Exception { + DeidentifyTemplate expectedResponse = + DeidentifyTemplate.newBuilder() + .setName( + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + + DeidentifyTemplate actualResponse = client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDeidentifyTemplateExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeidentifyTemplateTest4() throws Exception { + DeidentifyTemplate expectedResponse = + DeidentifyTemplate.newBuilder() + .setName( + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + + DeidentifyTemplate actualResponse = client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDeidentifyTemplateExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeidentifyTemplateTest5() throws Exception { + DeidentifyTemplate expectedResponse = + DeidentifyTemplate.newBuilder() + .setName( + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + + DeidentifyTemplate actualResponse = client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDeidentifyTemplateExceptionTest5() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + client.createDeidentifyTemplate(parent, deidentifyTemplate); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDeidentifyTemplateTest() throws Exception { + DeidentifyTemplate expectedResponse = + DeidentifyTemplate.newBuilder() + .setName( + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + DeidentifyTemplateName name = + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + DeidentifyTemplate actualResponse = + client.updateDeidentifyTemplate(name, deidentifyTemplate, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDeidentifyTemplateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeidentifyTemplateName name = + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]"); + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDeidentifyTemplate(name, deidentifyTemplate, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDeidentifyTemplateTest2() throws Exception { + DeidentifyTemplate expectedResponse = + DeidentifyTemplate.newBuilder() + .setName( + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-136/deidentifyTemplates/deidentifyTemplate-136"; + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + DeidentifyTemplate actualResponse = + client.updateDeidentifyTemplate(name, deidentifyTemplate, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDeidentifyTemplateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-136/deidentifyTemplates/deidentifyTemplate-136"; + DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDeidentifyTemplate(name, deidentifyTemplate, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeidentifyTemplateTest() throws Exception { + DeidentifyTemplate expectedResponse = + DeidentifyTemplate.newBuilder() + .setName( + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + DeidentifyTemplateName name = + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]"); + + DeidentifyTemplate actualResponse = client.getDeidentifyTemplate(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDeidentifyTemplateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeidentifyTemplateName name = + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]"); + client.getDeidentifyTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeidentifyTemplateTest2() throws Exception { + DeidentifyTemplate expectedResponse = + DeidentifyTemplate.newBuilder() + .setName( + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeidentifyConfig(DeidentifyConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-136/deidentifyTemplates/deidentifyTemplate-136"; + + DeidentifyTemplate actualResponse = client.getDeidentifyTemplate(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDeidentifyTemplateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-136/deidentifyTemplates/deidentifyTemplate-136"; + client.getDeidentifyTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeidentifyTemplatesTest() throws Exception { + DeidentifyTemplate responsesElement = DeidentifyTemplate.newBuilder().build(); + ListDeidentifyTemplatesResponse expectedResponse = + ListDeidentifyTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllDeidentifyTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListDeidentifyTemplatesPagedResponse pagedListResponse = client.listDeidentifyTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeidentifyTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeidentifyTemplatesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listDeidentifyTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeidentifyTemplatesTest2() throws Exception { + DeidentifyTemplate responsesElement = DeidentifyTemplate.newBuilder().build(); + ListDeidentifyTemplatesResponse expectedResponse = + ListDeidentifyTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllDeidentifyTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + + ListDeidentifyTemplatesPagedResponse pagedListResponse = client.listDeidentifyTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeidentifyTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeidentifyTemplatesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + client.listDeidentifyTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeidentifyTemplatesTest3() throws Exception { + DeidentifyTemplate responsesElement = DeidentifyTemplate.newBuilder().build(); + ListDeidentifyTemplatesResponse expectedResponse = + ListDeidentifyTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllDeidentifyTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListDeidentifyTemplatesPagedResponse pagedListResponse = client.listDeidentifyTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeidentifyTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeidentifyTemplatesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listDeidentifyTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeidentifyTemplatesTest4() throws Exception { + DeidentifyTemplate responsesElement = DeidentifyTemplate.newBuilder().build(); + ListDeidentifyTemplatesResponse expectedResponse = + ListDeidentifyTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllDeidentifyTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListDeidentifyTemplatesPagedResponse pagedListResponse = client.listDeidentifyTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeidentifyTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeidentifyTemplatesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listDeidentifyTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeidentifyTemplatesTest5() throws Exception { + DeidentifyTemplate responsesElement = DeidentifyTemplate.newBuilder().build(); + ListDeidentifyTemplatesResponse expectedResponse = + ListDeidentifyTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllDeidentifyTemplates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListDeidentifyTemplatesPagedResponse pagedListResponse = client.listDeidentifyTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeidentifyTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeidentifyTemplatesExceptionTest5() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listDeidentifyTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDeidentifyTemplateTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeidentifyTemplateName name = + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]"); + + client.deleteDeidentifyTemplate(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDeidentifyTemplateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeidentifyTemplateName name = + DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName( + "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]"); + client.deleteDeidentifyTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDeidentifyTemplateTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-136/deidentifyTemplates/deidentifyTemplate-136"; + + client.deleteDeidentifyTemplate(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDeidentifyTemplateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-136/deidentifyTemplates/deidentifyTemplate-136"; + client.deleteDeidentifyTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTriggerTest() throws Exception { + JobTrigger expectedResponse = + JobTrigger.newBuilder() + .setName( + JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllTriggers(new ArrayList()) + .addAllErrors(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + + JobTrigger actualResponse = client.createJobTrigger(parent, jobTrigger); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createJobTriggerExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + client.createJobTrigger(parent, jobTrigger); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTriggerTest2() throws Exception { + JobTrigger expectedResponse = + JobTrigger.newBuilder() + .setName( + JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllTriggers(new ArrayList()) + .addAllErrors(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + + JobTrigger actualResponse = client.createJobTrigger(parent, jobTrigger); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createJobTriggerExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + client.createJobTrigger(parent, jobTrigger); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTriggerTest3() throws Exception { + JobTrigger expectedResponse = + JobTrigger.newBuilder() + .setName( + JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllTriggers(new ArrayList()) + .addAllErrors(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + + JobTrigger actualResponse = client.createJobTrigger(parent, jobTrigger); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createJobTriggerExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + client.createJobTrigger(parent, jobTrigger); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateJobTriggerTest() throws Exception { + JobTrigger expectedResponse = + JobTrigger.newBuilder() + .setName( + JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllTriggers(new ArrayList()) + .addAllErrors(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]"); + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + JobTrigger actualResponse = client.updateJobTrigger(name, jobTrigger, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateJobTriggerExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]"); + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateJobTrigger(name, jobTrigger, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateJobTriggerTest2() throws Exception { + JobTrigger expectedResponse = + JobTrigger.newBuilder() + .setName( + JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllTriggers(new ArrayList()) + .addAllErrors(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2172/jobTriggers/jobTrigger-2172"; + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + JobTrigger actualResponse = client.updateJobTrigger(name, jobTrigger, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateJobTriggerExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2172/jobTriggers/jobTrigger-2172"; + JobTrigger jobTrigger = JobTrigger.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateJobTrigger(name, jobTrigger, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void hybridInspectJobTriggerTest() throws Exception { + HybridInspectResponse expectedResponse = HybridInspectResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + JobTriggerName name = + JobTriggerName.ofProjectLocationJobTriggerName("[PROJECT]", "[LOCATION]", "[JOB_TRIGGER]"); + + HybridInspectResponse actualResponse = client.hybridInspectJobTrigger(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void hybridInspectJobTriggerExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobTriggerName name = + JobTriggerName.ofProjectLocationJobTriggerName( + "[PROJECT]", "[LOCATION]", "[JOB_TRIGGER]"); + client.hybridInspectJobTrigger(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void hybridInspectJobTriggerTest2() throws Exception { + HybridInspectResponse expectedResponse = HybridInspectResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-6030/locations/location-6030/jobTriggers/jobTrigger-6030"; + + HybridInspectResponse actualResponse = client.hybridInspectJobTrigger(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void hybridInspectJobTriggerExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-6030/locations/location-6030/jobTriggers/jobTrigger-6030"; + client.hybridInspectJobTrigger(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTriggerTest() throws Exception { + JobTrigger expectedResponse = + JobTrigger.newBuilder() + .setName( + JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllTriggers(new ArrayList()) + .addAllErrors(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]"); + + JobTrigger actualResponse = client.getJobTrigger(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getJobTriggerExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]"); + client.getJobTrigger(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTriggerTest2() throws Exception { + JobTrigger expectedResponse = + JobTrigger.newBuilder() + .setName( + JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllTriggers(new ArrayList()) + .addAllErrors(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2172/jobTriggers/jobTrigger-2172"; + + JobTrigger actualResponse = client.getJobTrigger(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getJobTriggerExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2172/jobTriggers/jobTrigger-2172"; + client.getJobTrigger(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listJobTriggersTest() throws Exception { + JobTrigger responsesElement = JobTrigger.newBuilder().build(); + ListJobTriggersResponse expectedResponse = + ListJobTriggersResponse.newBuilder() + .setNextPageToken("") + .addAllJobTriggers(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListJobTriggersPagedResponse pagedListResponse = client.listJobTriggers(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobTriggersList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listJobTriggersExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listJobTriggers(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listJobTriggersTest2() throws Exception { + JobTrigger responsesElement = JobTrigger.newBuilder().build(); + ListJobTriggersResponse expectedResponse = + ListJobTriggersResponse.newBuilder() + .setNextPageToken("") + .addAllJobTriggers(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListJobTriggersPagedResponse pagedListResponse = client.listJobTriggers(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobTriggersList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listJobTriggersExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listJobTriggers(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listJobTriggersTest3() throws Exception { + JobTrigger responsesElement = JobTrigger.newBuilder().build(); + ListJobTriggersResponse expectedResponse = + ListJobTriggersResponse.newBuilder() + .setNextPageToken("") + .addAllJobTriggers(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListJobTriggersPagedResponse pagedListResponse = client.listJobTriggers(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobTriggersList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listJobTriggersExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listJobTriggers(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteJobTriggerTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]"); + + client.deleteJobTrigger(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteJobTriggerExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]"); + client.deleteJobTrigger(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteJobTriggerTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2172/jobTriggers/jobTrigger-2172"; + + client.deleteJobTrigger(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteJobTriggerExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2172/jobTriggers/jobTrigger-2172"; + client.deleteJobTrigger(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void activateJobTriggerTest() throws Exception { + DlpJob expectedResponse = + DlpJob.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .setType(DlpJobType.forNumber(0)) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setJobTriggerName("jobTriggerName494333030") + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ActivateJobTriggerRequest request = + ActivateJobTriggerRequest.newBuilder() + .setName( + JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()) + .build(); + + DlpJob actualResponse = client.activateJobTrigger(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void activateJobTriggerExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ActivateJobTriggerRequest request = + ActivateJobTriggerRequest.newBuilder() + .setName( + JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()) + .build(); + client.activateJobTrigger(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDlpJobTest() throws Exception { + DlpJob expectedResponse = + DlpJob.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .setType(DlpJobType.forNumber(0)) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setJobTriggerName("jobTriggerName494333030") + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + InspectJobConfig inspectJob = InspectJobConfig.newBuilder().build(); + + DlpJob actualResponse = client.createDlpJob(parent, inspectJob); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDlpJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + InspectJobConfig inspectJob = InspectJobConfig.newBuilder().build(); + client.createDlpJob(parent, inspectJob); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDlpJobTest2() throws Exception { + DlpJob expectedResponse = + DlpJob.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .setType(DlpJobType.forNumber(0)) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setJobTriggerName("jobTriggerName494333030") + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + RiskAnalysisJobConfig riskJob = RiskAnalysisJobConfig.newBuilder().build(); + + DlpJob actualResponse = client.createDlpJob(parent, riskJob); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDlpJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + RiskAnalysisJobConfig riskJob = RiskAnalysisJobConfig.newBuilder().build(); + client.createDlpJob(parent, riskJob); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDlpJobTest3() throws Exception { + DlpJob expectedResponse = + DlpJob.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .setType(DlpJobType.forNumber(0)) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setJobTriggerName("jobTriggerName494333030") + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + InspectJobConfig inspectJob = InspectJobConfig.newBuilder().build(); + + DlpJob actualResponse = client.createDlpJob(parent, inspectJob); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDlpJobExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + InspectJobConfig inspectJob = InspectJobConfig.newBuilder().build(); + client.createDlpJob(parent, inspectJob); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDlpJobTest4() throws Exception { + DlpJob expectedResponse = + DlpJob.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .setType(DlpJobType.forNumber(0)) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setJobTriggerName("jobTriggerName494333030") + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + RiskAnalysisJobConfig riskJob = RiskAnalysisJobConfig.newBuilder().build(); + + DlpJob actualResponse = client.createDlpJob(parent, riskJob); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDlpJobExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + RiskAnalysisJobConfig riskJob = RiskAnalysisJobConfig.newBuilder().build(); + client.createDlpJob(parent, riskJob); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDlpJobTest5() throws Exception { + DlpJob expectedResponse = + DlpJob.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .setType(DlpJobType.forNumber(0)) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setJobTriggerName("jobTriggerName494333030") + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + InspectJobConfig inspectJob = InspectJobConfig.newBuilder().build(); + + DlpJob actualResponse = client.createDlpJob(parent, inspectJob); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDlpJobExceptionTest5() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + InspectJobConfig inspectJob = InspectJobConfig.newBuilder().build(); + client.createDlpJob(parent, inspectJob); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDlpJobTest6() throws Exception { + DlpJob expectedResponse = + DlpJob.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .setType(DlpJobType.forNumber(0)) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setJobTriggerName("jobTriggerName494333030") + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + RiskAnalysisJobConfig riskJob = RiskAnalysisJobConfig.newBuilder().build(); + + DlpJob actualResponse = client.createDlpJob(parent, riskJob); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDlpJobExceptionTest6() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + RiskAnalysisJobConfig riskJob = RiskAnalysisJobConfig.newBuilder().build(); + client.createDlpJob(parent, riskJob); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDlpJobsTest() throws Exception { + DlpJob responsesElement = DlpJob.newBuilder().build(); + ListDlpJobsResponse expectedResponse = + ListDlpJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListDlpJobsPagedResponse pagedListResponse = client.listDlpJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDlpJobsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listDlpJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDlpJobsTest2() throws Exception { + DlpJob responsesElement = DlpJob.newBuilder().build(); + ListDlpJobsResponse expectedResponse = + ListDlpJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListDlpJobsPagedResponse pagedListResponse = client.listDlpJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDlpJobsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listDlpJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDlpJobsTest3() throws Exception { + DlpJob responsesElement = DlpJob.newBuilder().build(); + ListDlpJobsResponse expectedResponse = + ListDlpJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListDlpJobsPagedResponse pagedListResponse = client.listDlpJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDlpJobsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listDlpJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDlpJobTest() throws Exception { + DlpJob expectedResponse = + DlpJob.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .setType(DlpJobType.forNumber(0)) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setJobTriggerName("jobTriggerName494333030") + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + DlpJobName name = DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]"); + + DlpJob actualResponse = client.getDlpJob(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDlpJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DlpJobName name = DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]"); + client.getDlpJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDlpJobTest2() throws Exception { + DlpJob expectedResponse = + DlpJob.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .setType(DlpJobType.forNumber(0)) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setJobTriggerName("jobTriggerName494333030") + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2726/dlpJobs/dlpJob-2726"; + + DlpJob actualResponse = client.getDlpJob(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDlpJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2726/dlpJobs/dlpJob-2726"; + client.getDlpJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDlpJobTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DlpJobName name = DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]"); + + client.deleteDlpJob(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDlpJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DlpJobName name = DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]"); + client.deleteDlpJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDlpJobTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2726/dlpJobs/dlpJob-2726"; + + client.deleteDlpJob(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDlpJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2726/dlpJobs/dlpJob-2726"; + client.deleteDlpJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cancelDlpJobTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + CancelDlpJobRequest request = + CancelDlpJobRequest.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .build(); + + client.cancelDlpJob(request); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void cancelDlpJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CancelDlpJobRequest request = + CancelDlpJobRequest.newBuilder() + .setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()) + .build(); + client.cancelDlpJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createStoredInfoTypeTest() throws Exception { + StoredInfoType expectedResponse = + StoredInfoType.newBuilder() + .setName( + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]") + .toString()) + .setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()) + .addAllPendingVersions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + + StoredInfoType actualResponse = client.createStoredInfoType(parent, config); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createStoredInfoTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + client.createStoredInfoType(parent, config); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createStoredInfoTypeTest2() throws Exception { + StoredInfoType expectedResponse = + StoredInfoType.newBuilder() + .setName( + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]") + .toString()) + .setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()) + .addAllPendingVersions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + + StoredInfoType actualResponse = client.createStoredInfoType(parent, config); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createStoredInfoTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + client.createStoredInfoType(parent, config); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createStoredInfoTypeTest3() throws Exception { + StoredInfoType expectedResponse = + StoredInfoType.newBuilder() + .setName( + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]") + .toString()) + .setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()) + .addAllPendingVersions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + + StoredInfoType actualResponse = client.createStoredInfoType(parent, config); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createStoredInfoTypeExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + client.createStoredInfoType(parent, config); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createStoredInfoTypeTest4() throws Exception { + StoredInfoType expectedResponse = + StoredInfoType.newBuilder() + .setName( + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]") + .toString()) + .setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()) + .addAllPendingVersions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + + StoredInfoType actualResponse = client.createStoredInfoType(parent, config); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createStoredInfoTypeExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + client.createStoredInfoType(parent, config); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createStoredInfoTypeTest5() throws Exception { + StoredInfoType expectedResponse = + StoredInfoType.newBuilder() + .setName( + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]") + .toString()) + .setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()) + .addAllPendingVersions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + + StoredInfoType actualResponse = client.createStoredInfoType(parent, config); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createStoredInfoTypeExceptionTest5() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + client.createStoredInfoType(parent, config); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateStoredInfoTypeTest() throws Exception { + StoredInfoType expectedResponse = + StoredInfoType.newBuilder() + .setName( + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]") + .toString()) + .setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()) + .addAllPendingVersions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + StoredInfoTypeName name = + StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + StoredInfoType actualResponse = client.updateStoredInfoType(name, config, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateStoredInfoTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StoredInfoTypeName name = + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]"); + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateStoredInfoType(name, config, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateStoredInfoTypeTest2() throws Exception { + StoredInfoType expectedResponse = + StoredInfoType.newBuilder() + .setName( + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]") + .toString()) + .setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()) + .addAllPendingVersions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-6364/storedInfoTypes/storedInfoType-6364"; + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + StoredInfoType actualResponse = client.updateStoredInfoType(name, config, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateStoredInfoTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-6364/storedInfoTypes/storedInfoType-6364"; + StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateStoredInfoType(name, config, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getStoredInfoTypeTest() throws Exception { + StoredInfoType expectedResponse = + StoredInfoType.newBuilder() + .setName( + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]") + .toString()) + .setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()) + .addAllPendingVersions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + StoredInfoTypeName name = + StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]"); + + StoredInfoType actualResponse = client.getStoredInfoType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getStoredInfoTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StoredInfoTypeName name = + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]"); + client.getStoredInfoType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getStoredInfoTypeTest2() throws Exception { + StoredInfoType expectedResponse = + StoredInfoType.newBuilder() + .setName( + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]") + .toString()) + .setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()) + .addAllPendingVersions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-6364/storedInfoTypes/storedInfoType-6364"; + + StoredInfoType actualResponse = client.getStoredInfoType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getStoredInfoTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-6364/storedInfoTypes/storedInfoType-6364"; + client.getStoredInfoType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStoredInfoTypesTest() throws Exception { + StoredInfoType responsesElement = StoredInfoType.newBuilder().build(); + ListStoredInfoTypesResponse expectedResponse = + ListStoredInfoTypesResponse.newBuilder() + .setNextPageToken("") + .addAllStoredInfoTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listStoredInfoTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listStoredInfoTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStoredInfoTypesTest2() throws Exception { + StoredInfoType responsesElement = StoredInfoType.newBuilder().build(); + ListStoredInfoTypesResponse expectedResponse = + ListStoredInfoTypesResponse.newBuilder() + .setNextPageToken("") + .addAllStoredInfoTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + + ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listStoredInfoTypesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]"); + client.listStoredInfoTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStoredInfoTypesTest3() throws Exception { + StoredInfoType responsesElement = StoredInfoType.newBuilder().build(); + ListStoredInfoTypesResponse expectedResponse = + ListStoredInfoTypesResponse.newBuilder() + .setNextPageToken("") + .addAllStoredInfoTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listStoredInfoTypesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listStoredInfoTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStoredInfoTypesTest4() throws Exception { + StoredInfoType responsesElement = StoredInfoType.newBuilder().build(); + ListStoredInfoTypesResponse expectedResponse = + ListStoredInfoTypesResponse.newBuilder() + .setNextPageToken("") + .addAllStoredInfoTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listStoredInfoTypesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listStoredInfoTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStoredInfoTypesTest5() throws Exception { + StoredInfoType responsesElement = StoredInfoType.newBuilder().build(); + ListStoredInfoTypesResponse expectedResponse = + ListStoredInfoTypesResponse.newBuilder() + .setNextPageToken("") + .addAllStoredInfoTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listStoredInfoTypesExceptionTest5() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listStoredInfoTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteStoredInfoTypeTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + StoredInfoTypeName name = + StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]"); + + client.deleteStoredInfoType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteStoredInfoTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StoredInfoTypeName name = + StoredInfoTypeName.ofOrganizationStoredInfoTypeName( + "[ORGANIZATION]", "[STORED_INFO_TYPE]"); + client.deleteStoredInfoType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteStoredInfoTypeTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-6364/storedInfoTypes/storedInfoType-6364"; + + client.deleteStoredInfoType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteStoredInfoTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-6364/storedInfoTypes/storedInfoType-6364"; + client.deleteStoredInfoType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void hybridInspectDlpJobTest() throws Exception { + HybridInspectResponse expectedResponse = HybridInspectResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DlpJobName name = + DlpJobName.ofProjectLocationDlpJobName("[PROJECT]", "[LOCATION]", "[DLP_JOB]"); + + HybridInspectResponse actualResponse = client.hybridInspectDlpJob(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void hybridInspectDlpJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DlpJobName name = + DlpJobName.ofProjectLocationDlpJobName("[PROJECT]", "[LOCATION]", "[DLP_JOB]"); + client.hybridInspectDlpJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void hybridInspectDlpJobTest2() throws Exception { + HybridInspectResponse expectedResponse = HybridInspectResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7036/locations/location-7036/dlpJobs/dlpJob-7036"; + + HybridInspectResponse actualResponse = client.hybridInspectDlpJob(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void hybridInspectDlpJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7036/locations/location-7036/dlpJobs/dlpJob-7036"; + client.hybridInspectDlpJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void finishDlpJobTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + FinishDlpJobRequest request = + FinishDlpJobRequest.newBuilder() + .setName( + DlpJobName.ofProjectLocationDlpJobName("[PROJECT]", "[LOCATION]", "[DLP_JOB]") + .toString()) + .build(); + + client.finishDlpJob(request); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void finishDlpJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FinishDlpJobRequest request = + FinishDlpJobRequest.newBuilder() + .setName( + DlpJobName.ofProjectLocationDlpJobName("[PROJECT]", "[LOCATION]", "[DLP_JOB]") + .toString()) + .build(); + client.finishDlpJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +}