• 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.v1;
18 
19 import static com.google.cloud.aiplatform.v1.JobServiceClient.ListBatchPredictionJobsPagedResponse;
20 import static com.google.cloud.aiplatform.v1.JobServiceClient.ListCustomJobsPagedResponse;
21 import static com.google.cloud.aiplatform.v1.JobServiceClient.ListDataLabelingJobsPagedResponse;
22 import static com.google.cloud.aiplatform.v1.JobServiceClient.ListHyperparameterTuningJobsPagedResponse;
23 import static com.google.cloud.aiplatform.v1.JobServiceClient.ListLocationsPagedResponse;
24 import static com.google.cloud.aiplatform.v1.JobServiceClient.ListModelDeploymentMonitoringJobsPagedResponse;
25 import static com.google.cloud.aiplatform.v1.JobServiceClient.ListNasJobsPagedResponse;
26 import static com.google.cloud.aiplatform.v1.JobServiceClient.ListNasTrialDetailsPagedResponse;
27 import static com.google.cloud.aiplatform.v1.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             .setDisableContainerLogging(true)
2195             .build();
2196     mockJobService.addResponse(expectedResponse);
2197 
2198     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2199     BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().build();
2200 
2201     BatchPredictionJob actualResponse = client.createBatchPredictionJob(parent, batchPredictionJob);
2202     Assert.assertEquals(expectedResponse, actualResponse);
2203 
2204     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2205     Assert.assertEquals(1, actualRequests.size());
2206     CreateBatchPredictionJobRequest actualRequest =
2207         ((CreateBatchPredictionJobRequest) actualRequests.get(0));
2208 
2209     Assert.assertEquals(parent.toString(), actualRequest.getParent());
2210     Assert.assertEquals(batchPredictionJob, actualRequest.getBatchPredictionJob());
2211     Assert.assertTrue(
2212         channelProvider.isHeaderSent(
2213             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2214             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2215   }
2216 
2217   @Test
createBatchPredictionJobExceptionTest()2218   public void createBatchPredictionJobExceptionTest() throws Exception {
2219     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2220     mockJobService.addException(exception);
2221 
2222     try {
2223       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2224       BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().build();
2225       client.createBatchPredictionJob(parent, batchPredictionJob);
2226       Assert.fail("No exception raised");
2227     } catch (InvalidArgumentException e) {
2228       // Expected exception.
2229     }
2230   }
2231 
2232   @Test
createBatchPredictionJobTest2()2233   public void createBatchPredictionJobTest2() throws Exception {
2234     BatchPredictionJob expectedResponse =
2235         BatchPredictionJob.newBuilder()
2236             .setName(
2237                 BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]")
2238                     .toString())
2239             .setDisplayName("displayName1714148973")
2240             .setModel(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
2241             .setModelVersionId("modelVersionId-2006125846")
2242             .setUnmanagedContainerModel(UnmanagedContainerModel.newBuilder().build())
2243             .setInputConfig(BatchPredictionJob.InputConfig.newBuilder().build())
2244             .setInstanceConfig(BatchPredictionJob.InstanceConfig.newBuilder().build())
2245             .setModelParameters(Value.newBuilder().setBoolValue(true).build())
2246             .setOutputConfig(BatchPredictionJob.OutputConfig.newBuilder().build())
2247             .setDedicatedResources(BatchDedicatedResources.newBuilder().build())
2248             .setServiceAccount("serviceAccount1079137720")
2249             .setManualBatchTuningParameters(ManualBatchTuningParameters.newBuilder().build())
2250             .setGenerateExplanation(true)
2251             .setExplanationSpec(ExplanationSpec.newBuilder().build())
2252             .setOutputInfo(BatchPredictionJob.OutputInfo.newBuilder().build())
2253             .setState(JobState.forNumber(0))
2254             .setError(Status.newBuilder().build())
2255             .addAllPartialFailures(new ArrayList<Status>())
2256             .setResourcesConsumed(ResourcesConsumed.newBuilder().build())
2257             .setCompletionStats(CompletionStats.newBuilder().build())
2258             .setCreateTime(Timestamp.newBuilder().build())
2259             .setStartTime(Timestamp.newBuilder().build())
2260             .setEndTime(Timestamp.newBuilder().build())
2261             .setUpdateTime(Timestamp.newBuilder().build())
2262             .putAllLabels(new HashMap<String, String>())
2263             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2264             .setDisableContainerLogging(true)
2265             .build();
2266     mockJobService.addResponse(expectedResponse);
2267 
2268     String parent = "parent-995424086";
2269     BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().build();
2270 
2271     BatchPredictionJob actualResponse = client.createBatchPredictionJob(parent, batchPredictionJob);
2272     Assert.assertEquals(expectedResponse, actualResponse);
2273 
2274     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2275     Assert.assertEquals(1, actualRequests.size());
2276     CreateBatchPredictionJobRequest actualRequest =
2277         ((CreateBatchPredictionJobRequest) actualRequests.get(0));
2278 
2279     Assert.assertEquals(parent, actualRequest.getParent());
2280     Assert.assertEquals(batchPredictionJob, actualRequest.getBatchPredictionJob());
2281     Assert.assertTrue(
2282         channelProvider.isHeaderSent(
2283             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2284             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2285   }
2286 
2287   @Test
createBatchPredictionJobExceptionTest2()2288   public void createBatchPredictionJobExceptionTest2() throws Exception {
2289     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2290     mockJobService.addException(exception);
2291 
2292     try {
2293       String parent = "parent-995424086";
2294       BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().build();
2295       client.createBatchPredictionJob(parent, batchPredictionJob);
2296       Assert.fail("No exception raised");
2297     } catch (InvalidArgumentException e) {
2298       // Expected exception.
2299     }
2300   }
2301 
2302   @Test
getBatchPredictionJobTest()2303   public void getBatchPredictionJobTest() throws Exception {
2304     BatchPredictionJob expectedResponse =
2305         BatchPredictionJob.newBuilder()
2306             .setName(
2307                 BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]")
2308                     .toString())
2309             .setDisplayName("displayName1714148973")
2310             .setModel(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
2311             .setModelVersionId("modelVersionId-2006125846")
2312             .setUnmanagedContainerModel(UnmanagedContainerModel.newBuilder().build())
2313             .setInputConfig(BatchPredictionJob.InputConfig.newBuilder().build())
2314             .setInstanceConfig(BatchPredictionJob.InstanceConfig.newBuilder().build())
2315             .setModelParameters(Value.newBuilder().setBoolValue(true).build())
2316             .setOutputConfig(BatchPredictionJob.OutputConfig.newBuilder().build())
2317             .setDedicatedResources(BatchDedicatedResources.newBuilder().build())
2318             .setServiceAccount("serviceAccount1079137720")
2319             .setManualBatchTuningParameters(ManualBatchTuningParameters.newBuilder().build())
2320             .setGenerateExplanation(true)
2321             .setExplanationSpec(ExplanationSpec.newBuilder().build())
2322             .setOutputInfo(BatchPredictionJob.OutputInfo.newBuilder().build())
2323             .setState(JobState.forNumber(0))
2324             .setError(Status.newBuilder().build())
2325             .addAllPartialFailures(new ArrayList<Status>())
2326             .setResourcesConsumed(ResourcesConsumed.newBuilder().build())
2327             .setCompletionStats(CompletionStats.newBuilder().build())
2328             .setCreateTime(Timestamp.newBuilder().build())
2329             .setStartTime(Timestamp.newBuilder().build())
2330             .setEndTime(Timestamp.newBuilder().build())
2331             .setUpdateTime(Timestamp.newBuilder().build())
2332             .putAllLabels(new HashMap<String, String>())
2333             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2334             .setDisableContainerLogging(true)
2335             .build();
2336     mockJobService.addResponse(expectedResponse);
2337 
2338     BatchPredictionJobName name =
2339         BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2340 
2341     BatchPredictionJob actualResponse = client.getBatchPredictionJob(name);
2342     Assert.assertEquals(expectedResponse, actualResponse);
2343 
2344     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2345     Assert.assertEquals(1, actualRequests.size());
2346     GetBatchPredictionJobRequest actualRequest =
2347         ((GetBatchPredictionJobRequest) actualRequests.get(0));
2348 
2349     Assert.assertEquals(name.toString(), actualRequest.getName());
2350     Assert.assertTrue(
2351         channelProvider.isHeaderSent(
2352             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2353             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2354   }
2355 
2356   @Test
getBatchPredictionJobExceptionTest()2357   public void getBatchPredictionJobExceptionTest() throws Exception {
2358     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2359     mockJobService.addException(exception);
2360 
2361     try {
2362       BatchPredictionJobName name =
2363           BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2364       client.getBatchPredictionJob(name);
2365       Assert.fail("No exception raised");
2366     } catch (InvalidArgumentException e) {
2367       // Expected exception.
2368     }
2369   }
2370 
2371   @Test
getBatchPredictionJobTest2()2372   public void getBatchPredictionJobTest2() throws Exception {
2373     BatchPredictionJob expectedResponse =
2374         BatchPredictionJob.newBuilder()
2375             .setName(
2376                 BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]")
2377                     .toString())
2378             .setDisplayName("displayName1714148973")
2379             .setModel(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
2380             .setModelVersionId("modelVersionId-2006125846")
2381             .setUnmanagedContainerModel(UnmanagedContainerModel.newBuilder().build())
2382             .setInputConfig(BatchPredictionJob.InputConfig.newBuilder().build())
2383             .setInstanceConfig(BatchPredictionJob.InstanceConfig.newBuilder().build())
2384             .setModelParameters(Value.newBuilder().setBoolValue(true).build())
2385             .setOutputConfig(BatchPredictionJob.OutputConfig.newBuilder().build())
2386             .setDedicatedResources(BatchDedicatedResources.newBuilder().build())
2387             .setServiceAccount("serviceAccount1079137720")
2388             .setManualBatchTuningParameters(ManualBatchTuningParameters.newBuilder().build())
2389             .setGenerateExplanation(true)
2390             .setExplanationSpec(ExplanationSpec.newBuilder().build())
2391             .setOutputInfo(BatchPredictionJob.OutputInfo.newBuilder().build())
2392             .setState(JobState.forNumber(0))
2393             .setError(Status.newBuilder().build())
2394             .addAllPartialFailures(new ArrayList<Status>())
2395             .setResourcesConsumed(ResourcesConsumed.newBuilder().build())
2396             .setCompletionStats(CompletionStats.newBuilder().build())
2397             .setCreateTime(Timestamp.newBuilder().build())
2398             .setStartTime(Timestamp.newBuilder().build())
2399             .setEndTime(Timestamp.newBuilder().build())
2400             .setUpdateTime(Timestamp.newBuilder().build())
2401             .putAllLabels(new HashMap<String, String>())
2402             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2403             .setDisableContainerLogging(true)
2404             .build();
2405     mockJobService.addResponse(expectedResponse);
2406 
2407     String name = "name3373707";
2408 
2409     BatchPredictionJob actualResponse = client.getBatchPredictionJob(name);
2410     Assert.assertEquals(expectedResponse, actualResponse);
2411 
2412     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2413     Assert.assertEquals(1, actualRequests.size());
2414     GetBatchPredictionJobRequest actualRequest =
2415         ((GetBatchPredictionJobRequest) actualRequests.get(0));
2416 
2417     Assert.assertEquals(name, actualRequest.getName());
2418     Assert.assertTrue(
2419         channelProvider.isHeaderSent(
2420             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2421             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2422   }
2423 
2424   @Test
getBatchPredictionJobExceptionTest2()2425   public void getBatchPredictionJobExceptionTest2() throws Exception {
2426     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2427     mockJobService.addException(exception);
2428 
2429     try {
2430       String name = "name3373707";
2431       client.getBatchPredictionJob(name);
2432       Assert.fail("No exception raised");
2433     } catch (InvalidArgumentException e) {
2434       // Expected exception.
2435     }
2436   }
2437 
2438   @Test
listBatchPredictionJobsTest()2439   public void listBatchPredictionJobsTest() throws Exception {
2440     BatchPredictionJob responsesElement = BatchPredictionJob.newBuilder().build();
2441     ListBatchPredictionJobsResponse expectedResponse =
2442         ListBatchPredictionJobsResponse.newBuilder()
2443             .setNextPageToken("")
2444             .addAllBatchPredictionJobs(Arrays.asList(responsesElement))
2445             .build();
2446     mockJobService.addResponse(expectedResponse);
2447 
2448     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2449 
2450     ListBatchPredictionJobsPagedResponse pagedListResponse = client.listBatchPredictionJobs(parent);
2451 
2452     List<BatchPredictionJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2453 
2454     Assert.assertEquals(1, resources.size());
2455     Assert.assertEquals(expectedResponse.getBatchPredictionJobsList().get(0), resources.get(0));
2456 
2457     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2458     Assert.assertEquals(1, actualRequests.size());
2459     ListBatchPredictionJobsRequest actualRequest =
2460         ((ListBatchPredictionJobsRequest) actualRequests.get(0));
2461 
2462     Assert.assertEquals(parent.toString(), actualRequest.getParent());
2463     Assert.assertTrue(
2464         channelProvider.isHeaderSent(
2465             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2466             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2467   }
2468 
2469   @Test
listBatchPredictionJobsExceptionTest()2470   public void listBatchPredictionJobsExceptionTest() throws Exception {
2471     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2472     mockJobService.addException(exception);
2473 
2474     try {
2475       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2476       client.listBatchPredictionJobs(parent);
2477       Assert.fail("No exception raised");
2478     } catch (InvalidArgumentException e) {
2479       // Expected exception.
2480     }
2481   }
2482 
2483   @Test
listBatchPredictionJobsTest2()2484   public void listBatchPredictionJobsTest2() throws Exception {
2485     BatchPredictionJob responsesElement = BatchPredictionJob.newBuilder().build();
2486     ListBatchPredictionJobsResponse expectedResponse =
2487         ListBatchPredictionJobsResponse.newBuilder()
2488             .setNextPageToken("")
2489             .addAllBatchPredictionJobs(Arrays.asList(responsesElement))
2490             .build();
2491     mockJobService.addResponse(expectedResponse);
2492 
2493     String parent = "parent-995424086";
2494 
2495     ListBatchPredictionJobsPagedResponse pagedListResponse = client.listBatchPredictionJobs(parent);
2496 
2497     List<BatchPredictionJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
2498 
2499     Assert.assertEquals(1, resources.size());
2500     Assert.assertEquals(expectedResponse.getBatchPredictionJobsList().get(0), resources.get(0));
2501 
2502     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2503     Assert.assertEquals(1, actualRequests.size());
2504     ListBatchPredictionJobsRequest actualRequest =
2505         ((ListBatchPredictionJobsRequest) actualRequests.get(0));
2506 
2507     Assert.assertEquals(parent, actualRequest.getParent());
2508     Assert.assertTrue(
2509         channelProvider.isHeaderSent(
2510             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2511             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2512   }
2513 
2514   @Test
listBatchPredictionJobsExceptionTest2()2515   public void listBatchPredictionJobsExceptionTest2() throws Exception {
2516     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2517     mockJobService.addException(exception);
2518 
2519     try {
2520       String parent = "parent-995424086";
2521       client.listBatchPredictionJobs(parent);
2522       Assert.fail("No exception raised");
2523     } catch (InvalidArgumentException e) {
2524       // Expected exception.
2525     }
2526   }
2527 
2528   @Test
deleteBatchPredictionJobTest()2529   public void deleteBatchPredictionJobTest() throws Exception {
2530     Empty expectedResponse = Empty.newBuilder().build();
2531     Operation resultOperation =
2532         Operation.newBuilder()
2533             .setName("deleteBatchPredictionJobTest")
2534             .setDone(true)
2535             .setResponse(Any.pack(expectedResponse))
2536             .build();
2537     mockJobService.addResponse(resultOperation);
2538 
2539     BatchPredictionJobName name =
2540         BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2541 
2542     client.deleteBatchPredictionJobAsync(name).get();
2543 
2544     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2545     Assert.assertEquals(1, actualRequests.size());
2546     DeleteBatchPredictionJobRequest actualRequest =
2547         ((DeleteBatchPredictionJobRequest) actualRequests.get(0));
2548 
2549     Assert.assertEquals(name.toString(), actualRequest.getName());
2550     Assert.assertTrue(
2551         channelProvider.isHeaderSent(
2552             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2553             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2554   }
2555 
2556   @Test
deleteBatchPredictionJobExceptionTest()2557   public void deleteBatchPredictionJobExceptionTest() throws Exception {
2558     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2559     mockJobService.addException(exception);
2560 
2561     try {
2562       BatchPredictionJobName name =
2563           BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2564       client.deleteBatchPredictionJobAsync(name).get();
2565       Assert.fail("No exception raised");
2566     } catch (ExecutionException e) {
2567       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
2568       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
2569       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
2570     }
2571   }
2572 
2573   @Test
deleteBatchPredictionJobTest2()2574   public void deleteBatchPredictionJobTest2() throws Exception {
2575     Empty expectedResponse = Empty.newBuilder().build();
2576     Operation resultOperation =
2577         Operation.newBuilder()
2578             .setName("deleteBatchPredictionJobTest")
2579             .setDone(true)
2580             .setResponse(Any.pack(expectedResponse))
2581             .build();
2582     mockJobService.addResponse(resultOperation);
2583 
2584     String name = "name3373707";
2585 
2586     client.deleteBatchPredictionJobAsync(name).get();
2587 
2588     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2589     Assert.assertEquals(1, actualRequests.size());
2590     DeleteBatchPredictionJobRequest actualRequest =
2591         ((DeleteBatchPredictionJobRequest) actualRequests.get(0));
2592 
2593     Assert.assertEquals(name, actualRequest.getName());
2594     Assert.assertTrue(
2595         channelProvider.isHeaderSent(
2596             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2597             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2598   }
2599 
2600   @Test
deleteBatchPredictionJobExceptionTest2()2601   public void deleteBatchPredictionJobExceptionTest2() throws Exception {
2602     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2603     mockJobService.addException(exception);
2604 
2605     try {
2606       String name = "name3373707";
2607       client.deleteBatchPredictionJobAsync(name).get();
2608       Assert.fail("No exception raised");
2609     } catch (ExecutionException e) {
2610       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
2611       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
2612       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
2613     }
2614   }
2615 
2616   @Test
cancelBatchPredictionJobTest()2617   public void cancelBatchPredictionJobTest() throws Exception {
2618     Empty expectedResponse = Empty.newBuilder().build();
2619     mockJobService.addResponse(expectedResponse);
2620 
2621     BatchPredictionJobName name =
2622         BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2623 
2624     client.cancelBatchPredictionJob(name);
2625 
2626     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2627     Assert.assertEquals(1, actualRequests.size());
2628     CancelBatchPredictionJobRequest actualRequest =
2629         ((CancelBatchPredictionJobRequest) actualRequests.get(0));
2630 
2631     Assert.assertEquals(name.toString(), actualRequest.getName());
2632     Assert.assertTrue(
2633         channelProvider.isHeaderSent(
2634             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2635             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2636   }
2637 
2638   @Test
cancelBatchPredictionJobExceptionTest()2639   public void cancelBatchPredictionJobExceptionTest() throws Exception {
2640     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2641     mockJobService.addException(exception);
2642 
2643     try {
2644       BatchPredictionJobName name =
2645           BatchPredictionJobName.of("[PROJECT]", "[LOCATION]", "[BATCH_PREDICTION_JOB]");
2646       client.cancelBatchPredictionJob(name);
2647       Assert.fail("No exception raised");
2648     } catch (InvalidArgumentException e) {
2649       // Expected exception.
2650     }
2651   }
2652 
2653   @Test
cancelBatchPredictionJobTest2()2654   public void cancelBatchPredictionJobTest2() throws Exception {
2655     Empty expectedResponse = Empty.newBuilder().build();
2656     mockJobService.addResponse(expectedResponse);
2657 
2658     String name = "name3373707";
2659 
2660     client.cancelBatchPredictionJob(name);
2661 
2662     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2663     Assert.assertEquals(1, actualRequests.size());
2664     CancelBatchPredictionJobRequest actualRequest =
2665         ((CancelBatchPredictionJobRequest) actualRequests.get(0));
2666 
2667     Assert.assertEquals(name, actualRequest.getName());
2668     Assert.assertTrue(
2669         channelProvider.isHeaderSent(
2670             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2671             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2672   }
2673 
2674   @Test
cancelBatchPredictionJobExceptionTest2()2675   public void cancelBatchPredictionJobExceptionTest2() throws Exception {
2676     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2677     mockJobService.addException(exception);
2678 
2679     try {
2680       String name = "name3373707";
2681       client.cancelBatchPredictionJob(name);
2682       Assert.fail("No exception raised");
2683     } catch (InvalidArgumentException e) {
2684       // Expected exception.
2685     }
2686   }
2687 
2688   @Test
createModelDeploymentMonitoringJobTest()2689   public void createModelDeploymentMonitoringJobTest() throws Exception {
2690     ModelDeploymentMonitoringJob expectedResponse =
2691         ModelDeploymentMonitoringJob.newBuilder()
2692             .setName(
2693                 ModelDeploymentMonitoringJobName.of(
2694                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
2695                     .toString())
2696             .setDisplayName("displayName1714148973")
2697             .setEndpoint(
2698                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
2699                     .toString())
2700             .setState(JobState.forNumber(0))
2701             .setLatestMonitoringPipelineMetadata(
2702                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
2703             .addAllModelDeploymentMonitoringObjectiveConfigs(
2704                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
2705             .setModelDeploymentMonitoringScheduleConfig(
2706                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
2707             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
2708             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
2709             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
2710             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
2711             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
2712             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
2713             .setLogTtl(Duration.newBuilder().build())
2714             .putAllLabels(new HashMap<String, String>())
2715             .setCreateTime(Timestamp.newBuilder().build())
2716             .setUpdateTime(Timestamp.newBuilder().build())
2717             .setNextScheduleTime(Timestamp.newBuilder().build())
2718             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
2719             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2720             .setEnableMonitoringPipelineLogs(true)
2721             .setError(Status.newBuilder().build())
2722             .build();
2723     mockJobService.addResponse(expectedResponse);
2724 
2725     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2726     ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
2727         ModelDeploymentMonitoringJob.newBuilder().build();
2728 
2729     ModelDeploymentMonitoringJob actualResponse =
2730         client.createModelDeploymentMonitoringJob(parent, modelDeploymentMonitoringJob);
2731     Assert.assertEquals(expectedResponse, actualResponse);
2732 
2733     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2734     Assert.assertEquals(1, actualRequests.size());
2735     CreateModelDeploymentMonitoringJobRequest actualRequest =
2736         ((CreateModelDeploymentMonitoringJobRequest) actualRequests.get(0));
2737 
2738     Assert.assertEquals(parent.toString(), actualRequest.getParent());
2739     Assert.assertEquals(
2740         modelDeploymentMonitoringJob, actualRequest.getModelDeploymentMonitoringJob());
2741     Assert.assertTrue(
2742         channelProvider.isHeaderSent(
2743             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2744             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2745   }
2746 
2747   @Test
createModelDeploymentMonitoringJobExceptionTest()2748   public void createModelDeploymentMonitoringJobExceptionTest() throws Exception {
2749     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2750     mockJobService.addException(exception);
2751 
2752     try {
2753       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
2754       ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
2755           ModelDeploymentMonitoringJob.newBuilder().build();
2756       client.createModelDeploymentMonitoringJob(parent, modelDeploymentMonitoringJob);
2757       Assert.fail("No exception raised");
2758     } catch (InvalidArgumentException e) {
2759       // Expected exception.
2760     }
2761   }
2762 
2763   @Test
createModelDeploymentMonitoringJobTest2()2764   public void createModelDeploymentMonitoringJobTest2() throws Exception {
2765     ModelDeploymentMonitoringJob expectedResponse =
2766         ModelDeploymentMonitoringJob.newBuilder()
2767             .setName(
2768                 ModelDeploymentMonitoringJobName.of(
2769                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
2770                     .toString())
2771             .setDisplayName("displayName1714148973")
2772             .setEndpoint(
2773                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
2774                     .toString())
2775             .setState(JobState.forNumber(0))
2776             .setLatestMonitoringPipelineMetadata(
2777                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
2778             .addAllModelDeploymentMonitoringObjectiveConfigs(
2779                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
2780             .setModelDeploymentMonitoringScheduleConfig(
2781                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
2782             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
2783             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
2784             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
2785             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
2786             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
2787             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
2788             .setLogTtl(Duration.newBuilder().build())
2789             .putAllLabels(new HashMap<String, String>())
2790             .setCreateTime(Timestamp.newBuilder().build())
2791             .setUpdateTime(Timestamp.newBuilder().build())
2792             .setNextScheduleTime(Timestamp.newBuilder().build())
2793             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
2794             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2795             .setEnableMonitoringPipelineLogs(true)
2796             .setError(Status.newBuilder().build())
2797             .build();
2798     mockJobService.addResponse(expectedResponse);
2799 
2800     String parent = "parent-995424086";
2801     ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
2802         ModelDeploymentMonitoringJob.newBuilder().build();
2803 
2804     ModelDeploymentMonitoringJob actualResponse =
2805         client.createModelDeploymentMonitoringJob(parent, modelDeploymentMonitoringJob);
2806     Assert.assertEquals(expectedResponse, actualResponse);
2807 
2808     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2809     Assert.assertEquals(1, actualRequests.size());
2810     CreateModelDeploymentMonitoringJobRequest actualRequest =
2811         ((CreateModelDeploymentMonitoringJobRequest) actualRequests.get(0));
2812 
2813     Assert.assertEquals(parent, actualRequest.getParent());
2814     Assert.assertEquals(
2815         modelDeploymentMonitoringJob, actualRequest.getModelDeploymentMonitoringJob());
2816     Assert.assertTrue(
2817         channelProvider.isHeaderSent(
2818             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2819             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2820   }
2821 
2822   @Test
createModelDeploymentMonitoringJobExceptionTest2()2823   public void createModelDeploymentMonitoringJobExceptionTest2() throws Exception {
2824     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2825     mockJobService.addException(exception);
2826 
2827     try {
2828       String parent = "parent-995424086";
2829       ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
2830           ModelDeploymentMonitoringJob.newBuilder().build();
2831       client.createModelDeploymentMonitoringJob(parent, modelDeploymentMonitoringJob);
2832       Assert.fail("No exception raised");
2833     } catch (InvalidArgumentException e) {
2834       // Expected exception.
2835     }
2836   }
2837 
2838   @Test
searchModelDeploymentMonitoringStatsAnomaliesTest()2839   public void searchModelDeploymentMonitoringStatsAnomaliesTest() throws Exception {
2840     ModelMonitoringStatsAnomalies responsesElement =
2841         ModelMonitoringStatsAnomalies.newBuilder().build();
2842     SearchModelDeploymentMonitoringStatsAnomaliesResponse expectedResponse =
2843         SearchModelDeploymentMonitoringStatsAnomaliesResponse.newBuilder()
2844             .setNextPageToken("")
2845             .addAllMonitoringStats(Arrays.asList(responsesElement))
2846             .build();
2847     mockJobService.addResponse(expectedResponse);
2848 
2849     ModelDeploymentMonitoringJobName modelDeploymentMonitoringJob =
2850         ModelDeploymentMonitoringJobName.of(
2851             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
2852     String deployedModelId = "deployedModelId-1817547906";
2853 
2854     SearchModelDeploymentMonitoringStatsAnomaliesPagedResponse pagedListResponse =
2855         client.searchModelDeploymentMonitoringStatsAnomalies(
2856             modelDeploymentMonitoringJob, deployedModelId);
2857 
2858     List<ModelMonitoringStatsAnomalies> resources =
2859         Lists.newArrayList(pagedListResponse.iterateAll());
2860 
2861     Assert.assertEquals(1, resources.size());
2862     Assert.assertEquals(expectedResponse.getMonitoringStatsList().get(0), resources.get(0));
2863 
2864     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2865     Assert.assertEquals(1, actualRequests.size());
2866     SearchModelDeploymentMonitoringStatsAnomaliesRequest actualRequest =
2867         ((SearchModelDeploymentMonitoringStatsAnomaliesRequest) actualRequests.get(0));
2868 
2869     Assert.assertEquals(
2870         modelDeploymentMonitoringJob.toString(), actualRequest.getModelDeploymentMonitoringJob());
2871     Assert.assertEquals(deployedModelId, actualRequest.getDeployedModelId());
2872     Assert.assertTrue(
2873         channelProvider.isHeaderSent(
2874             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2875             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2876   }
2877 
2878   @Test
searchModelDeploymentMonitoringStatsAnomaliesExceptionTest()2879   public void searchModelDeploymentMonitoringStatsAnomaliesExceptionTest() throws Exception {
2880     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2881     mockJobService.addException(exception);
2882 
2883     try {
2884       ModelDeploymentMonitoringJobName modelDeploymentMonitoringJob =
2885           ModelDeploymentMonitoringJobName.of(
2886               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
2887       String deployedModelId = "deployedModelId-1817547906";
2888       client.searchModelDeploymentMonitoringStatsAnomalies(
2889           modelDeploymentMonitoringJob, deployedModelId);
2890       Assert.fail("No exception raised");
2891     } catch (InvalidArgumentException e) {
2892       // Expected exception.
2893     }
2894   }
2895 
2896   @Test
searchModelDeploymentMonitoringStatsAnomaliesTest2()2897   public void searchModelDeploymentMonitoringStatsAnomaliesTest2() throws Exception {
2898     ModelMonitoringStatsAnomalies responsesElement =
2899         ModelMonitoringStatsAnomalies.newBuilder().build();
2900     SearchModelDeploymentMonitoringStatsAnomaliesResponse expectedResponse =
2901         SearchModelDeploymentMonitoringStatsAnomaliesResponse.newBuilder()
2902             .setNextPageToken("")
2903             .addAllMonitoringStats(Arrays.asList(responsesElement))
2904             .build();
2905     mockJobService.addResponse(expectedResponse);
2906 
2907     String modelDeploymentMonitoringJob = "modelDeploymentMonitoringJob-1178077657";
2908     String deployedModelId = "deployedModelId-1817547906";
2909 
2910     SearchModelDeploymentMonitoringStatsAnomaliesPagedResponse pagedListResponse =
2911         client.searchModelDeploymentMonitoringStatsAnomalies(
2912             modelDeploymentMonitoringJob, deployedModelId);
2913 
2914     List<ModelMonitoringStatsAnomalies> resources =
2915         Lists.newArrayList(pagedListResponse.iterateAll());
2916 
2917     Assert.assertEquals(1, resources.size());
2918     Assert.assertEquals(expectedResponse.getMonitoringStatsList().get(0), resources.get(0));
2919 
2920     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2921     Assert.assertEquals(1, actualRequests.size());
2922     SearchModelDeploymentMonitoringStatsAnomaliesRequest actualRequest =
2923         ((SearchModelDeploymentMonitoringStatsAnomaliesRequest) actualRequests.get(0));
2924 
2925     Assert.assertEquals(
2926         modelDeploymentMonitoringJob, actualRequest.getModelDeploymentMonitoringJob());
2927     Assert.assertEquals(deployedModelId, actualRequest.getDeployedModelId());
2928     Assert.assertTrue(
2929         channelProvider.isHeaderSent(
2930             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
2931             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
2932   }
2933 
2934   @Test
searchModelDeploymentMonitoringStatsAnomaliesExceptionTest2()2935   public void searchModelDeploymentMonitoringStatsAnomaliesExceptionTest2() throws Exception {
2936     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
2937     mockJobService.addException(exception);
2938 
2939     try {
2940       String modelDeploymentMonitoringJob = "modelDeploymentMonitoringJob-1178077657";
2941       String deployedModelId = "deployedModelId-1817547906";
2942       client.searchModelDeploymentMonitoringStatsAnomalies(
2943           modelDeploymentMonitoringJob, deployedModelId);
2944       Assert.fail("No exception raised");
2945     } catch (InvalidArgumentException e) {
2946       // Expected exception.
2947     }
2948   }
2949 
2950   @Test
getModelDeploymentMonitoringJobTest()2951   public void getModelDeploymentMonitoringJobTest() throws Exception {
2952     ModelDeploymentMonitoringJob expectedResponse =
2953         ModelDeploymentMonitoringJob.newBuilder()
2954             .setName(
2955                 ModelDeploymentMonitoringJobName.of(
2956                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
2957                     .toString())
2958             .setDisplayName("displayName1714148973")
2959             .setEndpoint(
2960                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
2961                     .toString())
2962             .setState(JobState.forNumber(0))
2963             .setLatestMonitoringPipelineMetadata(
2964                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
2965             .addAllModelDeploymentMonitoringObjectiveConfigs(
2966                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
2967             .setModelDeploymentMonitoringScheduleConfig(
2968                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
2969             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
2970             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
2971             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
2972             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
2973             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
2974             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
2975             .setLogTtl(Duration.newBuilder().build())
2976             .putAllLabels(new HashMap<String, String>())
2977             .setCreateTime(Timestamp.newBuilder().build())
2978             .setUpdateTime(Timestamp.newBuilder().build())
2979             .setNextScheduleTime(Timestamp.newBuilder().build())
2980             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
2981             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
2982             .setEnableMonitoringPipelineLogs(true)
2983             .setError(Status.newBuilder().build())
2984             .build();
2985     mockJobService.addResponse(expectedResponse);
2986 
2987     ModelDeploymentMonitoringJobName name =
2988         ModelDeploymentMonitoringJobName.of(
2989             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
2990 
2991     ModelDeploymentMonitoringJob actualResponse = client.getModelDeploymentMonitoringJob(name);
2992     Assert.assertEquals(expectedResponse, actualResponse);
2993 
2994     List<AbstractMessage> actualRequests = mockJobService.getRequests();
2995     Assert.assertEquals(1, actualRequests.size());
2996     GetModelDeploymentMonitoringJobRequest actualRequest =
2997         ((GetModelDeploymentMonitoringJobRequest) actualRequests.get(0));
2998 
2999     Assert.assertEquals(name.toString(), actualRequest.getName());
3000     Assert.assertTrue(
3001         channelProvider.isHeaderSent(
3002             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3003             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3004   }
3005 
3006   @Test
getModelDeploymentMonitoringJobExceptionTest()3007   public void getModelDeploymentMonitoringJobExceptionTest() throws Exception {
3008     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3009     mockJobService.addException(exception);
3010 
3011     try {
3012       ModelDeploymentMonitoringJobName name =
3013           ModelDeploymentMonitoringJobName.of(
3014               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3015       client.getModelDeploymentMonitoringJob(name);
3016       Assert.fail("No exception raised");
3017     } catch (InvalidArgumentException e) {
3018       // Expected exception.
3019     }
3020   }
3021 
3022   @Test
getModelDeploymentMonitoringJobTest2()3023   public void getModelDeploymentMonitoringJobTest2() throws Exception {
3024     ModelDeploymentMonitoringJob expectedResponse =
3025         ModelDeploymentMonitoringJob.newBuilder()
3026             .setName(
3027                 ModelDeploymentMonitoringJobName.of(
3028                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
3029                     .toString())
3030             .setDisplayName("displayName1714148973")
3031             .setEndpoint(
3032                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3033                     .toString())
3034             .setState(JobState.forNumber(0))
3035             .setLatestMonitoringPipelineMetadata(
3036                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
3037             .addAllModelDeploymentMonitoringObjectiveConfigs(
3038                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
3039             .setModelDeploymentMonitoringScheduleConfig(
3040                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
3041             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
3042             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
3043             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
3044             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
3045             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
3046             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
3047             .setLogTtl(Duration.newBuilder().build())
3048             .putAllLabels(new HashMap<String, String>())
3049             .setCreateTime(Timestamp.newBuilder().build())
3050             .setUpdateTime(Timestamp.newBuilder().build())
3051             .setNextScheduleTime(Timestamp.newBuilder().build())
3052             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
3053             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
3054             .setEnableMonitoringPipelineLogs(true)
3055             .setError(Status.newBuilder().build())
3056             .build();
3057     mockJobService.addResponse(expectedResponse);
3058 
3059     String name = "name3373707";
3060 
3061     ModelDeploymentMonitoringJob actualResponse = client.getModelDeploymentMonitoringJob(name);
3062     Assert.assertEquals(expectedResponse, actualResponse);
3063 
3064     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3065     Assert.assertEquals(1, actualRequests.size());
3066     GetModelDeploymentMonitoringJobRequest actualRequest =
3067         ((GetModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3068 
3069     Assert.assertEquals(name, actualRequest.getName());
3070     Assert.assertTrue(
3071         channelProvider.isHeaderSent(
3072             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3073             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3074   }
3075 
3076   @Test
getModelDeploymentMonitoringJobExceptionTest2()3077   public void getModelDeploymentMonitoringJobExceptionTest2() throws Exception {
3078     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3079     mockJobService.addException(exception);
3080 
3081     try {
3082       String name = "name3373707";
3083       client.getModelDeploymentMonitoringJob(name);
3084       Assert.fail("No exception raised");
3085     } catch (InvalidArgumentException e) {
3086       // Expected exception.
3087     }
3088   }
3089 
3090   @Test
listModelDeploymentMonitoringJobsTest()3091   public void listModelDeploymentMonitoringJobsTest() throws Exception {
3092     ModelDeploymentMonitoringJob responsesElement =
3093         ModelDeploymentMonitoringJob.newBuilder().build();
3094     ListModelDeploymentMonitoringJobsResponse expectedResponse =
3095         ListModelDeploymentMonitoringJobsResponse.newBuilder()
3096             .setNextPageToken("")
3097             .addAllModelDeploymentMonitoringJobs(Arrays.asList(responsesElement))
3098             .build();
3099     mockJobService.addResponse(expectedResponse);
3100 
3101     LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
3102 
3103     ListModelDeploymentMonitoringJobsPagedResponse pagedListResponse =
3104         client.listModelDeploymentMonitoringJobs(parent);
3105 
3106     List<ModelDeploymentMonitoringJob> resources =
3107         Lists.newArrayList(pagedListResponse.iterateAll());
3108 
3109     Assert.assertEquals(1, resources.size());
3110     Assert.assertEquals(
3111         expectedResponse.getModelDeploymentMonitoringJobsList().get(0), resources.get(0));
3112 
3113     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3114     Assert.assertEquals(1, actualRequests.size());
3115     ListModelDeploymentMonitoringJobsRequest actualRequest =
3116         ((ListModelDeploymentMonitoringJobsRequest) actualRequests.get(0));
3117 
3118     Assert.assertEquals(parent.toString(), actualRequest.getParent());
3119     Assert.assertTrue(
3120         channelProvider.isHeaderSent(
3121             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3122             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3123   }
3124 
3125   @Test
listModelDeploymentMonitoringJobsExceptionTest()3126   public void listModelDeploymentMonitoringJobsExceptionTest() throws Exception {
3127     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3128     mockJobService.addException(exception);
3129 
3130     try {
3131       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
3132       client.listModelDeploymentMonitoringJobs(parent);
3133       Assert.fail("No exception raised");
3134     } catch (InvalidArgumentException e) {
3135       // Expected exception.
3136     }
3137   }
3138 
3139   @Test
listModelDeploymentMonitoringJobsTest2()3140   public void listModelDeploymentMonitoringJobsTest2() throws Exception {
3141     ModelDeploymentMonitoringJob responsesElement =
3142         ModelDeploymentMonitoringJob.newBuilder().build();
3143     ListModelDeploymentMonitoringJobsResponse expectedResponse =
3144         ListModelDeploymentMonitoringJobsResponse.newBuilder()
3145             .setNextPageToken("")
3146             .addAllModelDeploymentMonitoringJobs(Arrays.asList(responsesElement))
3147             .build();
3148     mockJobService.addResponse(expectedResponse);
3149 
3150     String parent = "parent-995424086";
3151 
3152     ListModelDeploymentMonitoringJobsPagedResponse pagedListResponse =
3153         client.listModelDeploymentMonitoringJobs(parent);
3154 
3155     List<ModelDeploymentMonitoringJob> resources =
3156         Lists.newArrayList(pagedListResponse.iterateAll());
3157 
3158     Assert.assertEquals(1, resources.size());
3159     Assert.assertEquals(
3160         expectedResponse.getModelDeploymentMonitoringJobsList().get(0), resources.get(0));
3161 
3162     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3163     Assert.assertEquals(1, actualRequests.size());
3164     ListModelDeploymentMonitoringJobsRequest actualRequest =
3165         ((ListModelDeploymentMonitoringJobsRequest) actualRequests.get(0));
3166 
3167     Assert.assertEquals(parent, actualRequest.getParent());
3168     Assert.assertTrue(
3169         channelProvider.isHeaderSent(
3170             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3171             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3172   }
3173 
3174   @Test
listModelDeploymentMonitoringJobsExceptionTest2()3175   public void listModelDeploymentMonitoringJobsExceptionTest2() throws Exception {
3176     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3177     mockJobService.addException(exception);
3178 
3179     try {
3180       String parent = "parent-995424086";
3181       client.listModelDeploymentMonitoringJobs(parent);
3182       Assert.fail("No exception raised");
3183     } catch (InvalidArgumentException e) {
3184       // Expected exception.
3185     }
3186   }
3187 
3188   @Test
updateModelDeploymentMonitoringJobTest()3189   public void updateModelDeploymentMonitoringJobTest() throws Exception {
3190     ModelDeploymentMonitoringJob expectedResponse =
3191         ModelDeploymentMonitoringJob.newBuilder()
3192             .setName(
3193                 ModelDeploymentMonitoringJobName.of(
3194                         "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]")
3195                     .toString())
3196             .setDisplayName("displayName1714148973")
3197             .setEndpoint(
3198                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3199                     .toString())
3200             .setState(JobState.forNumber(0))
3201             .setLatestMonitoringPipelineMetadata(
3202                 ModelDeploymentMonitoringJob.LatestMonitoringPipelineMetadata.newBuilder().build())
3203             .addAllModelDeploymentMonitoringObjectiveConfigs(
3204                 new ArrayList<ModelDeploymentMonitoringObjectiveConfig>())
3205             .setModelDeploymentMonitoringScheduleConfig(
3206                 ModelDeploymentMonitoringScheduleConfig.newBuilder().build())
3207             .setLoggingSamplingStrategy(SamplingStrategy.newBuilder().build())
3208             .setModelMonitoringAlertConfig(ModelMonitoringAlertConfig.newBuilder().build())
3209             .setPredictInstanceSchemaUri("predictInstanceSchemaUri-1702051043")
3210             .setSamplePredictInstance(Value.newBuilder().setBoolValue(true).build())
3211             .setAnalysisInstanceSchemaUri("analysisInstanceSchemaUri-1686197382")
3212             .addAllBigqueryTables(new ArrayList<ModelDeploymentMonitoringBigQueryTable>())
3213             .setLogTtl(Duration.newBuilder().build())
3214             .putAllLabels(new HashMap<String, String>())
3215             .setCreateTime(Timestamp.newBuilder().build())
3216             .setUpdateTime(Timestamp.newBuilder().build())
3217             .setNextScheduleTime(Timestamp.newBuilder().build())
3218             .setStatsAnomaliesBaseDirectory(GcsDestination.newBuilder().build())
3219             .setEncryptionSpec(EncryptionSpec.newBuilder().build())
3220             .setEnableMonitoringPipelineLogs(true)
3221             .setError(Status.newBuilder().build())
3222             .build();
3223     Operation resultOperation =
3224         Operation.newBuilder()
3225             .setName("updateModelDeploymentMonitoringJobTest")
3226             .setDone(true)
3227             .setResponse(Any.pack(expectedResponse))
3228             .build();
3229     mockJobService.addResponse(resultOperation);
3230 
3231     ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
3232         ModelDeploymentMonitoringJob.newBuilder().build();
3233     FieldMask updateMask = FieldMask.newBuilder().build();
3234 
3235     ModelDeploymentMonitoringJob actualResponse =
3236         client
3237             .updateModelDeploymentMonitoringJobAsync(modelDeploymentMonitoringJob, updateMask)
3238             .get();
3239     Assert.assertEquals(expectedResponse, actualResponse);
3240 
3241     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3242     Assert.assertEquals(1, actualRequests.size());
3243     UpdateModelDeploymentMonitoringJobRequest actualRequest =
3244         ((UpdateModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3245 
3246     Assert.assertEquals(
3247         modelDeploymentMonitoringJob, actualRequest.getModelDeploymentMonitoringJob());
3248     Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
3249     Assert.assertTrue(
3250         channelProvider.isHeaderSent(
3251             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3252             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3253   }
3254 
3255   @Test
updateModelDeploymentMonitoringJobExceptionTest()3256   public void updateModelDeploymentMonitoringJobExceptionTest() throws Exception {
3257     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3258     mockJobService.addException(exception);
3259 
3260     try {
3261       ModelDeploymentMonitoringJob modelDeploymentMonitoringJob =
3262           ModelDeploymentMonitoringJob.newBuilder().build();
3263       FieldMask updateMask = FieldMask.newBuilder().build();
3264       client
3265           .updateModelDeploymentMonitoringJobAsync(modelDeploymentMonitoringJob, updateMask)
3266           .get();
3267       Assert.fail("No exception raised");
3268     } catch (ExecutionException e) {
3269       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
3270       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
3271       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
3272     }
3273   }
3274 
3275   @Test
deleteModelDeploymentMonitoringJobTest()3276   public void deleteModelDeploymentMonitoringJobTest() throws Exception {
3277     Empty expectedResponse = Empty.newBuilder().build();
3278     Operation resultOperation =
3279         Operation.newBuilder()
3280             .setName("deleteModelDeploymentMonitoringJobTest")
3281             .setDone(true)
3282             .setResponse(Any.pack(expectedResponse))
3283             .build();
3284     mockJobService.addResponse(resultOperation);
3285 
3286     ModelDeploymentMonitoringJobName name =
3287         ModelDeploymentMonitoringJobName.of(
3288             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3289 
3290     client.deleteModelDeploymentMonitoringJobAsync(name).get();
3291 
3292     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3293     Assert.assertEquals(1, actualRequests.size());
3294     DeleteModelDeploymentMonitoringJobRequest actualRequest =
3295         ((DeleteModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3296 
3297     Assert.assertEquals(name.toString(), actualRequest.getName());
3298     Assert.assertTrue(
3299         channelProvider.isHeaderSent(
3300             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3301             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3302   }
3303 
3304   @Test
deleteModelDeploymentMonitoringJobExceptionTest()3305   public void deleteModelDeploymentMonitoringJobExceptionTest() throws Exception {
3306     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3307     mockJobService.addException(exception);
3308 
3309     try {
3310       ModelDeploymentMonitoringJobName name =
3311           ModelDeploymentMonitoringJobName.of(
3312               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3313       client.deleteModelDeploymentMonitoringJobAsync(name).get();
3314       Assert.fail("No exception raised");
3315     } catch (ExecutionException e) {
3316       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
3317       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
3318       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
3319     }
3320   }
3321 
3322   @Test
deleteModelDeploymentMonitoringJobTest2()3323   public void deleteModelDeploymentMonitoringJobTest2() throws Exception {
3324     Empty expectedResponse = Empty.newBuilder().build();
3325     Operation resultOperation =
3326         Operation.newBuilder()
3327             .setName("deleteModelDeploymentMonitoringJobTest")
3328             .setDone(true)
3329             .setResponse(Any.pack(expectedResponse))
3330             .build();
3331     mockJobService.addResponse(resultOperation);
3332 
3333     String name = "name3373707";
3334 
3335     client.deleteModelDeploymentMonitoringJobAsync(name).get();
3336 
3337     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3338     Assert.assertEquals(1, actualRequests.size());
3339     DeleteModelDeploymentMonitoringJobRequest actualRequest =
3340         ((DeleteModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3341 
3342     Assert.assertEquals(name, actualRequest.getName());
3343     Assert.assertTrue(
3344         channelProvider.isHeaderSent(
3345             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3346             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3347   }
3348 
3349   @Test
deleteModelDeploymentMonitoringJobExceptionTest2()3350   public void deleteModelDeploymentMonitoringJobExceptionTest2() throws Exception {
3351     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3352     mockJobService.addException(exception);
3353 
3354     try {
3355       String name = "name3373707";
3356       client.deleteModelDeploymentMonitoringJobAsync(name).get();
3357       Assert.fail("No exception raised");
3358     } catch (ExecutionException e) {
3359       Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
3360       InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
3361       Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
3362     }
3363   }
3364 
3365   @Test
pauseModelDeploymentMonitoringJobTest()3366   public void pauseModelDeploymentMonitoringJobTest() throws Exception {
3367     Empty expectedResponse = Empty.newBuilder().build();
3368     mockJobService.addResponse(expectedResponse);
3369 
3370     ModelDeploymentMonitoringJobName name =
3371         ModelDeploymentMonitoringJobName.of(
3372             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3373 
3374     client.pauseModelDeploymentMonitoringJob(name);
3375 
3376     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3377     Assert.assertEquals(1, actualRequests.size());
3378     PauseModelDeploymentMonitoringJobRequest actualRequest =
3379         ((PauseModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3380 
3381     Assert.assertEquals(name.toString(), actualRequest.getName());
3382     Assert.assertTrue(
3383         channelProvider.isHeaderSent(
3384             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3385             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3386   }
3387 
3388   @Test
pauseModelDeploymentMonitoringJobExceptionTest()3389   public void pauseModelDeploymentMonitoringJobExceptionTest() throws Exception {
3390     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3391     mockJobService.addException(exception);
3392 
3393     try {
3394       ModelDeploymentMonitoringJobName name =
3395           ModelDeploymentMonitoringJobName.of(
3396               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3397       client.pauseModelDeploymentMonitoringJob(name);
3398       Assert.fail("No exception raised");
3399     } catch (InvalidArgumentException e) {
3400       // Expected exception.
3401     }
3402   }
3403 
3404   @Test
pauseModelDeploymentMonitoringJobTest2()3405   public void pauseModelDeploymentMonitoringJobTest2() throws Exception {
3406     Empty expectedResponse = Empty.newBuilder().build();
3407     mockJobService.addResponse(expectedResponse);
3408 
3409     String name = "name3373707";
3410 
3411     client.pauseModelDeploymentMonitoringJob(name);
3412 
3413     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3414     Assert.assertEquals(1, actualRequests.size());
3415     PauseModelDeploymentMonitoringJobRequest actualRequest =
3416         ((PauseModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3417 
3418     Assert.assertEquals(name, actualRequest.getName());
3419     Assert.assertTrue(
3420         channelProvider.isHeaderSent(
3421             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3422             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3423   }
3424 
3425   @Test
pauseModelDeploymentMonitoringJobExceptionTest2()3426   public void pauseModelDeploymentMonitoringJobExceptionTest2() throws Exception {
3427     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3428     mockJobService.addException(exception);
3429 
3430     try {
3431       String name = "name3373707";
3432       client.pauseModelDeploymentMonitoringJob(name);
3433       Assert.fail("No exception raised");
3434     } catch (InvalidArgumentException e) {
3435       // Expected exception.
3436     }
3437   }
3438 
3439   @Test
resumeModelDeploymentMonitoringJobTest()3440   public void resumeModelDeploymentMonitoringJobTest() throws Exception {
3441     Empty expectedResponse = Empty.newBuilder().build();
3442     mockJobService.addResponse(expectedResponse);
3443 
3444     ModelDeploymentMonitoringJobName name =
3445         ModelDeploymentMonitoringJobName.of(
3446             "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3447 
3448     client.resumeModelDeploymentMonitoringJob(name);
3449 
3450     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3451     Assert.assertEquals(1, actualRequests.size());
3452     ResumeModelDeploymentMonitoringJobRequest actualRequest =
3453         ((ResumeModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3454 
3455     Assert.assertEquals(name.toString(), actualRequest.getName());
3456     Assert.assertTrue(
3457         channelProvider.isHeaderSent(
3458             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3459             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3460   }
3461 
3462   @Test
resumeModelDeploymentMonitoringJobExceptionTest()3463   public void resumeModelDeploymentMonitoringJobExceptionTest() throws Exception {
3464     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3465     mockJobService.addException(exception);
3466 
3467     try {
3468       ModelDeploymentMonitoringJobName name =
3469           ModelDeploymentMonitoringJobName.of(
3470               "[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]");
3471       client.resumeModelDeploymentMonitoringJob(name);
3472       Assert.fail("No exception raised");
3473     } catch (InvalidArgumentException e) {
3474       // Expected exception.
3475     }
3476   }
3477 
3478   @Test
resumeModelDeploymentMonitoringJobTest2()3479   public void resumeModelDeploymentMonitoringJobTest2() throws Exception {
3480     Empty expectedResponse = Empty.newBuilder().build();
3481     mockJobService.addResponse(expectedResponse);
3482 
3483     String name = "name3373707";
3484 
3485     client.resumeModelDeploymentMonitoringJob(name);
3486 
3487     List<AbstractMessage> actualRequests = mockJobService.getRequests();
3488     Assert.assertEquals(1, actualRequests.size());
3489     ResumeModelDeploymentMonitoringJobRequest actualRequest =
3490         ((ResumeModelDeploymentMonitoringJobRequest) actualRequests.get(0));
3491 
3492     Assert.assertEquals(name, actualRequest.getName());
3493     Assert.assertTrue(
3494         channelProvider.isHeaderSent(
3495             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3496             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3497   }
3498 
3499   @Test
resumeModelDeploymentMonitoringJobExceptionTest2()3500   public void resumeModelDeploymentMonitoringJobExceptionTest2() throws Exception {
3501     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3502     mockJobService.addException(exception);
3503 
3504     try {
3505       String name = "name3373707";
3506       client.resumeModelDeploymentMonitoringJob(name);
3507       Assert.fail("No exception raised");
3508     } catch (InvalidArgumentException e) {
3509       // Expected exception.
3510     }
3511   }
3512 
3513   @Test
listLocationsTest()3514   public void listLocationsTest() throws Exception {
3515     Location responsesElement = Location.newBuilder().build();
3516     ListLocationsResponse expectedResponse =
3517         ListLocationsResponse.newBuilder()
3518             .setNextPageToken("")
3519             .addAllLocations(Arrays.asList(responsesElement))
3520             .build();
3521     mockLocations.addResponse(expectedResponse);
3522 
3523     ListLocationsRequest request =
3524         ListLocationsRequest.newBuilder()
3525             .setName("name3373707")
3526             .setFilter("filter-1274492040")
3527             .setPageSize(883849137)
3528             .setPageToken("pageToken873572522")
3529             .build();
3530 
3531     ListLocationsPagedResponse pagedListResponse = client.listLocations(request);
3532 
3533     List<Location> resources = Lists.newArrayList(pagedListResponse.iterateAll());
3534 
3535     Assert.assertEquals(1, resources.size());
3536     Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0));
3537 
3538     List<AbstractMessage> actualRequests = mockLocations.getRequests();
3539     Assert.assertEquals(1, actualRequests.size());
3540     ListLocationsRequest actualRequest = ((ListLocationsRequest) actualRequests.get(0));
3541 
3542     Assert.assertEquals(request.getName(), actualRequest.getName());
3543     Assert.assertEquals(request.getFilter(), actualRequest.getFilter());
3544     Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
3545     Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
3546     Assert.assertTrue(
3547         channelProvider.isHeaderSent(
3548             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3549             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3550   }
3551 
3552   @Test
listLocationsExceptionTest()3553   public void listLocationsExceptionTest() throws Exception {
3554     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3555     mockLocations.addException(exception);
3556 
3557     try {
3558       ListLocationsRequest request =
3559           ListLocationsRequest.newBuilder()
3560               .setName("name3373707")
3561               .setFilter("filter-1274492040")
3562               .setPageSize(883849137)
3563               .setPageToken("pageToken873572522")
3564               .build();
3565       client.listLocations(request);
3566       Assert.fail("No exception raised");
3567     } catch (InvalidArgumentException e) {
3568       // Expected exception.
3569     }
3570   }
3571 
3572   @Test
getLocationTest()3573   public void getLocationTest() throws Exception {
3574     Location expectedResponse =
3575         Location.newBuilder()
3576             .setName("name3373707")
3577             .setLocationId("locationId1541836720")
3578             .setDisplayName("displayName1714148973")
3579             .putAllLabels(new HashMap<String, String>())
3580             .setMetadata(Any.newBuilder().build())
3581             .build();
3582     mockLocations.addResponse(expectedResponse);
3583 
3584     GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
3585 
3586     Location actualResponse = client.getLocation(request);
3587     Assert.assertEquals(expectedResponse, actualResponse);
3588 
3589     List<AbstractMessage> actualRequests = mockLocations.getRequests();
3590     Assert.assertEquals(1, actualRequests.size());
3591     GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0));
3592 
3593     Assert.assertEquals(request.getName(), actualRequest.getName());
3594     Assert.assertTrue(
3595         channelProvider.isHeaderSent(
3596             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3597             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3598   }
3599 
3600   @Test
getLocationExceptionTest()3601   public void getLocationExceptionTest() throws Exception {
3602     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3603     mockLocations.addException(exception);
3604 
3605     try {
3606       GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
3607       client.getLocation(request);
3608       Assert.fail("No exception raised");
3609     } catch (InvalidArgumentException e) {
3610       // Expected exception.
3611     }
3612   }
3613 
3614   @Test
setIamPolicyTest()3615   public void setIamPolicyTest() throws Exception {
3616     Policy expectedResponse =
3617         Policy.newBuilder()
3618             .setVersion(351608024)
3619             .addAllBindings(new ArrayList<Binding>())
3620             .addAllAuditConfigs(new ArrayList<AuditConfig>())
3621             .setEtag(ByteString.EMPTY)
3622             .build();
3623     mockIAMPolicy.addResponse(expectedResponse);
3624 
3625     SetIamPolicyRequest request =
3626         SetIamPolicyRequest.newBuilder()
3627             .setResource(
3628                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3629                     .toString())
3630             .setPolicy(Policy.newBuilder().build())
3631             .setUpdateMask(FieldMask.newBuilder().build())
3632             .build();
3633 
3634     Policy actualResponse = client.setIamPolicy(request);
3635     Assert.assertEquals(expectedResponse, actualResponse);
3636 
3637     List<AbstractMessage> actualRequests = mockIAMPolicy.getRequests();
3638     Assert.assertEquals(1, actualRequests.size());
3639     SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0));
3640 
3641     Assert.assertEquals(request.getResource(), actualRequest.getResource());
3642     Assert.assertEquals(request.getPolicy(), actualRequest.getPolicy());
3643     Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
3644     Assert.assertTrue(
3645         channelProvider.isHeaderSent(
3646             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3647             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3648   }
3649 
3650   @Test
setIamPolicyExceptionTest()3651   public void setIamPolicyExceptionTest() throws Exception {
3652     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3653     mockIAMPolicy.addException(exception);
3654 
3655     try {
3656       SetIamPolicyRequest request =
3657           SetIamPolicyRequest.newBuilder()
3658               .setResource(
3659                   EndpointName.ofProjectLocationEndpointName(
3660                           "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3661                       .toString())
3662               .setPolicy(Policy.newBuilder().build())
3663               .setUpdateMask(FieldMask.newBuilder().build())
3664               .build();
3665       client.setIamPolicy(request);
3666       Assert.fail("No exception raised");
3667     } catch (InvalidArgumentException e) {
3668       // Expected exception.
3669     }
3670   }
3671 
3672   @Test
getIamPolicyTest()3673   public void getIamPolicyTest() throws Exception {
3674     Policy expectedResponse =
3675         Policy.newBuilder()
3676             .setVersion(351608024)
3677             .addAllBindings(new ArrayList<Binding>())
3678             .addAllAuditConfigs(new ArrayList<AuditConfig>())
3679             .setEtag(ByteString.EMPTY)
3680             .build();
3681     mockIAMPolicy.addResponse(expectedResponse);
3682 
3683     GetIamPolicyRequest request =
3684         GetIamPolicyRequest.newBuilder()
3685             .setResource(
3686                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3687                     .toString())
3688             .setOptions(GetPolicyOptions.newBuilder().build())
3689             .build();
3690 
3691     Policy actualResponse = client.getIamPolicy(request);
3692     Assert.assertEquals(expectedResponse, actualResponse);
3693 
3694     List<AbstractMessage> actualRequests = mockIAMPolicy.getRequests();
3695     Assert.assertEquals(1, actualRequests.size());
3696     GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0));
3697 
3698     Assert.assertEquals(request.getResource(), actualRequest.getResource());
3699     Assert.assertEquals(request.getOptions(), actualRequest.getOptions());
3700     Assert.assertTrue(
3701         channelProvider.isHeaderSent(
3702             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3703             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3704   }
3705 
3706   @Test
getIamPolicyExceptionTest()3707   public void getIamPolicyExceptionTest() throws Exception {
3708     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3709     mockIAMPolicy.addException(exception);
3710 
3711     try {
3712       GetIamPolicyRequest request =
3713           GetIamPolicyRequest.newBuilder()
3714               .setResource(
3715                   EndpointName.ofProjectLocationEndpointName(
3716                           "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3717                       .toString())
3718               .setOptions(GetPolicyOptions.newBuilder().build())
3719               .build();
3720       client.getIamPolicy(request);
3721       Assert.fail("No exception raised");
3722     } catch (InvalidArgumentException e) {
3723       // Expected exception.
3724     }
3725   }
3726 
3727   @Test
testIamPermissionsTest()3728   public void testIamPermissionsTest() throws Exception {
3729     TestIamPermissionsResponse expectedResponse =
3730         TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList<String>()).build();
3731     mockIAMPolicy.addResponse(expectedResponse);
3732 
3733     TestIamPermissionsRequest request =
3734         TestIamPermissionsRequest.newBuilder()
3735             .setResource(
3736                 EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3737                     .toString())
3738             .addAllPermissions(new ArrayList<String>())
3739             .build();
3740 
3741     TestIamPermissionsResponse actualResponse = client.testIamPermissions(request);
3742     Assert.assertEquals(expectedResponse, actualResponse);
3743 
3744     List<AbstractMessage> actualRequests = mockIAMPolicy.getRequests();
3745     Assert.assertEquals(1, actualRequests.size());
3746     TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0));
3747 
3748     Assert.assertEquals(request.getResource(), actualRequest.getResource());
3749     Assert.assertEquals(request.getPermissionsList(), actualRequest.getPermissionsList());
3750     Assert.assertTrue(
3751         channelProvider.isHeaderSent(
3752             ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
3753             GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
3754   }
3755 
3756   @Test
testIamPermissionsExceptionTest()3757   public void testIamPermissionsExceptionTest() throws Exception {
3758     StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
3759     mockIAMPolicy.addException(exception);
3760 
3761     try {
3762       TestIamPermissionsRequest request =
3763           TestIamPermissionsRequest.newBuilder()
3764               .setResource(
3765                   EndpointName.ofProjectLocationEndpointName(
3766                           "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
3767                       .toString())
3768               .addAllPermissions(new ArrayList<String>())
3769               .build();
3770       client.testIamPermissions(request);
3771       Assert.fail("No exception raised");
3772     } catch (InvalidArgumentException e) {
3773       // Expected exception.
3774     }
3775   }
3776 }
3777