• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.aiplatform.v1beta1;
18 
19 import static com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListBatchPredictionJobsPagedResponse;
20 import static com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListCustomJobsPagedResponse;
21 import static com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListDataLabelingJobsPagedResponse;
22 import static com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListHyperparameterTuningJobsPagedResponse;
23 import static com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListLocationsPagedResponse;
24 import static com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListModelDeploymentMonitoringJobsPagedResponse;
25 import static com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListNasJobsPagedResponse;
26 import static com.google.cloud.aiplatform.v1beta1.JobServiceClient.ListNasTrialDetailsPagedResponse;
27 import static com.google.cloud.aiplatform.v1beta1.JobServiceClient.SearchModelDeploymentMonitoringStatsAnomaliesPagedResponse;
28 
29 import com.google.api.gax.core.NoCredentialsProvider;
30 import com.google.api.gax.grpc.GaxGrpcProperties;
31 import com.google.api.gax.grpc.testing.LocalChannelProvider;
32 import com.google.api.gax.grpc.testing.MockGrpcService;
33 import com.google.api.gax.grpc.testing.MockServiceHelper;
34 import com.google.api.gax.rpc.ApiClientHeaderProvider;
35 import com.google.api.gax.rpc.InvalidArgumentException;
36 import com.google.api.gax.rpc.StatusCode;
37 import com.google.cloud.location.GetLocationRequest;
38 import com.google.cloud.location.ListLocationsRequest;
39 import com.google.cloud.location.ListLocationsResponse;
40 import com.google.cloud.location.Location;
41 import com.google.common.collect.Lists;
42 import com.google.iam.v1.AuditConfig;
43 import com.google.iam.v1.Binding;
44 import com.google.iam.v1.GetIamPolicyRequest;
45 import com.google.iam.v1.GetPolicyOptions;
46 import com.google.iam.v1.Policy;
47 import com.google.iam.v1.SetIamPolicyRequest;
48 import com.google.iam.v1.TestIamPermissionsRequest;
49 import com.google.iam.v1.TestIamPermissionsResponse;
50 import com.google.longrunning.Operation;
51 import com.google.protobuf.AbstractMessage;
52 import com.google.protobuf.Any;
53 import com.google.protobuf.ByteString;
54 import com.google.protobuf.Duration;
55 import com.google.protobuf.Empty;
56 import com.google.protobuf.FieldMask;
57 import com.google.protobuf.Timestamp;
58 import com.google.protobuf.Value;
59 import com.google.rpc.Status;
60 import com.google.type.Money;
61 import io.grpc.StatusRuntimeException;
62 import java.io.IOException;
63 import java.util.ArrayList;
64 import java.util.Arrays;
65 import java.util.HashMap;
66 import java.util.List;
67 import java.util.UUID;
68 import java.util.concurrent.ExecutionException;
69 import javax.annotation.Generated;
70 import org.junit.After;
71 import org.junit.AfterClass;
72 import org.junit.Assert;
73 import org.junit.Before;
74 import org.junit.BeforeClass;
75 import org.junit.Test;
76 
77 @Generated("by gapic-generator-java")
78 public class JobServiceClientTest {
79   private static MockIAMPolicy mockIAMPolicy;
80   private static MockJobService mockJobService;
81   private static MockLocations mockLocations;
82   private static MockServiceHelper mockServiceHelper;
83   private LocalChannelProvider channelProvider;
84   private JobServiceClient client;
85 
86   @BeforeClass
startStaticServer()87   public static void startStaticServer() {
88     mockJobService = new MockJobService();
89     mockLocations = new MockLocations();
90     mockIAMPolicy = new MockIAMPolicy();
91     mockServiceHelper =
92         new MockServiceHelper(
93             UUID.randomUUID().toString(),
94             Arrays.<MockGrpcService>asList(mockJobService, mockLocations, mockIAMPolicy));
95     mockServiceHelper.start();
96   }
97 
98   @AfterClass
stopServer()99   public static void stopServer() {
100     mockServiceHelper.stop();
101   }
102 
103   @Before
setUp()104   public void setUp() throws IOException {
105     mockServiceHelper.reset();
106     channelProvider = mockServiceHelper.createChannelProvider();
107     JobServiceSettings settings =
108         JobServiceSettings.newBuilder()
109             .setTransportChannelProvider(channelProvider)
110             .setCredentialsProvider(NoCredentialsProvider.create())
111             .build();
112     client = JobServiceClient.create(settings);
113   }
114 
115   @After
tearDown()116   public void tearDown() throws Exception {
117     client.close();
118   }
119 
120   @Test
createCustomJobTest()121   public void createCustomJobTest() throws Exception {
122     CustomJob expectedResponse =
123         CustomJob.newBuilder()
124             .setName(CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]").toString())
125             .setDisplayName("displayName1714148973")
126             .setJobSpec(CustomJobSpec.newBuilder().build())
127             .setState(JobState.forNumber(0))
128             .setCreateTime(Timestamp.newBuilder().build())
129             .setStartTime(Timestamp.newBuilder().build())
130             .setEndTime(Timestamp.newBuilder().build())
131             .setUpdateTime(Timestamp.newBuilder().build())
132             .setError(Status.newBuilder().build())
133             .putAllLabels(new HashMap<String, String>())
134             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
135             .putAllWebAccessUris(new HashMap<String, String>())
136             .build();
137     mockJobService.addResponse(expectedResponse);
138 
139     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
140     CustomJob customJob = CustomJob.newBuilder().build();
141 
142     CustomJob actualResponse = client.createCustomJob(parent, customJob);
143     Assert.assertEquals(expectedResponse, actualResponse);
144 
145     List<AbstractMessage> actualRequests = mockJobService.getRequests();
146     Assert.assertEquals(1, actualRequests.size());
147     CreateCustomJobRequest actualRequest = ((CreateCustomJobRequest) actualRequests.get(0));
148 
149     Assert.assertEquals(parent.toString(), actualRequest.getParent());
150     Assert.assertEquals(customJob, actualRequest.getCustomJob());
151     Assert.assertTrue(
152         channelProvider.isHeaderSent(
153             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
154             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
155   }
156 
157   @Test
createCustomJobExceptionTest()158   public void createCustomJobExceptionTest() throws Exception {
159     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
160     mockJobService.addException(exception);
161 
162     try {
163       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
164       CustomJob customJob = CustomJob.newBuilder().build();
165       client.createCustomJob(parent, customJob);
166       Assert.fail("No exception raised");
167     } catch (InvalidArgumentException e) {
168       // Expected exception.
169     }
170   }
171 
172   @Test
createCustomJobTest2()173   public void createCustomJobTest2() throws Exception {
174     CustomJob expectedResponse =
175         CustomJob.newBuilder()
176             .setName(CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]").toString())
177             .setDisplayName("displayName1714148973")
178             .setJobSpec(CustomJobSpec.newBuilder().build())
179             .setState(JobState.forNumber(0))
180             .setCreateTime(Timestamp.newBuilder().build())
181             .setStartTime(Timestamp.newBuilder().build())
182             .setEndTime(Timestamp.newBuilder().build())
183             .setUpdateTime(Timestamp.newBuilder().build())
184             .setError(Status.newBuilder().build())
185             .putAllLabels(new HashMap<String, String>())
186             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
187             .putAllWebAccessUris(new HashMap<String, String>())
188             .build();
189     mockJobService.addResponse(expectedResponse);
190 
191     String parent = "parent-995424086";
192     CustomJob customJob = CustomJob.newBuilder().build();
193 
194     CustomJob actualResponse = client.createCustomJob(parent, customJob);
195     Assert.assertEquals(expectedResponse, actualResponse);
196 
197     List<AbstractMessage> actualRequests = mockJobService.getRequests();
198     Assert.assertEquals(1, actualRequests.size());
199     CreateCustomJobRequest actualRequest = ((CreateCustomJobRequest) actualRequests.get(0));
200 
201     Assert.assertEquals(parent, actualRequest.getParent());
202     Assert.assertEquals(customJob, actualRequest.getCustomJob());
203     Assert.assertTrue(
204         channelProvider.isHeaderSent(
205             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
206             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
207   }
208 
209   @Test
createCustomJobExceptionTest2()210   public void createCustomJobExceptionTest2() throws Exception {
211     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
212     mockJobService.addException(exception);
213 
214     try {
215       String parent = "parent-995424086";
216       CustomJob customJob = CustomJob.newBuilder().build();
217       client.createCustomJob(parent, customJob);
218       Assert.fail("No exception raised");
219     } catch (InvalidArgumentException e) {
220       // Expected exception.
221     }
222   }
223 
224   @Test
getCustomJobTest()225   public void getCustomJobTest() throws Exception {
226     CustomJob expectedResponse =
227         CustomJob.newBuilder()
228             .setName(CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]").toString())
229             .setDisplayName("displayName1714148973")
230             .setJobSpec(CustomJobSpec.newBuilder().build())
231             .setState(JobState.forNumber(0))
232             .setCreateTime(Timestamp.newBuilder().build())
233             .setStartTime(Timestamp.newBuilder().build())
234             .setEndTime(Timestamp.newBuilder().build())
235             .setUpdateTime(Timestamp.newBuilder().build())
236             .setError(Status.newBuilder().build())
237             .putAllLabels(new HashMap<String, String>())
238             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
239             .putAllWebAccessUris(new HashMap<String, String>())
240             .build();
241     mockJobService.addResponse(expectedResponse);
242 
243     CustomJobName name = CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]");
244 
245     CustomJob actualResponse = client.getCustomJob(name);
246     Assert.assertEquals(expectedResponse, actualResponse);
247 
248     List<AbstractMessage> actualRequests = mockJobService.getRequests();
249     Assert.assertEquals(1, actualRequests.size());
250     GetCustomJobRequest actualRequest = ((GetCustomJobRequest) actualRequests.get(0));
251 
252     Assert.assertEquals(name.toString(), actualRequest.getName());
253     Assert.assertTrue(
254         channelProvider.isHeaderSent(
255             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
256             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
257   }
258 
259   @Test
getCustomJobExceptionTest()260   public void getCustomJobExceptionTest() throws Exception {
261     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
262     mockJobService.addException(exception);
263 
264     try {
265       CustomJobName name = CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]");
266       client.getCustomJob(name);
267       Assert.fail("No exception raised");
268     } catch (InvalidArgumentException e) {
269       // Expected exception.
270     }
271   }
272 
273   @Test
getCustomJobTest2()274   public void getCustomJobTest2() throws Exception {
275     CustomJob expectedResponse =
276         CustomJob.newBuilder()
277             .setName(CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]").toString())
278             .setDisplayName("displayName1714148973")
279             .setJobSpec(CustomJobSpec.newBuilder().build())
280             .setState(JobState.forNumber(0))
281             .setCreateTime(Timestamp.newBuilder().build())
282             .setStartTime(Timestamp.newBuilder().build())
283             .setEndTime(Timestamp.newBuilder().build())
284             .setUpdateTime(Timestamp.newBuilder().build())
285             .setError(Status.newBuilder().build())
286             .putAllLabels(new HashMap<String, String>())
287             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
288             .putAllWebAccessUris(new HashMap<String, String>())
289             .build();
290     mockJobService.addResponse(expectedResponse);
291 
292     String name = "name3373707";
293 
294     CustomJob actualResponse = client.getCustomJob(name);
295     Assert.assertEquals(expectedResponse, actualResponse);
296 
297     List<AbstractMessage> actualRequests = mockJobService.getRequests();
298     Assert.assertEquals(1, actualRequests.size());
299     GetCustomJobRequest actualRequest = ((GetCustomJobRequest) actualRequests.get(0));
300 
301     Assert.assertEquals(name, actualRequest.getName());
302     Assert.assertTrue(
303         channelProvider.isHeaderSent(
304             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
305             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
306   }
307 
308   @Test
getCustomJobExceptionTest2()309   public void getCustomJobExceptionTest2() throws Exception {
310     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
311     mockJobService.addException(exception);
312 
313     try {
314       String name = "name3373707";
315       client.getCustomJob(name);
316       Assert.fail("No exception raised");
317     } catch (InvalidArgumentException e) {
318       // Expected exception.
319     }
320   }
321 
322   @Test
listCustomJobsTest()323   public void listCustomJobsTest() throws Exception {
324     CustomJob responsesElement = CustomJob.newBuilder().build();
325     ListCustomJobsResponse expectedResponse =
326         ListCustomJobsResponse.newBuilder()
327             .setNextPageToken("")
328             .addAllCustomJobs(Arrays.asList(responsesElement))
329             .build();
330     mockJobService.addResponse(expectedResponse);
331 
332     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
333 
334     ListCustomJobsPagedResponse pagedListResponse = client.listCustomJobs(parent);
335 
336     List<CustomJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
337 
338     Assert.assertEquals(1, resources.size());
339     Assert.assertEquals(expectedResponse.getCustomJobsList().get(0), resources.get(0));
340 
341     List<AbstractMessage> actualRequests = mockJobService.getRequests();
342     Assert.assertEquals(1, actualRequests.size());
343     ListCustomJobsRequest actualRequest = ((ListCustomJobsRequest) actualRequests.get(0));
344 
345     Assert.assertEquals(parent.toString(), actualRequest.getParent());
346     Assert.assertTrue(
347         channelProvider.isHeaderSent(
348             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
349             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
350   }
351 
352   @Test
listCustomJobsExceptionTest()353   public void listCustomJobsExceptionTest() throws Exception {
354     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
355     mockJobService.addException(exception);
356 
357     try {
358       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
359       client.listCustomJobs(parent);
360       Assert.fail("No exception raised");
361     } catch (InvalidArgumentException e) {
362       // Expected exception.
363     }
364   }
365 
366   @Test
listCustomJobsTest2()367   public void listCustomJobsTest2() throws Exception {
368     CustomJob responsesElement = CustomJob.newBuilder().build();
369     ListCustomJobsResponse expectedResponse =
370         ListCustomJobsResponse.newBuilder()
371             .setNextPageToken("")
372             .addAllCustomJobs(Arrays.asList(responsesElement))
373             .build();
374     mockJobService.addResponse(expectedResponse);
375 
376     String parent = "parent-995424086";
377 
378     ListCustomJobsPagedResponse pagedListResponse = client.listCustomJobs(parent);
379 
380     List<CustomJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
381 
382     Assert.assertEquals(1, resources.size());
383     Assert.assertEquals(expectedResponse.getCustomJobsList().get(0), resources.get(0));
384 
385     List<AbstractMessage> actualRequests = mockJobService.getRequests();
386     Assert.assertEquals(1, actualRequests.size());
387     ListCustomJobsRequest actualRequest = ((ListCustomJobsRequest) actualRequests.get(0));
388 
389     Assert.assertEquals(parent, actualRequest.getParent());
390     Assert.assertTrue(
391         channelProvider.isHeaderSent(
392             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
393             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
394   }
395 
396   @Test
listCustomJobsExceptionTest2()397   public void listCustomJobsExceptionTest2() throws Exception {
398     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
399     mockJobService.addException(exception);
400 
401     try {
402       String parent = "parent-995424086";
403       client.listCustomJobs(parent);
404       Assert.fail("No exception raised");
405     } catch (InvalidArgumentException e) {
406       // Expected exception.
407     }
408   }
409 
410   @Test
deleteCustomJobTest()411   public void deleteCustomJobTest() throws Exception {
412     Empty expectedResponse = Empty.newBuilder().build();
413     Operation resultOperation =
414         Operation.newBuilder()
415             .setName("deleteCustomJobTest")
416             .setDone(true)
417             .setResponse(Any.pack(expectedResponse))
418             .build();
419     mockJobService.addResponse(resultOperation);
420 
421     CustomJobName name = CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]");
422 
423     client.deleteCustomJobAsync(name).get();
424 
425     List<AbstractMessage> actualRequests = mockJobService.getRequests();
426     Assert.assertEquals(1, actualRequests.size());
427     DeleteCustomJobRequest actualRequest = ((DeleteCustomJobRequest) actualRequests.get(0));
428 
429     Assert.assertEquals(name.toString(), actualRequest.getName());
430     Assert.assertTrue(
431         channelProvider.isHeaderSent(
432             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
433             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
434   }
435 
436   @Test
deleteCustomJobExceptionTest()437   public void deleteCustomJobExceptionTest() throws Exception {
438     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
439     mockJobService.addException(exception);
440 
441     try {
442       CustomJobName name = CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]");
443       client.deleteCustomJobAsync(name).get();
444       Assert.fail("No exception raised");
445     } catch (ExecutionException e) {
446       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
447       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
448       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
449     }
450   }
451 
452   @Test
deleteCustomJobTest2()453   public void deleteCustomJobTest2() throws Exception {
454     Empty expectedResponse = Empty.newBuilder().build();
455     Operation resultOperation =
456         Operation.newBuilder()
457             .setName("deleteCustomJobTest")
458             .setDone(true)
459             .setResponse(Any.pack(expectedResponse))
460             .build();
461     mockJobService.addResponse(resultOperation);
462 
463     String name = "name3373707";
464 
465     client.deleteCustomJobAsync(name).get();
466 
467     List<AbstractMessage> actualRequests = mockJobService.getRequests();
468     Assert.assertEquals(1, actualRequests.size());
469     DeleteCustomJobRequest actualRequest = ((DeleteCustomJobRequest) actualRequests.get(0));
470 
471     Assert.assertEquals(name, actualRequest.getName());
472     Assert.assertTrue(
473         channelProvider.isHeaderSent(
474             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
475             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
476   }
477 
478   @Test
deleteCustomJobExceptionTest2()479   public void deleteCustomJobExceptionTest2() throws Exception {
480     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
481     mockJobService.addException(exception);
482 
483     try {
484       String name = "name3373707";
485       client.deleteCustomJobAsync(name).get();
486       Assert.fail("No exception raised");
487     } catch (ExecutionException e) {
488       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
489       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
490       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
491     }
492   }
493 
494   @Test
cancelCustomJobTest()495   public void cancelCustomJobTest() throws Exception {
496     Empty expectedResponse = Empty.newBuilder().build();
497     mockJobService.addResponse(expectedResponse);
498 
499     CustomJobName name = CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]");
500 
501     client.cancelCustomJob(name);
502 
503     List<AbstractMessage> actualRequests = mockJobService.getRequests();
504     Assert.assertEquals(1, actualRequests.size());
505     CancelCustomJobRequest actualRequest = ((CancelCustomJobRequest) actualRequests.get(0));
506 
507     Assert.assertEquals(name.toString(), actualRequest.getName());
508     Assert.assertTrue(
509         channelProvider.isHeaderSent(
510             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
511             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
512   }
513 
514   @Test
cancelCustomJobExceptionTest()515   public void cancelCustomJobExceptionTest() throws Exception {
516     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
517     mockJobService.addException(exception);
518 
519     try {
520       CustomJobName name = CustomJobName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_JOB]");
521       client.cancelCustomJob(name);
522       Assert.fail("No exception raised");
523     } catch (InvalidArgumentException e) {
524       // Expected exception.
525     }
526   }
527 
528   @Test
cancelCustomJobTest2()529   public void cancelCustomJobTest2() throws Exception {
530     Empty expectedResponse = Empty.newBuilder().build();
531     mockJobService.addResponse(expectedResponse);
532 
533     String name = "name3373707";
534 
535     client.cancelCustomJob(name);
536 
537     List<AbstractMessage> actualRequests = mockJobService.getRequests();
538     Assert.assertEquals(1, actualRequests.size());
539     CancelCustomJobRequest actualRequest = ((CancelCustomJobRequest) actualRequests.get(0));
540 
541     Assert.assertEquals(name, actualRequest.getName());
542     Assert.assertTrue(
543         channelProvider.isHeaderSent(
544             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
545             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
546   }
547 
548   @Test
cancelCustomJobExceptionTest2()549   public void cancelCustomJobExceptionTest2() throws Exception {
550     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
551     mockJobService.addException(exception);
552 
553     try {
554       String name = "name3373707";
555       client.cancelCustomJob(name);
556       Assert.fail("No exception raised");
557     } catch (InvalidArgumentException e) {
558       // Expected exception.
559     }
560   }
561 
562   @Test
createDataLabelingJobTest()563   public void createDataLabelingJobTest() throws Exception {
564     DataLabelingJob expectedResponse =
565         DataLabelingJob.newBuilder()
566             .setName(
567                 DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]").toString())
568             .setDisplayName("displayName1714148973")
569             .addAllDatasets(new ArrayList<String>())
570             .putAllAnnotationLabels(new HashMap<String, String>())
571             .setLabelerCount(-1457777167)
572             .setInstructionUri("instructionUri1989242366")
573             .setInputsSchemaUri("inputsSchemaUri1757461538")
574             .setInputs(Value.newBuilder().setBoolValue(true).build())
575             .setState(JobState.forNumber(0))
576             .setLabelingProgress(-685978914)
577             .setCurrentSpend(Money.newBuilder().build())
578             .setCreateTime(Timestamp.newBuilder().build())
579             .setUpdateTime(Timestamp.newBuilder().build())
580             .setError(Status.newBuilder().build())
581             .putAllLabels(new HashMap<String, String>())
582             .addAllSpecialistPools(new ArrayList<String>())
583             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
584             .setActiveLearningConfig(ActiveLearningConfig.newBuilder().build())
585             .build();
586     mockJobService.addResponse(expectedResponse);
587 
588     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
589     DataLabelingJob dataLabelingJob = DataLabelingJob.newBuilder().build();
590 
591     DataLabelingJob actualResponse = client.createDataLabelingJob(parent, dataLabelingJob);
592     Assert.assertEquals(expectedResponse, actualResponse);
593 
594     List<AbstractMessage> actualRequests = mockJobService.getRequests();
595     Assert.assertEquals(1, actualRequests.size());
596     CreateDataLabelingJobRequest actualRequest =
597         ((CreateDataLabelingJobRequest) actualRequests.get(0));
598 
599     Assert.assertEquals(parent.toString(), actualRequest.getParent());
600     Assert.assertEquals(dataLabelingJob, actualRequest.getDataLabelingJob());
601     Assert.assertTrue(
602         channelProvider.isHeaderSent(
603             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
604             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
605   }
606 
607   @Test
createDataLabelingJobExceptionTest()608   public void createDataLabelingJobExceptionTest() throws Exception {
609     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
610     mockJobService.addException(exception);
611 
612     try {
613       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
614       DataLabelingJob dataLabelingJob = DataLabelingJob.newBuilder().build();
615       client.createDataLabelingJob(parent, dataLabelingJob);
616       Assert.fail("No exception raised");
617     } catch (InvalidArgumentException e) {
618       // Expected exception.
619     }
620   }
621 
622   @Test
createDataLabelingJobTest2()623   public void createDataLabelingJobTest2() throws Exception {
624     DataLabelingJob expectedResponse =
625         DataLabelingJob.newBuilder()
626             .setName(
627                 DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]").toString())
628             .setDisplayName("displayName1714148973")
629             .addAllDatasets(new ArrayList<String>())
630             .putAllAnnotationLabels(new HashMap<String, String>())
631             .setLabelerCount(-1457777167)
632             .setInstructionUri("instructionUri1989242366")
633             .setInputsSchemaUri("inputsSchemaUri1757461538")
634             .setInputs(Value.newBuilder().setBoolValue(true).build())
635             .setState(JobState.forNumber(0))
636             .setLabelingProgress(-685978914)
637             .setCurrentSpend(Money.newBuilder().build())
638             .setCreateTime(Timestamp.newBuilder().build())
639             .setUpdateTime(Timestamp.newBuilder().build())
640             .setError(Status.newBuilder().build())
641             .putAllLabels(new HashMap<String, String>())
642             .addAllSpecialistPools(new ArrayList<String>())
643             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
644             .setActiveLearningConfig(ActiveLearningConfig.newBuilder().build())
645             .build();
646     mockJobService.addResponse(expectedResponse);
647 
648     String parent = "parent-995424086";
649     DataLabelingJob dataLabelingJob = DataLabelingJob.newBuilder().build();
650 
651     DataLabelingJob actualResponse = client.createDataLabelingJob(parent, dataLabelingJob);
652     Assert.assertEquals(expectedResponse, actualResponse);
653 
654     List<AbstractMessage> actualRequests = mockJobService.getRequests();
655     Assert.assertEquals(1, actualRequests.size());
656     CreateDataLabelingJobRequest actualRequest =
657         ((CreateDataLabelingJobRequest) actualRequests.get(0));
658 
659     Assert.assertEquals(parent, actualRequest.getParent());
660     Assert.assertEquals(dataLabelingJob, actualRequest.getDataLabelingJob());
661     Assert.assertTrue(
662         channelProvider.isHeaderSent(
663             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
664             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
665   }
666 
667   @Test
createDataLabelingJobExceptionTest2()668   public void createDataLabelingJobExceptionTest2() throws Exception {
669     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
670     mockJobService.addException(exception);
671 
672     try {
673       String parent = "parent-995424086";
674       DataLabelingJob dataLabelingJob = DataLabelingJob.newBuilder().build();
675       client.createDataLabelingJob(parent, dataLabelingJob);
676       Assert.fail("No exception raised");
677     } catch (InvalidArgumentException e) {
678       // Expected exception.
679     }
680   }
681 
682   @Test
getDataLabelingJobTest()683   public void getDataLabelingJobTest() throws Exception {
684     DataLabelingJob expectedResponse =
685         DataLabelingJob.newBuilder()
686             .setName(
687                 DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]").toString())
688             .setDisplayName("displayName1714148973")
689             .addAllDatasets(new ArrayList<String>())
690             .putAllAnnotationLabels(new HashMap<String, String>())
691             .setLabelerCount(-1457777167)
692             .setInstructionUri("instructionUri1989242366")
693             .setInputsSchemaUri("inputsSchemaUri1757461538")
694             .setInputs(Value.newBuilder().setBoolValue(true).build())
695             .setState(JobState.forNumber(0))
696             .setLabelingProgress(-685978914)
697             .setCurrentSpend(Money.newBuilder().build())
698             .setCreateTime(Timestamp.newBuilder().build())
699             .setUpdateTime(Timestamp.newBuilder().build())
700             .setError(Status.newBuilder().build())
701             .putAllLabels(new HashMap<String, String>())
702             .addAllSpecialistPools(new ArrayList<String>())
703             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
704             .setActiveLearningConfig(ActiveLearningConfig.newBuilder().build())
705             .build();
706     mockJobService.addResponse(expectedResponse);
707 
708     DataLabelingJobName name =
709         DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]");
710 
711     DataLabelingJob actualResponse = client.getDataLabelingJob(name);
712     Assert.assertEquals(expectedResponse, actualResponse);
713 
714     List<AbstractMessage> actualRequests = mockJobService.getRequests();
715     Assert.assertEquals(1, actualRequests.size());
716     GetDataLabelingJobRequest actualRequest = ((GetDataLabelingJobRequest) actualRequests.get(0));
717 
718     Assert.assertEquals(name.toString(), actualRequest.getName());
719     Assert.assertTrue(
720         channelProvider.isHeaderSent(
721             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
722             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
723   }
724 
725   @Test
getDataLabelingJobExceptionTest()726   public void getDataLabelingJobExceptionTest() throws Exception {
727     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
728     mockJobService.addException(exception);
729 
730     try {
731       DataLabelingJobName name =
732           DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]");
733       client.getDataLabelingJob(name);
734       Assert.fail("No exception raised");
735     } catch (InvalidArgumentException e) {
736       // Expected exception.
737     }
738   }
739 
740   @Test
getDataLabelingJobTest2()741   public void getDataLabelingJobTest2() throws Exception {
742     DataLabelingJob expectedResponse =
743         DataLabelingJob.newBuilder()
744             .setName(
745                 DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]").toString())
746             .setDisplayName("displayName1714148973")
747             .addAllDatasets(new ArrayList<String>())
748             .putAllAnnotationLabels(new HashMap<String, String>())
749             .setLabelerCount(-1457777167)
750             .setInstructionUri("instructionUri1989242366")
751             .setInputsSchemaUri("inputsSchemaUri1757461538")
752             .setInputs(Value.newBuilder().setBoolValue(true).build())
753             .setState(JobState.forNumber(0))
754             .setLabelingProgress(-685978914)
755             .setCurrentSpend(Money.newBuilder().build())
756             .setCreateTime(Timestamp.newBuilder().build())
757             .setUpdateTime(Timestamp.newBuilder().build())
758             .setError(Status.newBuilder().build())
759             .putAllLabels(new HashMap<String, String>())
760             .addAllSpecialistPools(new ArrayList<String>())
761             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
762             .setActiveLearningConfig(ActiveLearningConfig.newBuilder().build())
763             .build();
764     mockJobService.addResponse(expectedResponse);
765 
766     String name = "name3373707";
767 
768     DataLabelingJob actualResponse = client.getDataLabelingJob(name);
769     Assert.assertEquals(expectedResponse, actualResponse);
770 
771     List<AbstractMessage> actualRequests = mockJobService.getRequests();
772     Assert.assertEquals(1, actualRequests.size());
773     GetDataLabelingJobRequest actualRequest = ((GetDataLabelingJobRequest) actualRequests.get(0));
774 
775     Assert.assertEquals(name, actualRequest.getName());
776     Assert.assertTrue(
777         channelProvider.isHeaderSent(
778             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
779             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
780   }
781 
782   @Test
getDataLabelingJobExceptionTest2()783   public void getDataLabelingJobExceptionTest2() throws Exception {
784     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
785     mockJobService.addException(exception);
786 
787     try {
788       String name = "name3373707";
789       client.getDataLabelingJob(name);
790       Assert.fail("No exception raised");
791     } catch (InvalidArgumentException e) {
792       // Expected exception.
793     }
794   }
795 
796   @Test
listDataLabelingJobsTest()797   public void listDataLabelingJobsTest() throws Exception {
798     DataLabelingJob responsesElement = DataLabelingJob.newBuilder().build();
799     ListDataLabelingJobsResponse expectedResponse =
800         ListDataLabelingJobsResponse.newBuilder()
801             .setNextPageToken("")
802             .addAllDataLabelingJobs(Arrays.asList(responsesElement))
803             .build();
804     mockJobService.addResponse(expectedResponse);
805 
806     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
807 
808     ListDataLabelingJobsPagedResponse pagedListResponse = client.listDataLabelingJobs(parent);
809 
810     List<DataLabelingJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
811 
812     Assert.assertEquals(1, resources.size());
813     Assert.assertEquals(expectedResponse.getDataLabelingJobsList().get(0), resources.get(0));
814 
815     List<AbstractMessage> actualRequests = mockJobService.getRequests();
816     Assert.assertEquals(1, actualRequests.size());
817     ListDataLabelingJobsRequest actualRequest =
818         ((ListDataLabelingJobsRequest) actualRequests.get(0));
819 
820     Assert.assertEquals(parent.toString(), actualRequest.getParent());
821     Assert.assertTrue(
822         channelProvider.isHeaderSent(
823             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
824             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
825   }
826 
827   @Test
listDataLabelingJobsExceptionTest()828   public void listDataLabelingJobsExceptionTest() throws Exception {
829     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
830     mockJobService.addException(exception);
831 
832     try {
833       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
834       client.listDataLabelingJobs(parent);
835       Assert.fail("No exception raised");
836     } catch (InvalidArgumentException e) {
837       // Expected exception.
838     }
839   }
840 
841   @Test
listDataLabelingJobsTest2()842   public void listDataLabelingJobsTest2() throws Exception {
843     DataLabelingJob responsesElement = DataLabelingJob.newBuilder().build();
844     ListDataLabelingJobsResponse expectedResponse =
845         ListDataLabelingJobsResponse.newBuilder()
846             .setNextPageToken("")
847             .addAllDataLabelingJobs(Arrays.asList(responsesElement))
848             .build();
849     mockJobService.addResponse(expectedResponse);
850 
851     String parent = "parent-995424086";
852 
853     ListDataLabelingJobsPagedResponse pagedListResponse = client.listDataLabelingJobs(parent);
854 
855     List<DataLabelingJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
856 
857     Assert.assertEquals(1, resources.size());
858     Assert.assertEquals(expectedResponse.getDataLabelingJobsList().get(0), resources.get(0));
859 
860     List<AbstractMessage> actualRequests = mockJobService.getRequests();
861     Assert.assertEquals(1, actualRequests.size());
862     ListDataLabelingJobsRequest actualRequest =
863         ((ListDataLabelingJobsRequest) actualRequests.get(0));
864 
865     Assert.assertEquals(parent, actualRequest.getParent());
866     Assert.assertTrue(
867         channelProvider.isHeaderSent(
868             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
869             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
870   }
871 
872   @Test
listDataLabelingJobsExceptionTest2()873   public void listDataLabelingJobsExceptionTest2() throws Exception {
874     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
875     mockJobService.addException(exception);
876 
877     try {
878       String parent = "parent-995424086";
879       client.listDataLabelingJobs(parent);
880       Assert.fail("No exception raised");
881     } catch (InvalidArgumentException e) {
882       // Expected exception.
883     }
884   }
885 
886   @Test
deleteDataLabelingJobTest()887   public void deleteDataLabelingJobTest() throws Exception {
888     Empty expectedResponse = Empty.newBuilder().build();
889     Operation resultOperation =
890         Operation.newBuilder()
891             .setName("deleteDataLabelingJobTest")
892             .setDone(true)
893             .setResponse(Any.pack(expectedResponse))
894             .build();
895     mockJobService.addResponse(resultOperation);
896 
897     DataLabelingJobName name =
898         DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]");
899 
900     client.deleteDataLabelingJobAsync(name).get();
901 
902     List<AbstractMessage> actualRequests = mockJobService.getRequests();
903     Assert.assertEquals(1, actualRequests.size());
904     DeleteDataLabelingJobRequest actualRequest =
905         ((DeleteDataLabelingJobRequest) actualRequests.get(0));
906 
907     Assert.assertEquals(name.toString(), actualRequest.getName());
908     Assert.assertTrue(
909         channelProvider.isHeaderSent(
910             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
911             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
912   }
913 
914   @Test
deleteDataLabelingJobExceptionTest()915   public void deleteDataLabelingJobExceptionTest() throws Exception {
916     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
917     mockJobService.addException(exception);
918 
919     try {
920       DataLabelingJobName name =
921           DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]");
922       client.deleteDataLabelingJobAsync(name).get();
923       Assert.fail("No exception raised");
924     } catch (ExecutionException e) {
925       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
926       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
927       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
928     }
929   }
930 
931   @Test
deleteDataLabelingJobTest2()932   public void deleteDataLabelingJobTest2() throws Exception {
933     Empty expectedResponse = Empty.newBuilder().build();
934     Operation resultOperation =
935         Operation.newBuilder()
936             .setName("deleteDataLabelingJobTest")
937             .setDone(true)
938             .setResponse(Any.pack(expectedResponse))
939             .build();
940     mockJobService.addResponse(resultOperation);
941 
942     String name = "name3373707";
943 
944     client.deleteDataLabelingJobAsync(name).get();
945 
946     List<AbstractMessage> actualRequests = mockJobService.getRequests();
947     Assert.assertEquals(1, actualRequests.size());
948     DeleteDataLabelingJobRequest actualRequest =
949         ((DeleteDataLabelingJobRequest) actualRequests.get(0));
950 
951     Assert.assertEquals(name, actualRequest.getName());
952     Assert.assertTrue(
953         channelProvider.isHeaderSent(
954             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
955             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
956   }
957 
958   @Test
deleteDataLabelingJobExceptionTest2()959   public void deleteDataLabelingJobExceptionTest2() throws Exception {
960     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
961     mockJobService.addException(exception);
962 
963     try {
964       String name = "name3373707";
965       client.deleteDataLabelingJobAsync(name).get();
966       Assert.fail("No exception raised");
967     } catch (ExecutionException e) {
968       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
969       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
970       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
971     }
972   }
973 
974   @Test
cancelDataLabelingJobTest()975   public void cancelDataLabelingJobTest() throws Exception {
976     Empty expectedResponse = Empty.newBuilder().build();
977     mockJobService.addResponse(expectedResponse);
978 
979     DataLabelingJobName name =
980         DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]");
981 
982     client.cancelDataLabelingJob(name);
983 
984     List<AbstractMessage> actualRequests = mockJobService.getRequests();
985     Assert.assertEquals(1, actualRequests.size());
986     CancelDataLabelingJobRequest actualRequest =
987         ((CancelDataLabelingJobRequest) actualRequests.get(0));
988 
989     Assert.assertEquals(name.toString(), actualRequest.getName());
990     Assert.assertTrue(
991         channelProvider.isHeaderSent(
992             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
993             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
994   }
995 
996   @Test
cancelDataLabelingJobExceptionTest()997   public void cancelDataLabelingJobExceptionTest() throws Exception {
998     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
999     mockJobService.addException(exception);
1000 
1001     try {
1002       DataLabelingJobName name =
1003           DataLabelingJobName.of("[PROJECT]", "[LOCATION]", "[DATA_LABELING_JOB]");
1004       client.cancelDataLabelingJob(name);
1005       Assert.fail("No exception raised");
1006     } catch (InvalidArgumentException e) {
1007       // Expected exception.
1008     }
1009   }
1010 
1011   @Test
cancelDataLabelingJobTest2()1012   public void cancelDataLabelingJobTest2() throws Exception {
1013     Empty expectedResponse = Empty.newBuilder().build();
1014     mockJobService.addResponse(expectedResponse);
1015 
1016     String name = "name3373707";
1017 
1018     client.cancelDataLabelingJob(name);
1019 
1020     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1021     Assert.assertEquals(1, actualRequests.size());
1022     CancelDataLabelingJobRequest actualRequest =
1023         ((CancelDataLabelingJobRequest) actualRequests.get(0));
1024 
1025     Assert.assertEquals(name, actualRequest.getName());
1026     Assert.assertTrue(
1027         channelProvider.isHeaderSent(
1028             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1029             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1030   }
1031 
1032   @Test
cancelDataLabelingJobExceptionTest2()1033   public void cancelDataLabelingJobExceptionTest2() throws Exception {
1034     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1035     mockJobService.addException(exception);
1036 
1037     try {
1038       String name = "name3373707";
1039       client.cancelDataLabelingJob(name);
1040       Assert.fail("No exception raised");
1041     } catch (InvalidArgumentException e) {
1042       // Expected exception.
1043     }
1044   }
1045 
1046   @Test
createHyperparameterTuningJobTest()1047   public void createHyperparameterTuningJobTest() throws Exception {
1048     HyperparameterTuningJob expectedResponse =
1049         HyperparameterTuningJob.newBuilder()
1050             .setName(
1051                 HyperparameterTuningJobName.of(
1052                         "[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]")
1053                     .toString())
1054             .setDisplayName("displayName1714148973")
1055             .setStudySpec(StudySpec.newBuilder().build())
1056             .setMaxTrialCount(-445994933)
1057             .setParallelTrialCount(1813795950)
1058             .setMaxFailedTrialCount(-887662497)
1059             .setTrialJobSpec(CustomJobSpec.newBuilder().build())
1060             .addAllTrials(new ArrayList<Trial>())
1061             .setState(JobState.forNumber(0))
1062             .setCreateTime(Timestamp.newBuilder().build())
1063             .setStartTime(Timestamp.newBuilder().build())
1064             .setEndTime(Timestamp.newBuilder().build())
1065             .setUpdateTime(Timestamp.newBuilder().build())
1066             .setError(Status.newBuilder().build())
1067             .putAllLabels(new HashMap<String, String>())
1068             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
1069             .build();
1070     mockJobService.addResponse(expectedResponse);
1071 
1072     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
1073     HyperparameterTuningJob hyperparameterTuningJob = HyperparameterTuningJob.newBuilder().build();
1074 
1075     HyperparameterTuningJob actualResponse =
1076         client.createHyperparameterTuningJob(parent, hyperparameterTuningJob);
1077     Assert.assertEquals(expectedResponse, actualResponse);
1078 
1079     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1080     Assert.assertEquals(1, actualRequests.size());
1081     CreateHyperparameterTuningJobRequest actualRequest =
1082         ((CreateHyperparameterTuningJobRequest) actualRequests.get(0));
1083 
1084     Assert.assertEquals(parent.toString(), actualRequest.getParent());
1085     Assert.assertEquals(hyperparameterTuningJob, actualRequest.getHyperparameterTuningJob());
1086     Assert.assertTrue(
1087         channelProvider.isHeaderSent(
1088             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1089             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1090   }
1091 
1092   @Test
createHyperparameterTuningJobExceptionTest()1093   public void createHyperparameterTuningJobExceptionTest() throws Exception {
1094     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1095     mockJobService.addException(exception);
1096 
1097     try {
1098       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
1099       HyperparameterTuningJob hyperparameterTuningJob =
1100           HyperparameterTuningJob.newBuilder().build();
1101       client.createHyperparameterTuningJob(parent, hyperparameterTuningJob);
1102       Assert.fail("No exception raised");
1103     } catch (InvalidArgumentException e) {
1104       // Expected exception.
1105     }
1106   }
1107 
1108   @Test
createHyperparameterTuningJobTest2()1109   public void createHyperparameterTuningJobTest2() throws Exception {
1110     HyperparameterTuningJob expectedResponse =
1111         HyperparameterTuningJob.newBuilder()
1112             .setName(
1113                 HyperparameterTuningJobName.of(
1114                         "[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]")
1115                     .toString())
1116             .setDisplayName("displayName1714148973")
1117             .setStudySpec(StudySpec.newBuilder().build())
1118             .setMaxTrialCount(-445994933)
1119             .setParallelTrialCount(1813795950)
1120             .setMaxFailedTrialCount(-887662497)
1121             .setTrialJobSpec(CustomJobSpec.newBuilder().build())
1122             .addAllTrials(new ArrayList<Trial>())
1123             .setState(JobState.forNumber(0))
1124             .setCreateTime(Timestamp.newBuilder().build())
1125             .setStartTime(Timestamp.newBuilder().build())
1126             .setEndTime(Timestamp.newBuilder().build())
1127             .setUpdateTime(Timestamp.newBuilder().build())
1128             .setError(Status.newBuilder().build())
1129             .putAllLabels(new HashMap<String, String>())
1130             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
1131             .build();
1132     mockJobService.addResponse(expectedResponse);
1133 
1134     String parent = "parent-995424086";
1135     HyperparameterTuningJob hyperparameterTuningJob = HyperparameterTuningJob.newBuilder().build();
1136 
1137     HyperparameterTuningJob actualResponse =
1138         client.createHyperparameterTuningJob(parent, hyperparameterTuningJob);
1139     Assert.assertEquals(expectedResponse, actualResponse);
1140 
1141     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1142     Assert.assertEquals(1, actualRequests.size());
1143     CreateHyperparameterTuningJobRequest actualRequest =
1144         ((CreateHyperparameterTuningJobRequest) actualRequests.get(0));
1145 
1146     Assert.assertEquals(parent, actualRequest.getParent());
1147     Assert.assertEquals(hyperparameterTuningJob, actualRequest.getHyperparameterTuningJob());
1148     Assert.assertTrue(
1149         channelProvider.isHeaderSent(
1150             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1151             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1152   }
1153 
1154   @Test
createHyperparameterTuningJobExceptionTest2()1155   public void createHyperparameterTuningJobExceptionTest2() throws Exception {
1156     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1157     mockJobService.addException(exception);
1158 
1159     try {
1160       String parent = "parent-995424086";
1161       HyperparameterTuningJob hyperparameterTuningJob =
1162           HyperparameterTuningJob.newBuilder().build();
1163       client.createHyperparameterTuningJob(parent, hyperparameterTuningJob);
1164       Assert.fail("No exception raised");
1165     } catch (InvalidArgumentException e) {
1166       // Expected exception.
1167     }
1168   }
1169 
1170   @Test
getHyperparameterTuningJobTest()1171   public void getHyperparameterTuningJobTest() throws Exception {
1172     HyperparameterTuningJob expectedResponse =
1173         HyperparameterTuningJob.newBuilder()
1174             .setName(
1175                 HyperparameterTuningJobName.of(
1176                         "[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]")
1177                     .toString())
1178             .setDisplayName("displayName1714148973")
1179             .setStudySpec(StudySpec.newBuilder().build())
1180             .setMaxTrialCount(-445994933)
1181             .setParallelTrialCount(1813795950)
1182             .setMaxFailedTrialCount(-887662497)
1183             .setTrialJobSpec(CustomJobSpec.newBuilder().build())
1184             .addAllTrials(new ArrayList<Trial>())
1185             .setState(JobState.forNumber(0))
1186             .setCreateTime(Timestamp.newBuilder().build())
1187             .setStartTime(Timestamp.newBuilder().build())
1188             .setEndTime(Timestamp.newBuilder().build())
1189             .setUpdateTime(Timestamp.newBuilder().build())
1190             .setError(Status.newBuilder().build())
1191             .putAllLabels(new HashMap<String, String>())
1192             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
1193             .build();
1194     mockJobService.addResponse(expectedResponse);
1195 
1196     HyperparameterTuningJobName name =
1197         HyperparameterTuningJobName.of("[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]");
1198 
1199     HyperparameterTuningJob actualResponse = client.getHyperparameterTuningJob(name);
1200     Assert.assertEquals(expectedResponse, actualResponse);
1201 
1202     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1203     Assert.assertEquals(1, actualRequests.size());
1204     GetHyperparameterTuningJobRequest actualRequest =
1205         ((GetHyperparameterTuningJobRequest) actualRequests.get(0));
1206 
1207     Assert.assertEquals(name.toString(), actualRequest.getName());
1208     Assert.assertTrue(
1209         channelProvider.isHeaderSent(
1210             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1211             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1212   }
1213 
1214   @Test
getHyperparameterTuningJobExceptionTest()1215   public void getHyperparameterTuningJobExceptionTest() throws Exception {
1216     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1217     mockJobService.addException(exception);
1218 
1219     try {
1220       HyperparameterTuningJobName name =
1221           HyperparameterTuningJobName.of("[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]");
1222       client.getHyperparameterTuningJob(name);
1223       Assert.fail("No exception raised");
1224     } catch (InvalidArgumentException e) {
1225       // Expected exception.
1226     }
1227   }
1228 
1229   @Test
getHyperparameterTuningJobTest2()1230   public void getHyperparameterTuningJobTest2() throws Exception {
1231     HyperparameterTuningJob expectedResponse =
1232         HyperparameterTuningJob.newBuilder()
1233             .setName(
1234                 HyperparameterTuningJobName.of(
1235                         "[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]")
1236                     .toString())
1237             .setDisplayName("displayName1714148973")
1238             .setStudySpec(StudySpec.newBuilder().build())
1239             .setMaxTrialCount(-445994933)
1240             .setParallelTrialCount(1813795950)
1241             .setMaxFailedTrialCount(-887662497)
1242             .setTrialJobSpec(CustomJobSpec.newBuilder().build())
1243             .addAllTrials(new ArrayList<Trial>())
1244             .setState(JobState.forNumber(0))
1245             .setCreateTime(Timestamp.newBuilder().build())
1246             .setStartTime(Timestamp.newBuilder().build())
1247             .setEndTime(Timestamp.newBuilder().build())
1248             .setUpdateTime(Timestamp.newBuilder().build())
1249             .setError(Status.newBuilder().build())
1250             .putAllLabels(new HashMap<String, String>())
1251             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
1252             .build();
1253     mockJobService.addResponse(expectedResponse);
1254 
1255     String name = "name3373707";
1256 
1257     HyperparameterTuningJob actualResponse = client.getHyperparameterTuningJob(name);
1258     Assert.assertEquals(expectedResponse, actualResponse);
1259 
1260     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1261     Assert.assertEquals(1, actualRequests.size());
1262     GetHyperparameterTuningJobRequest actualRequest =
1263         ((GetHyperparameterTuningJobRequest) actualRequests.get(0));
1264 
1265     Assert.assertEquals(name, actualRequest.getName());
1266     Assert.assertTrue(
1267         channelProvider.isHeaderSent(
1268             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1269             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1270   }
1271 
1272   @Test
getHyperparameterTuningJobExceptionTest2()1273   public void getHyperparameterTuningJobExceptionTest2() throws Exception {
1274     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1275     mockJobService.addException(exception);
1276 
1277     try {
1278       String name = "name3373707";
1279       client.getHyperparameterTuningJob(name);
1280       Assert.fail("No exception raised");
1281     } catch (InvalidArgumentException e) {
1282       // Expected exception.
1283     }
1284   }
1285 
1286   @Test
listHyperparameterTuningJobsTest()1287   public void listHyperparameterTuningJobsTest() throws Exception {
1288     HyperparameterTuningJob responsesElement = HyperparameterTuningJob.newBuilder().build();
1289     ListHyperparameterTuningJobsResponse expectedResponse =
1290         ListHyperparameterTuningJobsResponse.newBuilder()
1291             .setNextPageToken("")
1292             .addAllHyperparameterTuningJobs(Arrays.asList(responsesElement))
1293             .build();
1294     mockJobService.addResponse(expectedResponse);
1295 
1296     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
1297 
1298     ListHyperparameterTuningJobsPagedResponse pagedListResponse =
1299         client.listHyperparameterTuningJobs(parent);
1300 
1301     List<HyperparameterTuningJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1302 
1303     Assert.assertEquals(1, resources.size());
1304     Assert.assertEquals(
1305         expectedResponse.getHyperparameterTuningJobsList().get(0), resources.get(0));
1306 
1307     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1308     Assert.assertEquals(1, actualRequests.size());
1309     ListHyperparameterTuningJobsRequest actualRequest =
1310         ((ListHyperparameterTuningJobsRequest) actualRequests.get(0));
1311 
1312     Assert.assertEquals(parent.toString(), actualRequest.getParent());
1313     Assert.assertTrue(
1314         channelProvider.isHeaderSent(
1315             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1316             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1317   }
1318 
1319   @Test
listHyperparameterTuningJobsExceptionTest()1320   public void listHyperparameterTuningJobsExceptionTest() throws Exception {
1321     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1322     mockJobService.addException(exception);
1323 
1324     try {
1325       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
1326       client.listHyperparameterTuningJobs(parent);
1327       Assert.fail("No exception raised");
1328     } catch (InvalidArgumentException e) {
1329       // Expected exception.
1330     }
1331   }
1332 
1333   @Test
listHyperparameterTuningJobsTest2()1334   public void listHyperparameterTuningJobsTest2() throws Exception {
1335     HyperparameterTuningJob responsesElement = HyperparameterTuningJob.newBuilder().build();
1336     ListHyperparameterTuningJobsResponse expectedResponse =
1337         ListHyperparameterTuningJobsResponse.newBuilder()
1338             .setNextPageToken("")
1339             .addAllHyperparameterTuningJobs(Arrays.asList(responsesElement))
1340             .build();
1341     mockJobService.addResponse(expectedResponse);
1342 
1343     String parent = "parent-995424086";
1344 
1345     ListHyperparameterTuningJobsPagedResponse pagedListResponse =
1346         client.listHyperparameterTuningJobs(parent);
1347 
1348     List<HyperparameterTuningJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1349 
1350     Assert.assertEquals(1, resources.size());
1351     Assert.assertEquals(
1352         expectedResponse.getHyperparameterTuningJobsList().get(0), resources.get(0));
1353 
1354     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1355     Assert.assertEquals(1, actualRequests.size());
1356     ListHyperparameterTuningJobsRequest actualRequest =
1357         ((ListHyperparameterTuningJobsRequest) actualRequests.get(0));
1358 
1359     Assert.assertEquals(parent, actualRequest.getParent());
1360     Assert.assertTrue(
1361         channelProvider.isHeaderSent(
1362             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1363             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1364   }
1365 
1366   @Test
listHyperparameterTuningJobsExceptionTest2()1367   public void listHyperparameterTuningJobsExceptionTest2() throws Exception {
1368     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1369     mockJobService.addException(exception);
1370 
1371     try {
1372       String parent = "parent-995424086";
1373       client.listHyperparameterTuningJobs(parent);
1374       Assert.fail("No exception raised");
1375     } catch (InvalidArgumentException e) {
1376       // Expected exception.
1377     }
1378   }
1379 
1380   @Test
deleteHyperparameterTuningJobTest()1381   public void deleteHyperparameterTuningJobTest() throws Exception {
1382     Empty expectedResponse = Empty.newBuilder().build();
1383     Operation resultOperation =
1384         Operation.newBuilder()
1385             .setName("deleteHyperparameterTuningJobTest")
1386             .setDone(true)
1387             .setResponse(Any.pack(expectedResponse))
1388             .build();
1389     mockJobService.addResponse(resultOperation);
1390 
1391     HyperparameterTuningJobName name =
1392         HyperparameterTuningJobName.of("[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]");
1393 
1394     client.deleteHyperparameterTuningJobAsync(name).get();
1395 
1396     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1397     Assert.assertEquals(1, actualRequests.size());
1398     DeleteHyperparameterTuningJobRequest actualRequest =
1399         ((DeleteHyperparameterTuningJobRequest) actualRequests.get(0));
1400 
1401     Assert.assertEquals(name.toString(), actualRequest.getName());
1402     Assert.assertTrue(
1403         channelProvider.isHeaderSent(
1404             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1405             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1406   }
1407 
1408   @Test
deleteHyperparameterTuningJobExceptionTest()1409   public void deleteHyperparameterTuningJobExceptionTest() throws Exception {
1410     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1411     mockJobService.addException(exception);
1412 
1413     try {
1414       HyperparameterTuningJobName name =
1415           HyperparameterTuningJobName.of("[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]");
1416       client.deleteHyperparameterTuningJobAsync(name).get();
1417       Assert.fail("No exception raised");
1418     } catch (ExecutionException e) {
1419       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1420       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1421       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1422     }
1423   }
1424 
1425   @Test
deleteHyperparameterTuningJobTest2()1426   public void deleteHyperparameterTuningJobTest2() throws Exception {
1427     Empty expectedResponse = Empty.newBuilder().build();
1428     Operation resultOperation =
1429         Operation.newBuilder()
1430             .setName("deleteHyperparameterTuningJobTest")
1431             .setDone(true)
1432             .setResponse(Any.pack(expectedResponse))
1433             .build();
1434     mockJobService.addResponse(resultOperation);
1435 
1436     String name = "name3373707";
1437 
1438     client.deleteHyperparameterTuningJobAsync(name).get();
1439 
1440     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1441     Assert.assertEquals(1, actualRequests.size());
1442     DeleteHyperparameterTuningJobRequest actualRequest =
1443         ((DeleteHyperparameterTuningJobRequest) actualRequests.get(0));
1444 
1445     Assert.assertEquals(name, actualRequest.getName());
1446     Assert.assertTrue(
1447         channelProvider.isHeaderSent(
1448             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1449             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1450   }
1451 
1452   @Test
deleteHyperparameterTuningJobExceptionTest2()1453   public void deleteHyperparameterTuningJobExceptionTest2() throws Exception {
1454     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1455     mockJobService.addException(exception);
1456 
1457     try {
1458       String name = "name3373707";
1459       client.deleteHyperparameterTuningJobAsync(name).get();
1460       Assert.fail("No exception raised");
1461     } catch (ExecutionException e) {
1462       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1463       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1464       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1465     }
1466   }
1467 
1468   @Test
cancelHyperparameterTuningJobTest()1469   public void cancelHyperparameterTuningJobTest() throws Exception {
1470     Empty expectedResponse = Empty.newBuilder().build();
1471     mockJobService.addResponse(expectedResponse);
1472 
1473     HyperparameterTuningJobName name =
1474         HyperparameterTuningJobName.of("[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]");
1475 
1476     client.cancelHyperparameterTuningJob(name);
1477 
1478     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1479     Assert.assertEquals(1, actualRequests.size());
1480     CancelHyperparameterTuningJobRequest actualRequest =
1481         ((CancelHyperparameterTuningJobRequest) actualRequests.get(0));
1482 
1483     Assert.assertEquals(name.toString(), actualRequest.getName());
1484     Assert.assertTrue(
1485         channelProvider.isHeaderSent(
1486             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1487             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1488   }
1489 
1490   @Test
cancelHyperparameterTuningJobExceptionTest()1491   public void cancelHyperparameterTuningJobExceptionTest() throws Exception {
1492     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1493     mockJobService.addException(exception);
1494 
1495     try {
1496       HyperparameterTuningJobName name =
1497           HyperparameterTuningJobName.of("[PROJECT]", "[LOCATION]", "[HYPERPARAMETER_TUNING_JOB]");
1498       client.cancelHyperparameterTuningJob(name);
1499       Assert.fail("No exception raised");
1500     } catch (InvalidArgumentException e) {
1501       // Expected exception.
1502     }
1503   }
1504 
1505   @Test
cancelHyperparameterTuningJobTest2()1506   public void cancelHyperparameterTuningJobTest2() throws Exception {
1507     Empty expectedResponse = Empty.newBuilder().build();
1508     mockJobService.addResponse(expectedResponse);
1509 
1510     String name = "name3373707";
1511 
1512     client.cancelHyperparameterTuningJob(name);
1513 
1514     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1515     Assert.assertEquals(1, actualRequests.size());
1516     CancelHyperparameterTuningJobRequest actualRequest =
1517         ((CancelHyperparameterTuningJobRequest) actualRequests.get(0));
1518 
1519     Assert.assertEquals(name, actualRequest.getName());
1520     Assert.assertTrue(
1521         channelProvider.isHeaderSent(
1522             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1523             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1524   }
1525 
1526   @Test
cancelHyperparameterTuningJobExceptionTest2()1527   public void cancelHyperparameterTuningJobExceptionTest2() throws Exception {
1528     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1529     mockJobService.addException(exception);
1530 
1531     try {
1532       String name = "name3373707";
1533       client.cancelHyperparameterTuningJob(name);
1534       Assert.fail("No exception raised");
1535     } catch (InvalidArgumentException e) {
1536       // Expected exception.
1537     }
1538   }
1539 
1540   @Test
createNasJobTest()1541   public void createNasJobTest() throws Exception {
1542     NasJob expectedResponse =
1543         NasJob.newBuilder()
1544             .setName(NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]").toString())
1545             .setDisplayName("displayName1714148973")
1546             .setNasJobSpec(NasJobSpec.newBuilder().build())
1547             .setNasJobOutput(NasJobOutput.newBuilder().build())
1548             .setState(JobState.forNumber(0))
1549             .setCreateTime(Timestamp.newBuilder().build())
1550             .setStartTime(Timestamp.newBuilder().build())
1551             .setEndTime(Timestamp.newBuilder().build())
1552             .setUpdateTime(Timestamp.newBuilder().build())
1553             .setError(Status.newBuilder().build())
1554             .putAllLabels(new HashMap<String, String>())
1555             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
1556             .setEnableRestrictedImageTraining(true)
1557             .build();
1558     mockJobService.addResponse(expectedResponse);
1559 
1560     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
1561     NasJob nasJob = NasJob.newBuilder().build();
1562 
1563     NasJob actualResponse = client.createNasJob(parent, nasJob);
1564     Assert.assertEquals(expectedResponse, actualResponse);
1565 
1566     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1567     Assert.assertEquals(1, actualRequests.size());
1568     CreateNasJobRequest actualRequest = ((CreateNasJobRequest) actualRequests.get(0));
1569 
1570     Assert.assertEquals(parent.toString(), actualRequest.getParent());
1571     Assert.assertEquals(nasJob, actualRequest.getNasJob());
1572     Assert.assertTrue(
1573         channelProvider.isHeaderSent(
1574             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1575             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1576   }
1577 
1578   @Test
createNasJobExceptionTest()1579   public void createNasJobExceptionTest() throws Exception {
1580     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1581     mockJobService.addException(exception);
1582 
1583     try {
1584       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
1585       NasJob nasJob = NasJob.newBuilder().build();
1586       client.createNasJob(parent, nasJob);
1587       Assert.fail("No exception raised");
1588     } catch (InvalidArgumentException e) {
1589       // Expected exception.
1590     }
1591   }
1592 
1593   @Test
createNasJobTest2()1594   public void createNasJobTest2() throws Exception {
1595     NasJob expectedResponse =
1596         NasJob.newBuilder()
1597             .setName(NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]").toString())
1598             .setDisplayName("displayName1714148973")
1599             .setNasJobSpec(NasJobSpec.newBuilder().build())
1600             .setNasJobOutput(NasJobOutput.newBuilder().build())
1601             .setState(JobState.forNumber(0))
1602             .setCreateTime(Timestamp.newBuilder().build())
1603             .setStartTime(Timestamp.newBuilder().build())
1604             .setEndTime(Timestamp.newBuilder().build())
1605             .setUpdateTime(Timestamp.newBuilder().build())
1606             .setError(Status.newBuilder().build())
1607             .putAllLabels(new HashMap<String, String>())
1608             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
1609             .setEnableRestrictedImageTraining(true)
1610             .build();
1611     mockJobService.addResponse(expectedResponse);
1612 
1613     String parent = "parent-995424086";
1614     NasJob nasJob = NasJob.newBuilder().build();
1615 
1616     NasJob actualResponse = client.createNasJob(parent, nasJob);
1617     Assert.assertEquals(expectedResponse, actualResponse);
1618 
1619     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1620     Assert.assertEquals(1, actualRequests.size());
1621     CreateNasJobRequest actualRequest = ((CreateNasJobRequest) actualRequests.get(0));
1622 
1623     Assert.assertEquals(parent, actualRequest.getParent());
1624     Assert.assertEquals(nasJob, actualRequest.getNasJob());
1625     Assert.assertTrue(
1626         channelProvider.isHeaderSent(
1627             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1628             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1629   }
1630 
1631   @Test
createNasJobExceptionTest2()1632   public void createNasJobExceptionTest2() throws Exception {
1633     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1634     mockJobService.addException(exception);
1635 
1636     try {
1637       String parent = "parent-995424086";
1638       NasJob nasJob = NasJob.newBuilder().build();
1639       client.createNasJob(parent, nasJob);
1640       Assert.fail("No exception raised");
1641     } catch (InvalidArgumentException e) {
1642       // Expected exception.
1643     }
1644   }
1645 
1646   @Test
getNasJobTest()1647   public void getNasJobTest() throws Exception {
1648     NasJob expectedResponse =
1649         NasJob.newBuilder()
1650             .setName(NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]").toString())
1651             .setDisplayName("displayName1714148973")
1652             .setNasJobSpec(NasJobSpec.newBuilder().build())
1653             .setNasJobOutput(NasJobOutput.newBuilder().build())
1654             .setState(JobState.forNumber(0))
1655             .setCreateTime(Timestamp.newBuilder().build())
1656             .setStartTime(Timestamp.newBuilder().build())
1657             .setEndTime(Timestamp.newBuilder().build())
1658             .setUpdateTime(Timestamp.newBuilder().build())
1659             .setError(Status.newBuilder().build())
1660             .putAllLabels(new HashMap<String, String>())
1661             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
1662             .setEnableRestrictedImageTraining(true)
1663             .build();
1664     mockJobService.addResponse(expectedResponse);
1665 
1666     NasJobName name = NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]");
1667 
1668     NasJob actualResponse = client.getNasJob(name);
1669     Assert.assertEquals(expectedResponse, actualResponse);
1670 
1671     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1672     Assert.assertEquals(1, actualRequests.size());
1673     GetNasJobRequest actualRequest = ((GetNasJobRequest) actualRequests.get(0));
1674 
1675     Assert.assertEquals(name.toString(), actualRequest.getName());
1676     Assert.assertTrue(
1677         channelProvider.isHeaderSent(
1678             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1679             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1680   }
1681 
1682   @Test
getNasJobExceptionTest()1683   public void getNasJobExceptionTest() throws Exception {
1684     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1685     mockJobService.addException(exception);
1686 
1687     try {
1688       NasJobName name = NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]");
1689       client.getNasJob(name);
1690       Assert.fail("No exception raised");
1691     } catch (InvalidArgumentException e) {
1692       // Expected exception.
1693     }
1694   }
1695 
1696   @Test
getNasJobTest2()1697   public void getNasJobTest2() throws Exception {
1698     NasJob expectedResponse =
1699         NasJob.newBuilder()
1700             .setName(NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]").toString())
1701             .setDisplayName("displayName1714148973")
1702             .setNasJobSpec(NasJobSpec.newBuilder().build())
1703             .setNasJobOutput(NasJobOutput.newBuilder().build())
1704             .setState(JobState.forNumber(0))
1705             .setCreateTime(Timestamp.newBuilder().build())
1706             .setStartTime(Timestamp.newBuilder().build())
1707             .setEndTime(Timestamp.newBuilder().build())
1708             .setUpdateTime(Timestamp.newBuilder().build())
1709             .setError(Status.newBuilder().build())
1710             .putAllLabels(new HashMap<String, String>())
1711             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
1712             .setEnableRestrictedImageTraining(true)
1713             .build();
1714     mockJobService.addResponse(expectedResponse);
1715 
1716     String name = "name3373707";
1717 
1718     NasJob actualResponse = client.getNasJob(name);
1719     Assert.assertEquals(expectedResponse, actualResponse);
1720 
1721     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1722     Assert.assertEquals(1, actualRequests.size());
1723     GetNasJobRequest actualRequest = ((GetNasJobRequest) actualRequests.get(0));
1724 
1725     Assert.assertEquals(name, actualRequest.getName());
1726     Assert.assertTrue(
1727         channelProvider.isHeaderSent(
1728             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1729             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1730   }
1731 
1732   @Test
getNasJobExceptionTest2()1733   public void getNasJobExceptionTest2() throws Exception {
1734     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1735     mockJobService.addException(exception);
1736 
1737     try {
1738       String name = "name3373707";
1739       client.getNasJob(name);
1740       Assert.fail("No exception raised");
1741     } catch (InvalidArgumentException e) {
1742       // Expected exception.
1743     }
1744   }
1745 
1746   @Test
listNasJobsTest()1747   public void listNasJobsTest() throws Exception {
1748     NasJob responsesElement = NasJob.newBuilder().build();
1749     ListNasJobsResponse expectedResponse =
1750         ListNasJobsResponse.newBuilder()
1751             .setNextPageToken("")
1752             .addAllNasJobs(Arrays.asList(responsesElement))
1753             .build();
1754     mockJobService.addResponse(expectedResponse);
1755 
1756     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
1757 
1758     ListNasJobsPagedResponse pagedListResponse = client.listNasJobs(parent);
1759 
1760     List<NasJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1761 
1762     Assert.assertEquals(1, resources.size());
1763     Assert.assertEquals(expectedResponse.getNasJobsList().get(0), resources.get(0));
1764 
1765     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1766     Assert.assertEquals(1, actualRequests.size());
1767     ListNasJobsRequest actualRequest = ((ListNasJobsRequest) actualRequests.get(0));
1768 
1769     Assert.assertEquals(parent.toString(), actualRequest.getParent());
1770     Assert.assertTrue(
1771         channelProvider.isHeaderSent(
1772             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1773             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1774   }
1775 
1776   @Test
listNasJobsExceptionTest()1777   public void listNasJobsExceptionTest() throws Exception {
1778     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1779     mockJobService.addException(exception);
1780 
1781     try {
1782       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
1783       client.listNasJobs(parent);
1784       Assert.fail("No exception raised");
1785     } catch (InvalidArgumentException e) {
1786       // Expected exception.
1787     }
1788   }
1789 
1790   @Test
listNasJobsTest2()1791   public void listNasJobsTest2() throws Exception {
1792     NasJob responsesElement = NasJob.newBuilder().build();
1793     ListNasJobsResponse expectedResponse =
1794         ListNasJobsResponse.newBuilder()
1795             .setNextPageToken("")
1796             .addAllNasJobs(Arrays.asList(responsesElement))
1797             .build();
1798     mockJobService.addResponse(expectedResponse);
1799 
1800     String parent = "parent-995424086";
1801 
1802     ListNasJobsPagedResponse pagedListResponse = client.listNasJobs(parent);
1803 
1804     List<NasJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
1805 
1806     Assert.assertEquals(1, resources.size());
1807     Assert.assertEquals(expectedResponse.getNasJobsList().get(0), resources.get(0));
1808 
1809     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1810     Assert.assertEquals(1, actualRequests.size());
1811     ListNasJobsRequest actualRequest = ((ListNasJobsRequest) actualRequests.get(0));
1812 
1813     Assert.assertEquals(parent, actualRequest.getParent());
1814     Assert.assertTrue(
1815         channelProvider.isHeaderSent(
1816             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1817             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1818   }
1819 
1820   @Test
listNasJobsExceptionTest2()1821   public void listNasJobsExceptionTest2() throws Exception {
1822     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1823     mockJobService.addException(exception);
1824 
1825     try {
1826       String parent = "parent-995424086";
1827       client.listNasJobs(parent);
1828       Assert.fail("No exception raised");
1829     } catch (InvalidArgumentException e) {
1830       // Expected exception.
1831     }
1832   }
1833 
1834   @Test
deleteNasJobTest()1835   public void deleteNasJobTest() throws Exception {
1836     Empty expectedResponse = Empty.newBuilder().build();
1837     Operation resultOperation =
1838         Operation.newBuilder()
1839             .setName("deleteNasJobTest")
1840             .setDone(true)
1841             .setResponse(Any.pack(expectedResponse))
1842             .build();
1843     mockJobService.addResponse(resultOperation);
1844 
1845     NasJobName name = NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]");
1846 
1847     client.deleteNasJobAsync(name).get();
1848 
1849     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1850     Assert.assertEquals(1, actualRequests.size());
1851     DeleteNasJobRequest actualRequest = ((DeleteNasJobRequest) actualRequests.get(0));
1852 
1853     Assert.assertEquals(name.toString(), actualRequest.getName());
1854     Assert.assertTrue(
1855         channelProvider.isHeaderSent(
1856             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1857             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1858   }
1859 
1860   @Test
deleteNasJobExceptionTest()1861   public void deleteNasJobExceptionTest() throws Exception {
1862     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1863     mockJobService.addException(exception);
1864 
1865     try {
1866       NasJobName name = NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]");
1867       client.deleteNasJobAsync(name).get();
1868       Assert.fail("No exception raised");
1869     } catch (ExecutionException e) {
1870       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1871       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1872       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1873     }
1874   }
1875 
1876   @Test
deleteNasJobTest2()1877   public void deleteNasJobTest2() throws Exception {
1878     Empty expectedResponse = Empty.newBuilder().build();
1879     Operation resultOperation =
1880         Operation.newBuilder()
1881             .setName("deleteNasJobTest")
1882             .setDone(true)
1883             .setResponse(Any.pack(expectedResponse))
1884             .build();
1885     mockJobService.addResponse(resultOperation);
1886 
1887     String name = "name3373707";
1888 
1889     client.deleteNasJobAsync(name).get();
1890 
1891     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1892     Assert.assertEquals(1, actualRequests.size());
1893     DeleteNasJobRequest actualRequest = ((DeleteNasJobRequest) actualRequests.get(0));
1894 
1895     Assert.assertEquals(name, actualRequest.getName());
1896     Assert.assertTrue(
1897         channelProvider.isHeaderSent(
1898             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1899             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1900   }
1901 
1902   @Test
deleteNasJobExceptionTest2()1903   public void deleteNasJobExceptionTest2() throws Exception {
1904     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1905     mockJobService.addException(exception);
1906 
1907     try {
1908       String name = "name3373707";
1909       client.deleteNasJobAsync(name).get();
1910       Assert.fail("No exception raised");
1911     } catch (ExecutionException e) {
1912       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
1913       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
1914       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
1915     }
1916   }
1917 
1918   @Test
cancelNasJobTest()1919   public void cancelNasJobTest() throws Exception {
1920     Empty expectedResponse = Empty.newBuilder().build();
1921     mockJobService.addResponse(expectedResponse);
1922 
1923     NasJobName name = NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]");
1924 
1925     client.cancelNasJob(name);
1926 
1927     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1928     Assert.assertEquals(1, actualRequests.size());
1929     CancelNasJobRequest actualRequest = ((CancelNasJobRequest) actualRequests.get(0));
1930 
1931     Assert.assertEquals(name.toString(), actualRequest.getName());
1932     Assert.assertTrue(
1933         channelProvider.isHeaderSent(
1934             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1935             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1936   }
1937 
1938   @Test
cancelNasJobExceptionTest()1939   public void cancelNasJobExceptionTest() throws Exception {
1940     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1941     mockJobService.addException(exception);
1942 
1943     try {
1944       NasJobName name = NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]");
1945       client.cancelNasJob(name);
1946       Assert.fail("No exception raised");
1947     } catch (InvalidArgumentException e) {
1948       // Expected exception.
1949     }
1950   }
1951 
1952   @Test
cancelNasJobTest2()1953   public void cancelNasJobTest2() throws Exception {
1954     Empty expectedResponse = Empty.newBuilder().build();
1955     mockJobService.addResponse(expectedResponse);
1956 
1957     String name = "name3373707";
1958 
1959     client.cancelNasJob(name);
1960 
1961     List<AbstractMessage> actualRequests = mockJobService.getRequests();
1962     Assert.assertEquals(1, actualRequests.size());
1963     CancelNasJobRequest actualRequest = ((CancelNasJobRequest) actualRequests.get(0));
1964 
1965     Assert.assertEquals(name, actualRequest.getName());
1966     Assert.assertTrue(
1967         channelProvider.isHeaderSent(
1968             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1969             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1970   }
1971 
1972   @Test
cancelNasJobExceptionTest2()1973   public void cancelNasJobExceptionTest2() throws Exception {
1974     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
1975     mockJobService.addException(exception);
1976 
1977     try {
1978       String name = "name3373707";
1979       client.cancelNasJob(name);
1980       Assert.fail("No exception raised");
1981     } catch (InvalidArgumentException e) {
1982       // Expected exception.
1983     }
1984   }
1985 
1986   @Test
getNasTrialDetailTest()1987   public void getNasTrialDetailTest() throws Exception {
1988     NasTrialDetail expectedResponse =
1989         NasTrialDetail.newBuilder()
1990             .setName(
1991                 NasTrialDetailName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]", "[NAS_TRIAL_DETAIL]")
1992                     .toString())
1993             .setParameters("parameters458736106")
1994             .setSearchTrial(NasTrial.newBuilder().build())
1995             .setTrainTrial(NasTrial.newBuilder().build())
1996             .build();
1997     mockJobService.addResponse(expectedResponse);
1998 
1999     NasTrialDetailName name =
2000         NasTrialDetailName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]", "[NAS_TRIAL_DETAIL]");
2001 
2002     NasTrialDetail actualResponse = client.getNasTrialDetail(name);
2003     Assert.assertEquals(expectedResponse, actualResponse);
2004 
2005     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2006     Assert.assertEquals(1, actualRequests.size());
2007     GetNasTrialDetailRequest actualRequest = ((GetNasTrialDetailRequest) actualRequests.get(0));
2008 
2009     Assert.assertEquals(name.toString(), actualRequest.getName());
2010     Assert.assertTrue(
2011         channelProvider.isHeaderSent(
2012             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2013             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2014   }
2015 
2016   @Test
getNasTrialDetailExceptionTest()2017   public void getNasTrialDetailExceptionTest() throws Exception {
2018     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2019     mockJobService.addException(exception);
2020 
2021     try {
2022       NasTrialDetailName name =
2023           NasTrialDetailName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]", "[NAS_TRIAL_DETAIL]");
2024       client.getNasTrialDetail(name);
2025       Assert.fail("No exception raised");
2026     } catch (InvalidArgumentException e) {
2027       // Expected exception.
2028     }
2029   }
2030 
2031   @Test
getNasTrialDetailTest2()2032   public void getNasTrialDetailTest2() throws Exception {
2033     NasTrialDetail expectedResponse =
2034         NasTrialDetail.newBuilder()
2035             .setName(
2036                 NasTrialDetailName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]", "[NAS_TRIAL_DETAIL]")
2037                     .toString())
2038             .setParameters("parameters458736106")
2039             .setSearchTrial(NasTrial.newBuilder().build())
2040             .setTrainTrial(NasTrial.newBuilder().build())
2041             .build();
2042     mockJobService.addResponse(expectedResponse);
2043 
2044     String name = "name3373707";
2045 
2046     NasTrialDetail actualResponse = client.getNasTrialDetail(name);
2047     Assert.assertEquals(expectedResponse, actualResponse);
2048 
2049     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2050     Assert.assertEquals(1, actualRequests.size());
2051     GetNasTrialDetailRequest actualRequest = ((GetNasTrialDetailRequest) actualRequests.get(0));
2052 
2053     Assert.assertEquals(name, actualRequest.getName());
2054     Assert.assertTrue(
2055         channelProvider.isHeaderSent(
2056             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2057             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2058   }
2059 
2060   @Test
getNasTrialDetailExceptionTest2()2061   public void getNasTrialDetailExceptionTest2() throws Exception {
2062     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2063     mockJobService.addException(exception);
2064 
2065     try {
2066       String name = "name3373707";
2067       client.getNasTrialDetail(name);
2068       Assert.fail("No exception raised");
2069     } catch (InvalidArgumentException e) {
2070       // Expected exception.
2071     }
2072   }
2073 
2074   @Test
listNasTrialDetailsTest()2075   public void listNasTrialDetailsTest() throws Exception {
2076     NasTrialDetail responsesElement = NasTrialDetail.newBuilder().build();
2077     ListNasTrialDetailsResponse expectedResponse =
2078         ListNasTrialDetailsResponse.newBuilder()
2079             .setNextPageToken("")
2080             .addAllNasTrialDetails(Arrays.asList(responsesElement))
2081             .build();
2082     mockJobService.addResponse(expectedResponse);
2083 
2084     NasJobName parent = NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]");
2085 
2086     ListNasTrialDetailsPagedResponse pagedListResponse = client.listNasTrialDetails(parent);
2087 
2088     List<NasTrialDetail> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2089 
2090     Assert.assertEquals(1, resources.size());
2091     Assert.assertEquals(expectedResponse.getNasTrialDetailsList().get(0), resources.get(0));
2092 
2093     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2094     Assert.assertEquals(1, actualRequests.size());
2095     ListNasTrialDetailsRequest actualRequest = ((ListNasTrialDetailsRequest) actualRequests.get(0));
2096 
2097     Assert.assertEquals(parent.toString(), actualRequest.getParent());
2098     Assert.assertTrue(
2099         channelProvider.isHeaderSent(
2100             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2101             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2102   }
2103 
2104   @Test
listNasTrialDetailsExceptionTest()2105   public void listNasTrialDetailsExceptionTest() throws Exception {
2106     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2107     mockJobService.addException(exception);
2108 
2109     try {
2110       NasJobName parent = NasJobName.of("[PROJECT]", "[LOCATION]", "[NAS_JOB]");
2111       client.listNasTrialDetails(parent);
2112       Assert.fail("No exception raised");
2113     } catch (InvalidArgumentException e) {
2114       // Expected exception.
2115     }
2116   }
2117 
2118   @Test
listNasTrialDetailsTest2()2119   public void listNasTrialDetailsTest2() throws Exception {
2120     NasTrialDetail responsesElement = NasTrialDetail.newBuilder().build();
2121     ListNasTrialDetailsResponse expectedResponse =
2122         ListNasTrialDetailsResponse.newBuilder()
2123             .setNextPageToken("")
2124             .addAllNasTrialDetails(Arrays.asList(responsesElement))
2125             .build();
2126     mockJobService.addResponse(expectedResponse);
2127 
2128     String parent = "parent-995424086";
2129 
2130     ListNasTrialDetailsPagedResponse pagedListResponse = client.listNasTrialDetails(parent);
2131 
2132     List<NasTrialDetail> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2133 
2134     Assert.assertEquals(1, resources.size());
2135     Assert.assertEquals(expectedResponse.getNasTrialDetailsList().get(0), resources.get(0));
2136 
2137     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2138     Assert.assertEquals(1, actualRequests.size());
2139     ListNasTrialDetailsRequest actualRequest = ((ListNasTrialDetailsRequest) actualRequests.get(0));
2140 
2141     Assert.assertEquals(parent, actualRequest.getParent());
2142     Assert.assertTrue(
2143         channelProvider.isHeaderSent(
2144             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2145             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2146   }
2147 
2148   @Test
listNasTrialDetailsExceptionTest2()2149   public void listNasTrialDetailsExceptionTest2() throws Exception {
2150     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2151     mockJobService.addException(exception);
2152 
2153     try {
2154       String parent = "parent-995424086";
2155       client.listNasTrialDetails(parent);
2156       Assert.fail("No exception raised");
2157     } catch (InvalidArgumentException e) {
2158       // Expected exception.
2159     }
2160   }
2161 
2162   @Test
createBatchPredictionJobTest()2163   public void createBatchPredictionJobTest() throws Exception {
2164     BatchPredictionJob expectedResponse =
2165         BatchPredictionJob.newBuilder()
2166             .setName(
2167                 BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]")
2168                     .toString())
2169             .setDisplayName("displayName1714148973")
2170             .setModel(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
2171             .setModelVersionId("modelVersionId-2006125846")
2172             .setUnmanagedContainerModel(UnmanagedContainerModel.newBuilder().build())
2173             .setInputConfig(BatchPredictionJob.InputConfig.newBuilder().build())
2174             .setInstanceConfig(BatchPredictionJob.InstanceConfig.newBuilder().build())
2175             .setModelParameters(Value.newBuilder().setBoolValue(true).build())
2176             .setOutputConfig(BatchPredictionJob.OutputConfig.newBuilder().build())
2177             .setDedicatedResources(BatchDedicatedResources.newBuilder().build())
2178             .setServiceAccount("serviceAccount1079137720")
2179             .setManualBatchTuningParameters(ManualBatchTuningParameters.newBuilder().build())
2180             .setGenerateExplanation(true)
2181             .setExplanationSpec(ExplanationSpec.newBuilder().build())
2182             .setOutputInfo(BatchPredictionJob.OutputInfo.newBuilder().build())
2183             .setState(JobState.forNumber(0))
2184             .setError(Status.newBuilder().build())
2185             .addAllPartialFailures(new ArrayList<Status>())
2186             .setResourcesConsumed(ResourcesConsumed.newBuilder().build())
2187             .setCompletionStats(CompletionStats.newBuilder().build())
2188             .setCreateTime(Timestamp.newBuilder().build())
2189             .setStartTime(Timestamp.newBuilder().build())
2190             .setEndTime(Timestamp.newBuilder().build())
2191             .setUpdateTime(Timestamp.newBuilder().build())
2192             .putAllLabels(new HashMap<String, String>())
2193             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2194             .setModelMonitoringConfig(ModelMonitoringConfig.newBuilder().build())
2195             .addAllModelMonitoringStatsAnomalies(new ArrayList<ModelMonitoringStatsAnomalies>())
2196             .setModelMonitoringStatus(Status.newBuilder().build())
2197             .setDisableContainerLogging(true)
2198             .build();
2199     mockJobService.addResponse(expectedResponse);
2200 
2201     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2202     BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().build();
2203 
2204     BatchPredictionJob actualResponse = client.createBatchPredictionJob(parent, batchPredictionJob);
2205     Assert.assertEquals(expectedResponse, actualResponse);
2206 
2207     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2208     Assert.assertEquals(1, actualRequests.size());
2209     CreateBatchPredictionJobRequest actualRequest =
2210         ((CreateBatchPredictionJobRequest) actualRequests.get(0));
2211 
2212     Assert.assertEquals(parent.toString(), actualRequest.getParent());
2213     Assert.assertEquals(batchPredictionJob, actualRequest.getBatchPredictionJob());
2214     Assert.assertTrue(
2215         channelProvider.isHeaderSent(
2216             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2217             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2218   }
2219 
2220   @Test
createBatchPredictionJobExceptionTest()2221   public void createBatchPredictionJobExceptionTest() throws Exception {
2222     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2223     mockJobService.addException(exception);
2224 
2225     try {
2226       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2227       BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().build();
2228       client.createBatchPredictionJob(parent, batchPredictionJob);
2229       Assert.fail("No exception raised");
2230     } catch (InvalidArgumentException e) {
2231       // Expected exception.
2232     }
2233   }
2234 
2235   @Test
createBatchPredictionJobTest2()2236   public void createBatchPredictionJobTest2() throws Exception {
2237     BatchPredictionJob expectedResponse =
2238         BatchPredictionJob.newBuilder()
2239             .setName(
2240                 BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]")
2241                     .toString())
2242             .setDisplayName("displayName1714148973")
2243             .setModel(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
2244             .setModelVersionId("modelVersionId-2006125846")
2245             .setUnmanagedContainerModel(UnmanagedContainerModel.newBuilder().build())
2246             .setInputConfig(BatchPredictionJob.InputConfig.newBuilder().build())
2247             .setInstanceConfig(BatchPredictionJob.InstanceConfig.newBuilder().build())
2248             .setModelParameters(Value.newBuilder().setBoolValue(true).build())
2249             .setOutputConfig(BatchPredictionJob.OutputConfig.newBuilder().build())
2250             .setDedicatedResources(BatchDedicatedResources.newBuilder().build())
2251             .setServiceAccount("serviceAccount1079137720")
2252             .setManualBatchTuningParameters(ManualBatchTuningParameters.newBuilder().build())
2253             .setGenerateExplanation(true)
2254             .setExplanationSpec(ExplanationSpec.newBuilder().build())
2255             .setOutputInfo(BatchPredictionJob.OutputInfo.newBuilder().build())
2256             .setState(JobState.forNumber(0))
2257             .setError(Status.newBuilder().build())
2258             .addAllPartialFailures(new ArrayList<Status>())
2259             .setResourcesConsumed(ResourcesConsumed.newBuilder().build())
2260             .setCompletionStats(CompletionStats.newBuilder().build())
2261             .setCreateTime(Timestamp.newBuilder().build())
2262             .setStartTime(Timestamp.newBuilder().build())
2263             .setEndTime(Timestamp.newBuilder().build())
2264             .setUpdateTime(Timestamp.newBuilder().build())
2265             .putAllLabels(new HashMap<String, String>())
2266             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2267             .setModelMonitoringConfig(ModelMonitoringConfig.newBuilder().build())
2268             .addAllModelMonitoringStatsAnomalies(new ArrayList<ModelMonitoringStatsAnomalies>())
2269             .setModelMonitoringStatus(Status.newBuilder().build())
2270             .setDisableContainerLogging(true)
2271             .build();
2272     mockJobService.addResponse(expectedResponse);
2273 
2274     String parent = "parent-995424086";
2275     BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().build();
2276 
2277     BatchPredictionJob actualResponse = client.createBatchPredictionJob(parent, batchPredictionJob);
2278     Assert.assertEquals(expectedResponse, actualResponse);
2279 
2280     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2281     Assert.assertEquals(1, actualRequests.size());
2282     CreateBatchPredictionJobRequest actualRequest =
2283         ((CreateBatchPredictionJobRequest) actualRequests.get(0));
2284 
2285     Assert.assertEquals(parent, actualRequest.getParent());
2286     Assert.assertEquals(batchPredictionJob, actualRequest.getBatchPredictionJob());
2287     Assert.assertTrue(
2288         channelProvider.isHeaderSent(
2289             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2290             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2291   }
2292 
2293   @Test
createBatchPredictionJobExceptionTest2()2294   public void createBatchPredictionJobExceptionTest2() throws Exception {
2295     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2296     mockJobService.addException(exception);
2297 
2298     try {
2299       String parent = "parent-995424086";
2300       BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().build();
2301       client.createBatchPredictionJob(parent, batchPredictionJob);
2302       Assert.fail("No exception raised");
2303     } catch (InvalidArgumentException e) {
2304       // Expected exception.
2305     }
2306   }
2307 
2308   @Test
getBatchPredictionJobTest()2309   public void getBatchPredictionJobTest() throws Exception {
2310     BatchPredictionJob expectedResponse =
2311         BatchPredictionJob.newBuilder()
2312             .setName(
2313                 BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]")
2314                     .toString())
2315             .setDisplayName("displayName1714148973")
2316             .setModel(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
2317             .setModelVersionId("modelVersionId-2006125846")
2318             .setUnmanagedContainerModel(UnmanagedContainerModel.newBuilder().build())
2319             .setInputConfig(BatchPredictionJob.InputConfig.newBuilder().build())
2320             .setInstanceConfig(BatchPredictionJob.InstanceConfig.newBuilder().build())
2321             .setModelParameters(Value.newBuilder().setBoolValue(true).build())
2322             .setOutputConfig(BatchPredictionJob.OutputConfig.newBuilder().build())
2323             .setDedicatedResources(BatchDedicatedResources.newBuilder().build())
2324             .setServiceAccount("serviceAccount1079137720")
2325             .setManualBatchTuningParameters(ManualBatchTuningParameters.newBuilder().build())
2326             .setGenerateExplanation(true)
2327             .setExplanationSpec(ExplanationSpec.newBuilder().build())
2328             .setOutputInfo(BatchPredictionJob.OutputInfo.newBuilder().build())
2329             .setState(JobState.forNumber(0))
2330             .setError(Status.newBuilder().build())
2331             .addAllPartialFailures(new ArrayList<Status>())
2332             .setResourcesConsumed(ResourcesConsumed.newBuilder().build())
2333             .setCompletionStats(CompletionStats.newBuilder().build())
2334             .setCreateTime(Timestamp.newBuilder().build())
2335             .setStartTime(Timestamp.newBuilder().build())
2336             .setEndTime(Timestamp.newBuilder().build())
2337             .setUpdateTime(Timestamp.newBuilder().build())
2338             .putAllLabels(new HashMap<String, String>())
2339             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2340             .setModelMonitoringConfig(ModelMonitoringConfig.newBuilder().build())
2341             .addAllModelMonitoringStatsAnomalies(new ArrayList<ModelMonitoringStatsAnomalies>())
2342             .setModelMonitoringStatus(Status.newBuilder().build())
2343             .setDisableContainerLogging(true)
2344             .build();
2345     mockJobService.addResponse(expectedResponse);
2346 
2347     BatchPredictionJobName name =
2348         BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2349 
2350     BatchPredictionJob actualResponse = client.getBatchPredictionJob(name);
2351     Assert.assertEquals(expectedResponse, actualResponse);
2352 
2353     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2354     Assert.assertEquals(1, actualRequests.size());
2355     GetBatchPredictionJobRequest actualRequest =
2356         ((GetBatchPredictionJobRequest) actualRequests.get(0));
2357 
2358     Assert.assertEquals(name.toString(), actualRequest.getName());
2359     Assert.assertTrue(
2360         channelProvider.isHeaderSent(
2361             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2362             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2363   }
2364 
2365   @Test
getBatchPredictionJobExceptionTest()2366   public void getBatchPredictionJobExceptionTest() throws Exception {
2367     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2368     mockJobService.addException(exception);
2369 
2370     try {
2371       BatchPredictionJobName name =
2372           BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2373       client.getBatchPredictionJob(name);
2374       Assert.fail("No exception raised");
2375     } catch (InvalidArgumentException e) {
2376       // Expected exception.
2377     }
2378   }
2379 
2380   @Test
getBatchPredictionJobTest2()2381   public void getBatchPredictionJobTest2() throws Exception {
2382     BatchPredictionJob expectedResponse =
2383         BatchPredictionJob.newBuilder()
2384             .setName(
2385                 BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]")
2386                     .toString())
2387             .setDisplayName("displayName1714148973")
2388             .setModel(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
2389             .setModelVersionId("modelVersionId-2006125846")
2390             .setUnmanagedContainerModel(UnmanagedContainerModel.newBuilder().build())
2391             .setInputConfig(BatchPredictionJob.InputConfig.newBuilder().build())
2392             .setInstanceConfig(BatchPredictionJob.InstanceConfig.newBuilder().build())
2393             .setModelParameters(Value.newBuilder().setBoolValue(true).build())
2394             .setOutputConfig(BatchPredictionJob.OutputConfig.newBuilder().build())
2395             .setDedicatedResources(BatchDedicatedResources.newBuilder().build())
2396             .setServiceAccount("serviceAccount1079137720")
2397             .setManualBatchTuningParameters(ManualBatchTuningParameters.newBuilder().build())
2398             .setGenerateExplanation(true)
2399             .setExplanationSpec(ExplanationSpec.newBuilder().build())
2400             .setOutputInfo(BatchPredictionJob.OutputInfo.newBuilder().build())
2401             .setState(JobState.forNumber(0))
2402             .setError(Status.newBuilder().build())
2403             .addAllPartialFailures(new ArrayList<Status>())
2404             .setResourcesConsumed(ResourcesConsumed.newBuilder().build())
2405             .setCompletionStats(CompletionStats.newBuilder().build())
2406             .setCreateTime(Timestamp.newBuilder().build())
2407             .setStartTime(Timestamp.newBuilder().build())
2408             .setEndTime(Timestamp.newBuilder().build())
2409             .setUpdateTime(Timestamp.newBuilder().build())
2410             .putAllLabels(new HashMap<String, String>())
2411             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2412             .setModelMonitoringConfig(ModelMonitoringConfig.newBuilder().build())
2413             .addAllModelMonitoringStatsAnomalies(new ArrayList<ModelMonitoringStatsAnomalies>())
2414             .setModelMonitoringStatus(Status.newBuilder().build())
2415             .setDisableContainerLogging(true)
2416             .build();
2417     mockJobService.addResponse(expectedResponse);
2418 
2419     String name = "name3373707";
2420 
2421     BatchPredictionJob actualResponse = client.getBatchPredictionJob(name);
2422     Assert.assertEquals(expectedResponse, actualResponse);
2423 
2424     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2425     Assert.assertEquals(1, actualRequests.size());
2426     GetBatchPredictionJobRequest actualRequest =
2427         ((GetBatchPredictionJobRequest) actualRequests.get(0));
2428 
2429     Assert.assertEquals(name, actualRequest.getName());
2430     Assert.assertTrue(
2431         channelProvider.isHeaderSent(
2432             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2433             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2434   }
2435 
2436   @Test
getBatchPredictionJobExceptionTest2()2437   public void getBatchPredictionJobExceptionTest2() throws Exception {
2438     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2439     mockJobService.addException(exception);
2440 
2441     try {
2442       String name = "name3373707";
2443       client.getBatchPredictionJob(name);
2444       Assert.fail("No exception raised");
2445     } catch (InvalidArgumentException e) {
2446       // Expected exception.
2447     }
2448   }
2449 
2450   @Test
listBatchPredictionJobsTest()2451   public void listBatchPredictionJobsTest() throws Exception {
2452     BatchPredictionJob responsesElement = BatchPredictionJob.newBuilder().build();
2453     ListBatchPredictionJobsResponse expectedResponse =
2454         ListBatchPredictionJobsResponse.newBuilder()
2455             .setNextPageToken("")
2456             .addAllBatchPredictionJobs(Arrays.asList(responsesElement))
2457             .build();
2458     mockJobService.addResponse(expectedResponse);
2459 
2460     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2461 
2462     ListBatchPredictionJobsPagedResponse pagedListResponse = client.listBatchPredictionJobs(parent);
2463 
2464     List<BatchPredictionJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2465 
2466     Assert.assertEquals(1, resources.size());
2467     Assert.assertEquals(expectedResponse.getBatchPredictionJobsList().get(0), resources.get(0));
2468 
2469     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2470     Assert.assertEquals(1, actualRequests.size());
2471     ListBatchPredictionJobsRequest actualRequest =
2472         ((ListBatchPredictionJobsRequest) actualRequests.get(0));
2473 
2474     Assert.assertEquals(parent.toString(), actualRequest.getParent());
2475     Assert.assertTrue(
2476         channelProvider.isHeaderSent(
2477             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2478             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2479   }
2480 
2481   @Test
listBatchPredictionJobsExceptionTest()2482   public void listBatchPredictionJobsExceptionTest() throws Exception {
2483     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2484     mockJobService.addException(exception);
2485 
2486     try {
2487       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2488       client.listBatchPredictionJobs(parent);
2489       Assert.fail("No exception raised");
2490     } catch (InvalidArgumentException e) {
2491       // Expected exception.
2492     }
2493   }
2494 
2495   @Test
listBatchPredictionJobsTest2()2496   public void listBatchPredictionJobsTest2() throws Exception {
2497     BatchPredictionJob responsesElement = BatchPredictionJob.newBuilder().build();
2498     ListBatchPredictionJobsResponse expectedResponse =
2499         ListBatchPredictionJobsResponse.newBuilder()
2500             .setNextPageToken("")
2501             .addAllBatchPredictionJobs(Arrays.asList(responsesElement))
2502             .build();
2503     mockJobService.addResponse(expectedResponse);
2504 
2505     String parent = "parent-995424086";
2506 
2507     ListBatchPredictionJobsPagedResponse pagedListResponse = client.listBatchPredictionJobs(parent);
2508 
2509     List<BatchPredictionJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2510 
2511     Assert.assertEquals(1, resources.size());
2512     Assert.assertEquals(expectedResponse.getBatchPredictionJobsList().get(0), resources.get(0));
2513 
2514     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2515     Assert.assertEquals(1, actualRequests.size());
2516     ListBatchPredictionJobsRequest actualRequest =
2517         ((ListBatchPredictionJobsRequest) actualRequests.get(0));
2518 
2519     Assert.assertEquals(parent, actualRequest.getParent());
2520     Assert.assertTrue(
2521         channelProvider.isHeaderSent(
2522             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2523             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2524   }
2525 
2526   @Test
listBatchPredictionJobsExceptionTest2()2527   public void listBatchPredictionJobsExceptionTest2() throws Exception {
2528     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2529     mockJobService.addException(exception);
2530 
2531     try {
2532       String parent = "parent-995424086";
2533       client.listBatchPredictionJobs(parent);
2534       Assert.fail("No exception raised");
2535     } catch (InvalidArgumentException e) {
2536       // Expected exception.
2537     }
2538   }
2539 
2540   @Test
deleteBatchPredictionJobTest()2541   public void deleteBatchPredictionJobTest() throws Exception {
2542     Empty expectedResponse = Empty.newBuilder().build();
2543     Operation resultOperation =
2544         Operation.newBuilder()
2545             .setName("deleteBatchPredictionJobTest")
2546             .setDone(true)
2547             .setResponse(Any.pack(expectedResponse))
2548             .build();
2549     mockJobService.addResponse(resultOperation);
2550 
2551     BatchPredictionJobName name =
2552         BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2553 
2554     client.deleteBatchPredictionJobAsync(name).get();
2555 
2556     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2557     Assert.assertEquals(1, actualRequests.size());
2558     DeleteBatchPredictionJobRequest actualRequest =
2559         ((DeleteBatchPredictionJobRequest) actualRequests.get(0));
2560 
2561     Assert.assertEquals(name.toString(), actualRequest.getName());
2562     Assert.assertTrue(
2563         channelProvider.isHeaderSent(
2564             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2565             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2566   }
2567 
2568   @Test
deleteBatchPredictionJobExceptionTest()2569   public void deleteBatchPredictionJobExceptionTest() throws Exception {
2570     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2571     mockJobService.addException(exception);
2572 
2573     try {
2574       BatchPredictionJobName name =
2575           BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2576       client.deleteBatchPredictionJobAsync(name).get();
2577       Assert.fail("No exception raised");
2578     } catch (ExecutionException e) {
2579       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
2580       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
2581       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
2582     }
2583   }
2584 
2585   @Test
deleteBatchPredictionJobTest2()2586   public void deleteBatchPredictionJobTest2() throws Exception {
2587     Empty expectedResponse = Empty.newBuilder().build();
2588     Operation resultOperation =
2589         Operation.newBuilder()
2590             .setName("deleteBatchPredictionJobTest")
2591             .setDone(true)
2592             .setResponse(Any.pack(expectedResponse))
2593             .build();
2594     mockJobService.addResponse(resultOperation);
2595 
2596     String name = "name3373707";
2597 
2598     client.deleteBatchPredictionJobAsync(name).get();
2599 
2600     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2601     Assert.assertEquals(1, actualRequests.size());
2602     DeleteBatchPredictionJobRequest actualRequest =
2603         ((DeleteBatchPredictionJobRequest) actualRequests.get(0));
2604 
2605     Assert.assertEquals(name, actualRequest.getName());
2606     Assert.assertTrue(
2607         channelProvider.isHeaderSent(
2608             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2609             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2610   }
2611 
2612   @Test
deleteBatchPredictionJobExceptionTest2()2613   public void deleteBatchPredictionJobExceptionTest2() throws Exception {
2614     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2615     mockJobService.addException(exception);
2616 
2617     try {
2618       String name = "name3373707";
2619       client.deleteBatchPredictionJobAsync(name).get();
2620       Assert.fail("No exception raised");
2621     } catch (ExecutionException e) {
2622       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
2623       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
2624       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
2625     }
2626   }
2627 
2628   @Test
cancelBatchPredictionJobTest()2629   public void cancelBatchPredictionJobTest() throws Exception {
2630     Empty expectedResponse = Empty.newBuilder().build();
2631     mockJobService.addResponse(expectedResponse);
2632 
2633     BatchPredictionJobName name =
2634         BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2635 
2636     client.cancelBatchPredictionJob(name);
2637 
2638     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2639     Assert.assertEquals(1, actualRequests.size());
2640     CancelBatchPredictionJobRequest actualRequest =
2641         ((CancelBatchPredictionJobRequest) actualRequests.get(0));
2642 
2643     Assert.assertEquals(name.toString(), actualRequest.getName());
2644     Assert.assertTrue(
2645         channelProvider.isHeaderSent(
2646             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2647             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2648   }
2649 
2650   @Test
cancelBatchPredictionJobExceptionTest()2651   public void cancelBatchPredictionJobExceptionTest() throws Exception {
2652     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2653     mockJobService.addException(exception);
2654 
2655     try {
2656       BatchPredictionJobName name =
2657           BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2658       client.cancelBatchPredictionJob(name);
2659       Assert.fail("No exception raised");
2660     } catch (InvalidArgumentException e) {
2661       // Expected exception.
2662     }
2663   }
2664 
2665   @Test
cancelBatchPredictionJobTest2()2666   public void cancelBatchPredictionJobTest2() throws Exception {
2667     Empty expectedResponse = Empty.newBuilder().build();
2668     mockJobService.addResponse(expectedResponse);
2669 
2670     String name = "name3373707";
2671 
2672     client.cancelBatchPredictionJob(name);
2673 
2674     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2675     Assert.assertEquals(1, actualRequests.size());
2676     CancelBatchPredictionJobRequest actualRequest =
2677         ((CancelBatchPredictionJobRequest) actualRequests.get(0));
2678 
2679     Assert.assertEquals(name, actualRequest.getName());
2680     Assert.assertTrue(
2681         channelProvider.isHeaderSent(
2682             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2683             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2684   }
2685 
2686   @Test
cancelBatchPredictionJobExceptionTest2()2687   public void cancelBatchPredictionJobExceptionTest2() throws Exception {
2688     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2689     mockJobService.addException(exception);
2690 
2691     try {
2692       String name = "name3373707";
2693       client.cancelBatchPredictionJob(name);
2694       Assert.fail("No exception raised");
2695     } catch (InvalidArgumentException e) {
2696       // Expected exception.
2697     }
2698   }
2699 
2700   @Test
createModelDeploymentMonitoringJobTest()2701   public void createModelDeploymentMonitoringJobTest() throws Exception {
2702     ModelDeploymentMonitoringJob expectedResponse =
2703         ModelDeploymentMonitoringJob.newBuilder()
2704             .setName(
2705                 ModelDeploymentMonitoringJobName.of(
2706                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
2707                     .toString())
2708             .setDisplayName("displayName1714148973")
2709             .setEndpoint(
2710                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
2711                     .toString())
2712             .setState(JobState.forNumber(0))
2713             .setLatestMonitoringPipelineMetadata(
2714                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
2715             .addAllModelDeploymentMonitoringObjectiveConfigs(
2716                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
2717             .setModelDeploymentMonitoringScheduleConfig(
2718                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
2719             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
2720             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
2721             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
2722             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
2723             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
2724             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
2725             .setLogTtl(Duration.newBuilder().build())
2726             .putAllLabels(new HashMap<String, String>())
2727             .setCreateTime(Timestamp.newBuilder().build())
2728             .setUpdateTime(Timestamp.newBuilder().build())
2729             .setNextScheduleTime(Timestamp.newBuilder().build())
2730             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
2731             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2732             .setEnableMonitoringPipelineLogs(true)
2733             .setError(Status.newBuilder().build())
2734             .build();
2735     mockJobService.addResponse(expectedResponse);
2736 
2737     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2738     ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
2739         ModelDeploymentMonitoringJob.newBuilder().build();
2740 
2741     ModelDeploymentMonitoringJob actualResponse =
2742         client.createModelDeploymentMonitoringJob(parent, modelDeploymentMonitoringJob);
2743     Assert.assertEquals(expectedResponse, actualResponse);
2744 
2745     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2746     Assert.assertEquals(1, actualRequests.size());
2747     CreateModelDeploymentMonitoringJobRequest actualRequest =
2748         ((CreateModelDeploymentMonitoringJobRequest) actualRequests.get(0));
2749 
2750     Assert.assertEquals(parent.toString(), actualRequest.getParent());
2751     Assert.assertEquals(
2752         modelDeploymentMonitoringJob, actualRequest.getModelDeploymentMonitoringJob());
2753     Assert.assertTrue(
2754         channelProvider.isHeaderSent(
2755             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2756             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2757   }
2758 
2759   @Test
createModelDeploymentMonitoringJobExceptionTest()2760   public void createModelDeploymentMonitoringJobExceptionTest() throws Exception {
2761     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2762     mockJobService.addException(exception);
2763 
2764     try {
2765       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2766       ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
2767           ModelDeploymentMonitoringJob.newBuilder().build();
2768       client.createModelDeploymentMonitoringJob(parent, modelDeploymentMonitoringJob);
2769       Assert.fail("No exception raised");
2770     } catch (InvalidArgumentException e) {
2771       // Expected exception.
2772     }
2773   }
2774 
2775   @Test
createModelDeploymentMonitoringJobTest2()2776   public void createModelDeploymentMonitoringJobTest2() throws Exception {
2777     ModelDeploymentMonitoringJob expectedResponse =
2778         ModelDeploymentMonitoringJob.newBuilder()
2779             .setName(
2780                 ModelDeploymentMonitoringJobName.of(
2781                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
2782                     .toString())
2783             .setDisplayName("displayName1714148973")
2784             .setEndpoint(
2785                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
2786                     .toString())
2787             .setState(JobState.forNumber(0))
2788             .setLatestMonitoringPipelineMetadata(
2789                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
2790             .addAllModelDeploymentMonitoringObjectiveConfigs(
2791                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
2792             .setModelDeploymentMonitoringScheduleConfig(
2793                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
2794             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
2795             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
2796             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
2797             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
2798             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
2799             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
2800             .setLogTtl(Duration.newBuilder().build())
2801             .putAllLabels(new HashMap<String, String>())
2802             .setCreateTime(Timestamp.newBuilder().build())
2803             .setUpdateTime(Timestamp.newBuilder().build())
2804             .setNextScheduleTime(Timestamp.newBuilder().build())
2805             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
2806             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2807             .setEnableMonitoringPipelineLogs(true)
2808             .setError(Status.newBuilder().build())
2809             .build();
2810     mockJobService.addResponse(expectedResponse);
2811 
2812     String parent = "parent-995424086";
2813     ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
2814         ModelDeploymentMonitoringJob.newBuilder().build();
2815 
2816     ModelDeploymentMonitoringJob actualResponse =
2817         client.createModelDeploymentMonitoringJob(parent, modelDeploymentMonitoringJob);
2818     Assert.assertEquals(expectedResponse, actualResponse);
2819 
2820     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2821     Assert.assertEquals(1, actualRequests.size());
2822     CreateModelDeploymentMonitoringJobRequest actualRequest =
2823         ((CreateModelDeploymentMonitoringJobRequest) actualRequests.get(0));
2824 
2825     Assert.assertEquals(parent, actualRequest.getParent());
2826     Assert.assertEquals(
2827         modelDeploymentMonitoringJob, actualRequest.getModelDeploymentMonitoringJob());
2828     Assert.assertTrue(
2829         channelProvider.isHeaderSent(
2830             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2831             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2832   }
2833 
2834   @Test
createModelDeploymentMonitoringJobExceptionTest2()2835   public void createModelDeploymentMonitoringJobExceptionTest2() throws Exception {
2836     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2837     mockJobService.addException(exception);
2838 
2839     try {
2840       String parent = "parent-995424086";
2841       ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
2842           ModelDeploymentMonitoringJob.newBuilder().build();
2843       client.createModelDeploymentMonitoringJob(parent, modelDeploymentMonitoringJob);
2844       Assert.fail("No exception raised");
2845     } catch (InvalidArgumentException e) {
2846       // Expected exception.
2847     }
2848   }
2849 
2850   @Test
searchModelDeploymentMonitoringStatsAnomaliesTest()2851   public void searchModelDeploymentMonitoringStatsAnomaliesTest() throws Exception {
2852     ModelMonitoringStatsAnomalies responsesElement =
2853         ModelMonitoringStatsAnomalies.newBuilder().build();
2854     SearchModelDeploymentMonitoringStatsAnomaliesResponse expectedResponse =
2855         SearchModelDeploymentMonitoringStatsAnomaliesResponse.newBuilder()
2856             .setNextPageToken("")
2857             .addAllMonitoringStats(Arrays.asList(responsesElement))
2858             .build();
2859     mockJobService.addResponse(expectedResponse);
2860 
2861     ModelDeploymentMonitoringJobName modelDeploymentMonitoringJob =
2862         ModelDeploymentMonitoringJobName.of(
2863             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
2864     String deployedModelId = "deployedModelId-1817547906";
2865 
2866     SearchModelDeploymentMonitoringStatsAnomaliesPagedResponse pagedListResponse =
2867         client.searchModelDeploymentMonitoringStatsAnomalies(
2868             modelDeploymentMonitoringJob, deployedModelId);
2869 
2870     List<ModelMonitoringStatsAnomalies> resources =
2871         Lists.newArrayList(pagedListResponse.iterateAll());
2872 
2873     Assert.assertEquals(1, resources.size());
2874     Assert.assertEquals(expectedResponse.getMonitoringStatsList().get(0), resources.get(0));
2875 
2876     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2877     Assert.assertEquals(1, actualRequests.size());
2878     SearchModelDeploymentMonitoringStatsAnomaliesRequest actualRequest =
2879         ((SearchModelDeploymentMonitoringStatsAnomaliesRequest) actualRequests.get(0));
2880 
2881     Assert.assertEquals(
2882         modelDeploymentMonitoringJob.toString(), actualRequest.getModelDeploymentMonitoringJob());
2883     Assert.assertEquals(deployedModelId, actualRequest.getDeployedModelId());
2884     Assert.assertTrue(
2885         channelProvider.isHeaderSent(
2886             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2887             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2888   }
2889 
2890   @Test
searchModelDeploymentMonitoringStatsAnomaliesExceptionTest()2891   public void searchModelDeploymentMonitoringStatsAnomaliesExceptionTest() throws Exception {
2892     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2893     mockJobService.addException(exception);
2894 
2895     try {
2896       ModelDeploymentMonitoringJobName modelDeploymentMonitoringJob =
2897           ModelDeploymentMonitoringJobName.of(
2898               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
2899       String deployedModelId = "deployedModelId-1817547906";
2900       client.searchModelDeploymentMonitoringStatsAnomalies(
2901           modelDeploymentMonitoringJob, deployedModelId);
2902       Assert.fail("No exception raised");
2903     } catch (InvalidArgumentException e) {
2904       // Expected exception.
2905     }
2906   }
2907 
2908   @Test
searchModelDeploymentMonitoringStatsAnomaliesTest2()2909   public void searchModelDeploymentMonitoringStatsAnomaliesTest2() throws Exception {
2910     ModelMonitoringStatsAnomalies responsesElement =
2911         ModelMonitoringStatsAnomalies.newBuilder().build();
2912     SearchModelDeploymentMonitoringStatsAnomaliesResponse expectedResponse =
2913         SearchModelDeploymentMonitoringStatsAnomaliesResponse.newBuilder()
2914             .setNextPageToken("")
2915             .addAllMonitoringStats(Arrays.asList(responsesElement))
2916             .build();
2917     mockJobService.addResponse(expectedResponse);
2918 
2919     String modelDeploymentMonitoringJob = "modelDeploymentMonitoringJob-1178077657";
2920     String deployedModelId = "deployedModelId-1817547906";
2921 
2922     SearchModelDeploymentMonitoringStatsAnomaliesPagedResponse pagedListResponse =
2923         client.searchModelDeploymentMonitoringStatsAnomalies(
2924             modelDeploymentMonitoringJob, deployedModelId);
2925 
2926     List<ModelMonitoringStatsAnomalies> resources =
2927         Lists.newArrayList(pagedListResponse.iterateAll());
2928 
2929     Assert.assertEquals(1, resources.size());
2930     Assert.assertEquals(expectedResponse.getMonitoringStatsList().get(0), resources.get(0));
2931 
2932     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2933     Assert.assertEquals(1, actualRequests.size());
2934     SearchModelDeploymentMonitoringStatsAnomaliesRequest actualRequest =
2935         ((SearchModelDeploymentMonitoringStatsAnomaliesRequest) actualRequests.get(0));
2936 
2937     Assert.assertEquals(
2938         modelDeploymentMonitoringJob, actualRequest.getModelDeploymentMonitoringJob());
2939     Assert.assertEquals(deployedModelId, actualRequest.getDeployedModelId());
2940     Assert.assertTrue(
2941         channelProvider.isHeaderSent(
2942             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2943             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2944   }
2945 
2946   @Test
searchModelDeploymentMonitoringStatsAnomaliesExceptionTest2()2947   public void searchModelDeploymentMonitoringStatsAnomaliesExceptionTest2() throws Exception {
2948     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2949     mockJobService.addException(exception);
2950 
2951     try {
2952       String modelDeploymentMonitoringJob = "modelDeploymentMonitoringJob-1178077657";
2953       String deployedModelId = "deployedModelId-1817547906";
2954       client.searchModelDeploymentMonitoringStatsAnomalies(
2955           modelDeploymentMonitoringJob, deployedModelId);
2956       Assert.fail("No exception raised");
2957     } catch (InvalidArgumentException e) {
2958       // Expected exception.
2959     }
2960   }
2961 
2962   @Test
getModelDeploymentMonitoringJobTest()2963   public void getModelDeploymentMonitoringJobTest() throws Exception {
2964     ModelDeploymentMonitoringJob expectedResponse =
2965         ModelDeploymentMonitoringJob.newBuilder()
2966             .setName(
2967                 ModelDeploymentMonitoringJobName.of(
2968                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
2969                     .toString())
2970             .setDisplayName("displayName1714148973")
2971             .setEndpoint(
2972                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
2973                     .toString())
2974             .setState(JobState.forNumber(0))
2975             .setLatestMonitoringPipelineMetadata(
2976                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
2977             .addAllModelDeploymentMonitoringObjectiveConfigs(
2978                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
2979             .setModelDeploymentMonitoringScheduleConfig(
2980                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
2981             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
2982             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
2983             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
2984             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
2985             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
2986             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
2987             .setLogTtl(Duration.newBuilder().build())
2988             .putAllLabels(new HashMap<String, String>())
2989             .setCreateTime(Timestamp.newBuilder().build())
2990             .setUpdateTime(Timestamp.newBuilder().build())
2991             .setNextScheduleTime(Timestamp.newBuilder().build())
2992             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
2993             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2994             .setEnableMonitoringPipelineLogs(true)
2995             .setError(Status.newBuilder().build())
2996             .build();
2997     mockJobService.addResponse(expectedResponse);
2998 
2999     ModelDeploymentMonitoringJobName name =
3000         ModelDeploymentMonitoringJobName.of(
3001             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3002 
3003     ModelDeploymentMonitoringJob actualResponse = client.getModelDeploymentMonitoringJob(name);
3004     Assert.assertEquals(expectedResponse, actualResponse);
3005 
3006     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3007     Assert.assertEquals(1, actualRequests.size());
3008     GetModelDeploymentMonitoringJobRequest actualRequest =
3009         ((GetModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3010 
3011     Assert.assertEquals(name.toString(), actualRequest.getName());
3012     Assert.assertTrue(
3013         channelProvider.isHeaderSent(
3014             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3015             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3016   }
3017 
3018   @Test
getModelDeploymentMonitoringJobExceptionTest()3019   public void getModelDeploymentMonitoringJobExceptionTest() throws Exception {
3020     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3021     mockJobService.addException(exception);
3022 
3023     try {
3024       ModelDeploymentMonitoringJobName name =
3025           ModelDeploymentMonitoringJobName.of(
3026               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3027       client.getModelDeploymentMonitoringJob(name);
3028       Assert.fail("No exception raised");
3029     } catch (InvalidArgumentException e) {
3030       // Expected exception.
3031     }
3032   }
3033 
3034   @Test
getModelDeploymentMonitoringJobTest2()3035   public void getModelDeploymentMonitoringJobTest2() throws Exception {
3036     ModelDeploymentMonitoringJob expectedResponse =
3037         ModelDeploymentMonitoringJob.newBuilder()
3038             .setName(
3039                 ModelDeploymentMonitoringJobName.of(
3040                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
3041                     .toString())
3042             .setDisplayName("displayName1714148973")
3043             .setEndpoint(
3044                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3045                     .toString())
3046             .setState(JobState.forNumber(0))
3047             .setLatestMonitoringPipelineMetadata(
3048                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
3049             .addAllModelDeploymentMonitoringObjectiveConfigs(
3050                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
3051             .setModelDeploymentMonitoringScheduleConfig(
3052                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
3053             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
3054             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
3055             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
3056             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
3057             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
3058             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
3059             .setLogTtl(Duration.newBuilder().build())
3060             .putAllLabels(new HashMap<String, String>())
3061             .setCreateTime(Timestamp.newBuilder().build())
3062             .setUpdateTime(Timestamp.newBuilder().build())
3063             .setNextScheduleTime(Timestamp.newBuilder().build())
3064             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
3065             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
3066             .setEnableMonitoringPipelineLogs(true)
3067             .setError(Status.newBuilder().build())
3068             .build();
3069     mockJobService.addResponse(expectedResponse);
3070 
3071     String name = "name3373707";
3072 
3073     ModelDeploymentMonitoringJob actualResponse = client.getModelDeploymentMonitoringJob(name);
3074     Assert.assertEquals(expectedResponse, actualResponse);
3075 
3076     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3077     Assert.assertEquals(1, actualRequests.size());
3078     GetModelDeploymentMonitoringJobRequest actualRequest =
3079         ((GetModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3080 
3081     Assert.assertEquals(name, actualRequest.getName());
3082     Assert.assertTrue(
3083         channelProvider.isHeaderSent(
3084             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3085             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3086   }
3087 
3088   @Test
getModelDeploymentMonitoringJobExceptionTest2()3089   public void getModelDeploymentMonitoringJobExceptionTest2() throws Exception {
3090     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3091     mockJobService.addException(exception);
3092 
3093     try {
3094       String name = "name3373707";
3095       client.getModelDeploymentMonitoringJob(name);
3096       Assert.fail("No exception raised");
3097     } catch (InvalidArgumentException e) {
3098       // Expected exception.
3099     }
3100   }
3101 
3102   @Test
listModelDeploymentMonitoringJobsTest()3103   public void listModelDeploymentMonitoringJobsTest() throws Exception {
3104     ModelDeploymentMonitoringJob responsesElement =
3105         ModelDeploymentMonitoringJob.newBuilder().build();
3106     ListModelDeploymentMonitoringJobsResponse expectedResponse =
3107         ListModelDeploymentMonitoringJobsResponse.newBuilder()
3108             .setNextPageToken("")
3109             .addAllModelDeploymentMonitoringJobs(Arrays.asList(responsesElement))
3110             .build();
3111     mockJobService.addResponse(expectedResponse);
3112 
3113     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
3114 
3115     ListModelDeploymentMonitoringJobsPagedResponse pagedListResponse =
3116         client.listModelDeploymentMonitoringJobs(parent);
3117 
3118     List<ModelDeploymentMonitoringJob> resources =
3119         Lists.newArrayList(pagedListResponse.iterateAll());
3120 
3121     Assert.assertEquals(1, resources.size());
3122     Assert.assertEquals(
3123         expectedResponse.getModelDeploymentMonitoringJobsList().get(0), resources.get(0));
3124 
3125     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3126     Assert.assertEquals(1, actualRequests.size());
3127     ListModelDeploymentMonitoringJobsRequest actualRequest =
3128         ((ListModelDeploymentMonitoringJobsRequest) actualRequests.get(0));
3129 
3130     Assert.assertEquals(parent.toString(), actualRequest.getParent());
3131     Assert.assertTrue(
3132         channelProvider.isHeaderSent(
3133             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3134             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3135   }
3136 
3137   @Test
listModelDeploymentMonitoringJobsExceptionTest()3138   public void listModelDeploymentMonitoringJobsExceptionTest() throws Exception {
3139     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3140     mockJobService.addException(exception);
3141 
3142     try {
3143       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
3144       client.listModelDeploymentMonitoringJobs(parent);
3145       Assert.fail("No exception raised");
3146     } catch (InvalidArgumentException e) {
3147       // Expected exception.
3148     }
3149   }
3150 
3151   @Test
listModelDeploymentMonitoringJobsTest2()3152   public void listModelDeploymentMonitoringJobsTest2() throws Exception {
3153     ModelDeploymentMonitoringJob responsesElement =
3154         ModelDeploymentMonitoringJob.newBuilder().build();
3155     ListModelDeploymentMonitoringJobsResponse expectedResponse =
3156         ListModelDeploymentMonitoringJobsResponse.newBuilder()
3157             .setNextPageToken("")
3158             .addAllModelDeploymentMonitoringJobs(Arrays.asList(responsesElement))
3159             .build();
3160     mockJobService.addResponse(expectedResponse);
3161 
3162     String parent = "parent-995424086";
3163 
3164     ListModelDeploymentMonitoringJobsPagedResponse pagedListResponse =
3165         client.listModelDeploymentMonitoringJobs(parent);
3166 
3167     List<ModelDeploymentMonitoringJob> resources =
3168         Lists.newArrayList(pagedListResponse.iterateAll());
3169 
3170     Assert.assertEquals(1, resources.size());
3171     Assert.assertEquals(
3172         expectedResponse.getModelDeploymentMonitoringJobsList().get(0), resources.get(0));
3173 
3174     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3175     Assert.assertEquals(1, actualRequests.size());
3176     ListModelDeploymentMonitoringJobsRequest actualRequest =
3177         ((ListModelDeploymentMonitoringJobsRequest) actualRequests.get(0));
3178 
3179     Assert.assertEquals(parent, actualRequest.getParent());
3180     Assert.assertTrue(
3181         channelProvider.isHeaderSent(
3182             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3183             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3184   }
3185 
3186   @Test
listModelDeploymentMonitoringJobsExceptionTest2()3187   public void listModelDeploymentMonitoringJobsExceptionTest2() throws Exception {
3188     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3189     mockJobService.addException(exception);
3190 
3191     try {
3192       String parent = "parent-995424086";
3193       client.listModelDeploymentMonitoringJobs(parent);
3194       Assert.fail("No exception raised");
3195     } catch (InvalidArgumentException e) {
3196       // Expected exception.
3197     }
3198   }
3199 
3200   @Test
updateModelDeploymentMonitoringJobTest()3201   public void updateModelDeploymentMonitoringJobTest() throws Exception {
3202     ModelDeploymentMonitoringJob expectedResponse =
3203         ModelDeploymentMonitoringJob.newBuilder()
3204             .setName(
3205                 ModelDeploymentMonitoringJobName.of(
3206                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
3207                     .toString())
3208             .setDisplayName("displayName1714148973")
3209             .setEndpoint(
3210                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3211                     .toString())
3212             .setState(JobState.forNumber(0))
3213             .setLatestMonitoringPipelineMetadata(
3214                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
3215             .addAllModelDeploymentMonitoringObjectiveConfigs(
3216                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
3217             .setModelDeploymentMonitoringScheduleConfig(
3218                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
3219             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
3220             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
3221             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
3222             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
3223             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
3224             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
3225             .setLogTtl(Duration.newBuilder().build())
3226             .putAllLabels(new HashMap<String, String>())
3227             .setCreateTime(Timestamp.newBuilder().build())
3228             .setUpdateTime(Timestamp.newBuilder().build())
3229             .setNextScheduleTime(Timestamp.newBuilder().build())
3230             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
3231             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
3232             .setEnableMonitoringPipelineLogs(true)
3233             .setError(Status.newBuilder().build())
3234             .build();
3235     Operation resultOperation =
3236         Operation.newBuilder()
3237             .setName("updateModelDeploymentMonitoringJobTest")
3238             .setDone(true)
3239             .setResponse(Any.pack(expectedResponse))
3240             .build();
3241     mockJobService.addResponse(resultOperation);
3242 
3243     ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
3244         ModelDeploymentMonitoringJob.newBuilder().build();
3245     FieldMask updateMask = FieldMask.newBuilder().build();
3246 
3247     ModelDeploymentMonitoringJob actualResponse =
3248         client
3249             .updateModelDeploymentMonitoringJobAsync(modelDeploymentMonitoringJob, updateMask)
3250             .get();
3251     Assert.assertEquals(expectedResponse, actualResponse);
3252 
3253     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3254     Assert.assertEquals(1, actualRequests.size());
3255     UpdateModelDeploymentMonitoringJobRequest actualRequest =
3256         ((UpdateModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3257 
3258     Assert.assertEquals(
3259         modelDeploymentMonitoringJob, actualRequest.getModelDeploymentMonitoringJob());
3260     Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
3261     Assert.assertTrue(
3262         channelProvider.isHeaderSent(
3263             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3264             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3265   }
3266 
3267   @Test
updateModelDeploymentMonitoringJobExceptionTest()3268   public void updateModelDeploymentMonitoringJobExceptionTest() throws Exception {
3269     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3270     mockJobService.addException(exception);
3271 
3272     try {
3273       ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
3274           ModelDeploymentMonitoringJob.newBuilder().build();
3275       FieldMask updateMask = FieldMask.newBuilder().build();
3276       client
3277           .updateModelDeploymentMonitoringJobAsync(modelDeploymentMonitoringJob, updateMask)
3278           .get();
3279       Assert.fail("No exception raised");
3280     } catch (ExecutionException e) {
3281       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
3282       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
3283       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
3284     }
3285   }
3286 
3287   @Test
deleteModelDeploymentMonitoringJobTest()3288   public void deleteModelDeploymentMonitoringJobTest() throws Exception {
3289     Empty expectedResponse = Empty.newBuilder().build();
3290     Operation resultOperation =
3291         Operation.newBuilder()
3292             .setName("deleteModelDeploymentMonitoringJobTest")
3293             .setDone(true)
3294             .setResponse(Any.pack(expectedResponse))
3295             .build();
3296     mockJobService.addResponse(resultOperation);
3297 
3298     ModelDeploymentMonitoringJobName name =
3299         ModelDeploymentMonitoringJobName.of(
3300             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3301 
3302     client.deleteModelDeploymentMonitoringJobAsync(name).get();
3303 
3304     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3305     Assert.assertEquals(1, actualRequests.size());
3306     DeleteModelDeploymentMonitoringJobRequest actualRequest =
3307         ((DeleteModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3308 
3309     Assert.assertEquals(name.toString(), actualRequest.getName());
3310     Assert.assertTrue(
3311         channelProvider.isHeaderSent(
3312             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3313             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3314   }
3315 
3316   @Test
deleteModelDeploymentMonitoringJobExceptionTest()3317   public void deleteModelDeploymentMonitoringJobExceptionTest() throws Exception {
3318     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3319     mockJobService.addException(exception);
3320 
3321     try {
3322       ModelDeploymentMonitoringJobName name =
3323           ModelDeploymentMonitoringJobName.of(
3324               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3325       client.deleteModelDeploymentMonitoringJobAsync(name).get();
3326       Assert.fail("No exception raised");
3327     } catch (ExecutionException e) {
3328       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
3329       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
3330       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
3331     }
3332   }
3333 
3334   @Test
deleteModelDeploymentMonitoringJobTest2()3335   public void deleteModelDeploymentMonitoringJobTest2() throws Exception {
3336     Empty expectedResponse = Empty.newBuilder().build();
3337     Operation resultOperation =
3338         Operation.newBuilder()
3339             .setName("deleteModelDeploymentMonitoringJobTest")
3340             .setDone(true)
3341             .setResponse(Any.pack(expectedResponse))
3342             .build();
3343     mockJobService.addResponse(resultOperation);
3344 
3345     String name = "name3373707";
3346 
3347     client.deleteModelDeploymentMonitoringJobAsync(name).get();
3348 
3349     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3350     Assert.assertEquals(1, actualRequests.size());
3351     DeleteModelDeploymentMonitoringJobRequest actualRequest =
3352         ((DeleteModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3353 
3354     Assert.assertEquals(name, actualRequest.getName());
3355     Assert.assertTrue(
3356         channelProvider.isHeaderSent(
3357             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3358             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3359   }
3360 
3361   @Test
deleteModelDeploymentMonitoringJobExceptionTest2()3362   public void deleteModelDeploymentMonitoringJobExceptionTest2() throws Exception {
3363     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3364     mockJobService.addException(exception);
3365 
3366     try {
3367       String name = "name3373707";
3368       client.deleteModelDeploymentMonitoringJobAsync(name).get();
3369       Assert.fail("No exception raised");
3370     } catch (ExecutionException e) {
3371       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
3372       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
3373       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
3374     }
3375   }
3376 
3377   @Test
pauseModelDeploymentMonitoringJobTest()3378   public void pauseModelDeploymentMonitoringJobTest() throws Exception {
3379     Empty expectedResponse = Empty.newBuilder().build();
3380     mockJobService.addResponse(expectedResponse);
3381 
3382     ModelDeploymentMonitoringJobName name =
3383         ModelDeploymentMonitoringJobName.of(
3384             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3385 
3386     client.pauseModelDeploymentMonitoringJob(name);
3387 
3388     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3389     Assert.assertEquals(1, actualRequests.size());
3390     PauseModelDeploymentMonitoringJobRequest actualRequest =
3391         ((PauseModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3392 
3393     Assert.assertEquals(name.toString(), actualRequest.getName());
3394     Assert.assertTrue(
3395         channelProvider.isHeaderSent(
3396             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3397             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3398   }
3399 
3400   @Test
pauseModelDeploymentMonitoringJobExceptionTest()3401   public void pauseModelDeploymentMonitoringJobExceptionTest() throws Exception {
3402     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3403     mockJobService.addException(exception);
3404 
3405     try {
3406       ModelDeploymentMonitoringJobName name =
3407           ModelDeploymentMonitoringJobName.of(
3408               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3409       client.pauseModelDeploymentMonitoringJob(name);
3410       Assert.fail("No exception raised");
3411     } catch (InvalidArgumentException e) {
3412       // Expected exception.
3413     }
3414   }
3415 
3416   @Test
pauseModelDeploymentMonitoringJobTest2()3417   public void pauseModelDeploymentMonitoringJobTest2() throws Exception {
3418     Empty expectedResponse = Empty.newBuilder().build();
3419     mockJobService.addResponse(expectedResponse);
3420 
3421     String name = "name3373707";
3422 
3423     client.pauseModelDeploymentMonitoringJob(name);
3424 
3425     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3426     Assert.assertEquals(1, actualRequests.size());
3427     PauseModelDeploymentMonitoringJobRequest actualRequest =
3428         ((PauseModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3429 
3430     Assert.assertEquals(name, actualRequest.getName());
3431     Assert.assertTrue(
3432         channelProvider.isHeaderSent(
3433             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3434             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3435   }
3436 
3437   @Test
pauseModelDeploymentMonitoringJobExceptionTest2()3438   public void pauseModelDeploymentMonitoringJobExceptionTest2() throws Exception {
3439     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3440     mockJobService.addException(exception);
3441 
3442     try {
3443       String name = "name3373707";
3444       client.pauseModelDeploymentMonitoringJob(name);
3445       Assert.fail("No exception raised");
3446     } catch (InvalidArgumentException e) {
3447       // Expected exception.
3448     }
3449   }
3450 
3451   @Test
resumeModelDeploymentMonitoringJobTest()3452   public void resumeModelDeploymentMonitoringJobTest() throws Exception {
3453     Empty expectedResponse = Empty.newBuilder().build();
3454     mockJobService.addResponse(expectedResponse);
3455 
3456     ModelDeploymentMonitoringJobName name =
3457         ModelDeploymentMonitoringJobName.of(
3458             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3459 
3460     client.resumeModelDeploymentMonitoringJob(name);
3461 
3462     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3463     Assert.assertEquals(1, actualRequests.size());
3464     ResumeModelDeploymentMonitoringJobRequest actualRequest =
3465         ((ResumeModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3466 
3467     Assert.assertEquals(name.toString(), actualRequest.getName());
3468     Assert.assertTrue(
3469         channelProvider.isHeaderSent(
3470             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3471             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3472   }
3473 
3474   @Test
resumeModelDeploymentMonitoringJobExceptionTest()3475   public void resumeModelDeploymentMonitoringJobExceptionTest() throws Exception {
3476     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3477     mockJobService.addException(exception);
3478 
3479     try {
3480       ModelDeploymentMonitoringJobName name =
3481           ModelDeploymentMonitoringJobName.of(
3482               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3483       client.resumeModelDeploymentMonitoringJob(name);
3484       Assert.fail("No exception raised");
3485     } catch (InvalidArgumentException e) {
3486       // Expected exception.
3487     }
3488   }
3489 
3490   @Test
resumeModelDeploymentMonitoringJobTest2()3491   public void resumeModelDeploymentMonitoringJobTest2() throws Exception {
3492     Empty expectedResponse = Empty.newBuilder().build();
3493     mockJobService.addResponse(expectedResponse);
3494 
3495     String name = "name3373707";
3496 
3497     client.resumeModelDeploymentMonitoringJob(name);
3498 
3499     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3500     Assert.assertEquals(1, actualRequests.size());
3501     ResumeModelDeploymentMonitoringJobRequest actualRequest =
3502         ((ResumeModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3503 
3504     Assert.assertEquals(name, actualRequest.getName());
3505     Assert.assertTrue(
3506         channelProvider.isHeaderSent(
3507             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3508             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3509   }
3510 
3511   @Test
resumeModelDeploymentMonitoringJobExceptionTest2()3512   public void resumeModelDeploymentMonitoringJobExceptionTest2() throws Exception {
3513     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3514     mockJobService.addException(exception);
3515 
3516     try {
3517       String name = "name3373707";
3518       client.resumeModelDeploymentMonitoringJob(name);
3519       Assert.fail("No exception raised");
3520     } catch (InvalidArgumentException e) {
3521       // Expected exception.
3522     }
3523   }
3524 
3525   @Test
listLocationsTest()3526   public void listLocationsTest() throws Exception {
3527     Location responsesElement = Location.newBuilder().build();
3528     ListLocationsResponse expectedResponse =
3529         ListLocationsResponse.newBuilder()
3530             .setNextPageToken("")
3531             .addAllLocations(Arrays.asList(responsesElement))
3532             .build();
3533     mockLocations.addResponse(expectedResponse);
3534 
3535     ListLocationsRequest request =
3536         ListLocationsRequest.newBuilder()
3537             .setName("name3373707")
3538             .setFilter("filter-1274492040")
3539             .setPageSize(883849137)
3540             .setPageToken("pageToken873572522")
3541             .build();
3542 
3543     ListLocationsPagedResponse pagedListResponse = client.listLocations(request);
3544 
3545     List<Location> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3546 
3547     Assert.assertEquals(1, resources.size());
3548     Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0));
3549 
3550     List<AbstractMessage> actualRequests = mockLocations.getRequests();
3551     Assert.assertEquals(1, actualRequests.size());
3552     ListLocationsRequest actualRequest = ((ListLocationsRequest) actualRequests.get(0));
3553 
3554     Assert.assertEquals(request.getName(), actualRequest.getName());
3555     Assert.assertEquals(request.getFilter(), actualRequest.getFilter());
3556     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
3557     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
3558     Assert.assertTrue(
3559         channelProvider.isHeaderSent(
3560             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3561             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3562   }
3563 
3564   @Test
listLocationsExceptionTest()3565   public void listLocationsExceptionTest() throws Exception {
3566     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3567     mockLocations.addException(exception);
3568 
3569     try {
3570       ListLocationsRequest request =
3571           ListLocationsRequest.newBuilder()
3572               .setName("name3373707")
3573               .setFilter("filter-1274492040")
3574               .setPageSize(883849137)
3575               .setPageToken("pageToken873572522")
3576               .build();
3577       client.listLocations(request);
3578       Assert.fail("No exception raised");
3579     } catch (InvalidArgumentException e) {
3580       // Expected exception.
3581     }
3582   }
3583 
3584   @Test
getLocationTest()3585   public void getLocationTest() throws Exception {
3586     Location expectedResponse =
3587         Location.newBuilder()
3588             .setName("name3373707")
3589             .setLocationId("locationId1541836720")
3590             .setDisplayName("displayName1714148973")
3591             .putAllLabels(new HashMap<String, String>())
3592             .setMetadata(Any.newBuilder().build())
3593             .build();
3594     mockLocations.addResponse(expectedResponse);
3595 
3596     GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
3597 
3598     Location actualResponse = client.getLocation(request);
3599     Assert.assertEquals(expectedResponse, actualResponse);
3600 
3601     List<AbstractMessage> actualRequests = mockLocations.getRequests();
3602     Assert.assertEquals(1, actualRequests.size());
3603     GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0));
3604 
3605     Assert.assertEquals(request.getName(), actualRequest.getName());
3606     Assert.assertTrue(
3607         channelProvider.isHeaderSent(
3608             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3609             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3610   }
3611 
3612   @Test
getLocationExceptionTest()3613   public void getLocationExceptionTest() throws Exception {
3614     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3615     mockLocations.addException(exception);
3616 
3617     try {
3618       GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
3619       client.getLocation(request);
3620       Assert.fail("No exception raised");
3621     } catch (InvalidArgumentException e) {
3622       // Expected exception.
3623     }
3624   }
3625 
3626   @Test
setIamPolicyTest()3627   public void setIamPolicyTest() throws Exception {
3628     Policy expectedResponse =
3629         Policy.newBuilder()
3630             .setVersion(351608024)
3631             .addAllBindings(new ArrayList<Binding>())
3632             .addAllAuditConfigs(new ArrayList<AuditConfig>())
3633             .setEtag(ByteString.EMPTY)
3634             .build();
3635     mockIAMPolicy.addResponse(expectedResponse);
3636 
3637     SetIamPolicyRequest request =
3638         SetIamPolicyRequest.newBuilder()
3639             .setResource(
3640                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3641                     .toString())
3642             .setPolicy(Policy.newBuilder().build())
3643             .setUpdateMask(FieldMask.newBuilder().build())
3644             .build();
3645 
3646     Policy actualResponse = client.setIamPolicy(request);
3647     Assert.assertEquals(expectedResponse, actualResponse);
3648 
3649     List<AbstractMessage> actualRequests = mockIAMPolicy.getRequests();
3650     Assert.assertEquals(1, actualRequests.size());
3651     SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0));
3652 
3653     Assert.assertEquals(request.getResource(), actualRequest.getResource());
3654     Assert.assertEquals(request.getPolicy(), actualRequest.getPolicy());
3655     Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
3656     Assert.assertTrue(
3657         channelProvider.isHeaderSent(
3658             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3659             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3660   }
3661 
3662   @Test
setIamPolicyExceptionTest()3663   public void setIamPolicyExceptionTest() throws Exception {
3664     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3665     mockIAMPolicy.addException(exception);
3666 
3667     try {
3668       SetIamPolicyRequest request =
3669           SetIamPolicyRequest.newBuilder()
3670               .setResource(
3671                   EndpointName.ofProjectLocationEndpointName(
3672                           "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3673                       .toString())
3674               .setPolicy(Policy.newBuilder().build())
3675               .setUpdateMask(FieldMask.newBuilder().build())
3676               .build();
3677       client.setIamPolicy(request);
3678       Assert.fail("No exception raised");
3679     } catch (InvalidArgumentException e) {
3680       // Expected exception.
3681     }
3682   }
3683 
3684   @Test
getIamPolicyTest()3685   public void getIamPolicyTest() throws Exception {
3686     Policy expectedResponse =
3687         Policy.newBuilder()
3688             .setVersion(351608024)
3689             .addAllBindings(new ArrayList<Binding>())
3690             .addAllAuditConfigs(new ArrayList<AuditConfig>())
3691             .setEtag(ByteString.EMPTY)
3692             .build();
3693     mockIAMPolicy.addResponse(expectedResponse);
3694 
3695     GetIamPolicyRequest request =
3696         GetIamPolicyRequest.newBuilder()
3697             .setResource(
3698                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3699                     .toString())
3700             .setOptions(GetPolicyOptions.newBuilder().build())
3701             .build();
3702 
3703     Policy actualResponse = client.getIamPolicy(request);
3704     Assert.assertEquals(expectedResponse, actualResponse);
3705 
3706     List<AbstractMessage> actualRequests = mockIAMPolicy.getRequests();
3707     Assert.assertEquals(1, actualRequests.size());
3708     GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0));
3709 
3710     Assert.assertEquals(request.getResource(), actualRequest.getResource());
3711     Assert.assertEquals(request.getOptions(), actualRequest.getOptions());
3712     Assert.assertTrue(
3713         channelProvider.isHeaderSent(
3714             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3715             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3716   }
3717 
3718   @Test
getIamPolicyExceptionTest()3719   public void getIamPolicyExceptionTest() throws Exception {
3720     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3721     mockIAMPolicy.addException(exception);
3722 
3723     try {
3724       GetIamPolicyRequest request =
3725           GetIamPolicyRequest.newBuilder()
3726               .setResource(
3727                   EndpointName.ofProjectLocationEndpointName(
3728                           "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3729                       .toString())
3730               .setOptions(GetPolicyOptions.newBuilder().build())
3731               .build();
3732       client.getIamPolicy(request);
3733       Assert.fail("No exception raised");
3734     } catch (InvalidArgumentException e) {
3735       // Expected exception.
3736     }
3737   }
3738 
3739   @Test
testIamPermissionsTest()3740   public void testIamPermissionsTest() throws Exception {
3741     TestIamPermissionsResponse expectedResponse =
3742         TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList<String>()).build();
3743     mockIAMPolicy.addResponse(expectedResponse);
3744 
3745     TestIamPermissionsRequest request =
3746         TestIamPermissionsRequest.newBuilder()
3747             .setResource(
3748                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3749                     .toString())
3750             .addAllPermissions(new ArrayList<String>())
3751             .build();
3752 
3753     TestIamPermissionsResponse actualResponse = client.testIamPermissions(request);
3754     Assert.assertEquals(expectedResponse, actualResponse);
3755 
3756     List<AbstractMessage> actualRequests = mockIAMPolicy.getRequests();
3757     Assert.assertEquals(1, actualRequests.size());
3758     TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0));
3759 
3760     Assert.assertEquals(request.getResource(), actualRequest.getResource());
3761     Assert.assertEquals(request.getPermissionsList(), actualRequest.getPermissionsList());
3762     Assert.assertTrue(
3763         channelProvider.isHeaderSent(
3764             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3765             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3766   }
3767 
3768   @Test
testIamPermissionsExceptionTest()3769   public void testIamPermissionsExceptionTest() throws Exception {
3770     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3771     mockIAMPolicy.addException(exception);
3772 
3773     try {
3774       TestIamPermissionsRequest request =
3775           TestIamPermissionsRequest.newBuilder()
3776               .setResource(
3777                   EndpointName.ofProjectLocationEndpointName(
3778                           "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3779                       .toString())
3780               .addAllPermissions(new ArrayList<String>())
3781               .build();
3782       client.testIamPermissions(request);
3783       Assert.fail("No exception raised");
3784     } catch (InvalidArgumentException e) {
3785       // Expected exception.
3786     }
3787   }
3788 }
3789