• 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.datacatalog.v1;
18 
19 import com.google.api.core.BetaApi;
20 import com.google.cloud.datacatalog.v1.DataCatalogGrpc.DataCatalogImplBase;
21 import com.google.iam.v1.GetIamPolicyRequest;
22 import com.google.iam.v1.Policy;
23 import com.google.iam.v1.SetIamPolicyRequest;
24 import com.google.iam.v1.TestIamPermissionsRequest;
25 import com.google.iam.v1.TestIamPermissionsResponse;
26 import com.google.longrunning.Operation;
27 import com.google.protobuf.AbstractMessage;
28 import com.google.protobuf.Empty;
29 import io.grpc.stub.StreamObserver;
30 import java.util.ArrayList;
31 import java.util.LinkedList;
32 import java.util.List;
33 import java.util.Queue;
34 import javax.annotation.Generated;
35 
36 @BetaApi
37 @Generated("by gapic-generator-java")
38 public class MockDataCatalogImpl extends DataCatalogImplBase {
39   private List<AbstractMessage> requests;
40   private Queue<Object> responses;
41 
MockDataCatalogImpl()42   public MockDataCatalogImpl() {
43     requests = new ArrayList<>();
44     responses = new LinkedList<>();
45   }
46 
getRequests()47   public List<AbstractMessage> getRequests() {
48     return requests;
49   }
50 
addResponse(AbstractMessage response)51   public void addResponse(AbstractMessage response) {
52     responses.add(response);
53   }
54 
setResponses(List<AbstractMessage> responses)55   public void setResponses(List<AbstractMessage> responses) {
56     this.responses = new LinkedList<Object>(responses);
57   }
58 
addException(Exception exception)59   public void addException(Exception exception) {
60     responses.add(exception);
61   }
62 
reset()63   public void reset() {
64     requests = new ArrayList<>();
65     responses = new LinkedList<>();
66   }
67 
68   @Override
searchCatalog( SearchCatalogRequest request, StreamObserver<SearchCatalogResponse> responseObserver)69   public void searchCatalog(
70       SearchCatalogRequest request, StreamObserver<SearchCatalogResponse> responseObserver) {
71     Object response = responses.poll();
72     if (response instanceof SearchCatalogResponse) {
73       requests.add(request);
74       responseObserver.onNext(((SearchCatalogResponse) response));
75       responseObserver.onCompleted();
76     } else if (response instanceof Exception) {
77       responseObserver.onError(((Exception) response));
78     } else {
79       responseObserver.onError(
80           new IllegalArgumentException(
81               String.format(
82                   "Unrecognized response type %s for method SearchCatalog, expected %s or %s",
83                   response == null ? "null" : response.getClass().getName(),
84                   SearchCatalogResponse.class.getName(),
85                   Exception.class.getName())));
86     }
87   }
88 
89   @Override
createEntryGroup( CreateEntryGroupRequest request, StreamObserver<EntryGroup> responseObserver)90   public void createEntryGroup(
91       CreateEntryGroupRequest request, StreamObserver<EntryGroup> responseObserver) {
92     Object response = responses.poll();
93     if (response instanceof EntryGroup) {
94       requests.add(request);
95       responseObserver.onNext(((EntryGroup) response));
96       responseObserver.onCompleted();
97     } else if (response instanceof Exception) {
98       responseObserver.onError(((Exception) response));
99     } else {
100       responseObserver.onError(
101           new IllegalArgumentException(
102               String.format(
103                   "Unrecognized response type %s for method CreateEntryGroup, expected %s or %s",
104                   response == null ? "null" : response.getClass().getName(),
105                   EntryGroup.class.getName(),
106                   Exception.class.getName())));
107     }
108   }
109 
110   @Override
getEntryGroup( GetEntryGroupRequest request, StreamObserver<EntryGroup> responseObserver)111   public void getEntryGroup(
112       GetEntryGroupRequest request, StreamObserver<EntryGroup> responseObserver) {
113     Object response = responses.poll();
114     if (response instanceof EntryGroup) {
115       requests.add(request);
116       responseObserver.onNext(((EntryGroup) response));
117       responseObserver.onCompleted();
118     } else if (response instanceof Exception) {
119       responseObserver.onError(((Exception) response));
120     } else {
121       responseObserver.onError(
122           new IllegalArgumentException(
123               String.format(
124                   "Unrecognized response type %s for method GetEntryGroup, expected %s or %s",
125                   response == null ? "null" : response.getClass().getName(),
126                   EntryGroup.class.getName(),
127                   Exception.class.getName())));
128     }
129   }
130 
131   @Override
updateEntryGroup( UpdateEntryGroupRequest request, StreamObserver<EntryGroup> responseObserver)132   public void updateEntryGroup(
133       UpdateEntryGroupRequest request, StreamObserver<EntryGroup> responseObserver) {
134     Object response = responses.poll();
135     if (response instanceof EntryGroup) {
136       requests.add(request);
137       responseObserver.onNext(((EntryGroup) response));
138       responseObserver.onCompleted();
139     } else if (response instanceof Exception) {
140       responseObserver.onError(((Exception) response));
141     } else {
142       responseObserver.onError(
143           new IllegalArgumentException(
144               String.format(
145                   "Unrecognized response type %s for method UpdateEntryGroup, expected %s or %s",
146                   response == null ? "null" : response.getClass().getName(),
147                   EntryGroup.class.getName(),
148                   Exception.class.getName())));
149     }
150   }
151 
152   @Override
deleteEntryGroup( DeleteEntryGroupRequest request, StreamObserver<Empty> responseObserver)153   public void deleteEntryGroup(
154       DeleteEntryGroupRequest request, StreamObserver<Empty> responseObserver) {
155     Object response = responses.poll();
156     if (response instanceof Empty) {
157       requests.add(request);
158       responseObserver.onNext(((Empty) response));
159       responseObserver.onCompleted();
160     } else if (response instanceof Exception) {
161       responseObserver.onError(((Exception) response));
162     } else {
163       responseObserver.onError(
164           new IllegalArgumentException(
165               String.format(
166                   "Unrecognized response type %s for method DeleteEntryGroup, expected %s or %s",
167                   response == null ? "null" : response.getClass().getName(),
168                   Empty.class.getName(),
169                   Exception.class.getName())));
170     }
171   }
172 
173   @Override
listEntryGroups( ListEntryGroupsRequest request, StreamObserver<ListEntryGroupsResponse> responseObserver)174   public void listEntryGroups(
175       ListEntryGroupsRequest request, StreamObserver<ListEntryGroupsResponse> responseObserver) {
176     Object response = responses.poll();
177     if (response instanceof ListEntryGroupsResponse) {
178       requests.add(request);
179       responseObserver.onNext(((ListEntryGroupsResponse) response));
180       responseObserver.onCompleted();
181     } else if (response instanceof Exception) {
182       responseObserver.onError(((Exception) response));
183     } else {
184       responseObserver.onError(
185           new IllegalArgumentException(
186               String.format(
187                   "Unrecognized response type %s for method ListEntryGroups, expected %s or %s",
188                   response == null ? "null" : response.getClass().getName(),
189                   ListEntryGroupsResponse.class.getName(),
190                   Exception.class.getName())));
191     }
192   }
193 
194   @Override
createEntry(CreateEntryRequest request, StreamObserver<Entry> responseObserver)195   public void createEntry(CreateEntryRequest request, StreamObserver<Entry> responseObserver) {
196     Object response = responses.poll();
197     if (response instanceof Entry) {
198       requests.add(request);
199       responseObserver.onNext(((Entry) response));
200       responseObserver.onCompleted();
201     } else if (response instanceof Exception) {
202       responseObserver.onError(((Exception) response));
203     } else {
204       responseObserver.onError(
205           new IllegalArgumentException(
206               String.format(
207                   "Unrecognized response type %s for method CreateEntry, expected %s or %s",
208                   response == null ? "null" : response.getClass().getName(),
209                   Entry.class.getName(),
210                   Exception.class.getName())));
211     }
212   }
213 
214   @Override
updateEntry(UpdateEntryRequest request, StreamObserver<Entry> responseObserver)215   public void updateEntry(UpdateEntryRequest request, StreamObserver<Entry> responseObserver) {
216     Object response = responses.poll();
217     if (response instanceof Entry) {
218       requests.add(request);
219       responseObserver.onNext(((Entry) response));
220       responseObserver.onCompleted();
221     } else if (response instanceof Exception) {
222       responseObserver.onError(((Exception) response));
223     } else {
224       responseObserver.onError(
225           new IllegalArgumentException(
226               String.format(
227                   "Unrecognized response type %s for method UpdateEntry, expected %s or %s",
228                   response == null ? "null" : response.getClass().getName(),
229                   Entry.class.getName(),
230                   Exception.class.getName())));
231     }
232   }
233 
234   @Override
deleteEntry(DeleteEntryRequest request, StreamObserver<Empty> responseObserver)235   public void deleteEntry(DeleteEntryRequest request, StreamObserver<Empty> responseObserver) {
236     Object response = responses.poll();
237     if (response instanceof Empty) {
238       requests.add(request);
239       responseObserver.onNext(((Empty) response));
240       responseObserver.onCompleted();
241     } else if (response instanceof Exception) {
242       responseObserver.onError(((Exception) response));
243     } else {
244       responseObserver.onError(
245           new IllegalArgumentException(
246               String.format(
247                   "Unrecognized response type %s for method DeleteEntry, expected %s or %s",
248                   response == null ? "null" : response.getClass().getName(),
249                   Empty.class.getName(),
250                   Exception.class.getName())));
251     }
252   }
253 
254   @Override
getEntry(GetEntryRequest request, StreamObserver<Entry> responseObserver)255   public void getEntry(GetEntryRequest request, StreamObserver<Entry> responseObserver) {
256     Object response = responses.poll();
257     if (response instanceof Entry) {
258       requests.add(request);
259       responseObserver.onNext(((Entry) response));
260       responseObserver.onCompleted();
261     } else if (response instanceof Exception) {
262       responseObserver.onError(((Exception) response));
263     } else {
264       responseObserver.onError(
265           new IllegalArgumentException(
266               String.format(
267                   "Unrecognized response type %s for method GetEntry, expected %s or %s",
268                   response == null ? "null" : response.getClass().getName(),
269                   Entry.class.getName(),
270                   Exception.class.getName())));
271     }
272   }
273 
274   @Override
lookupEntry(LookupEntryRequest request, StreamObserver<Entry> responseObserver)275   public void lookupEntry(LookupEntryRequest request, StreamObserver<Entry> responseObserver) {
276     Object response = responses.poll();
277     if (response instanceof Entry) {
278       requests.add(request);
279       responseObserver.onNext(((Entry) response));
280       responseObserver.onCompleted();
281     } else if (response instanceof Exception) {
282       responseObserver.onError(((Exception) response));
283     } else {
284       responseObserver.onError(
285           new IllegalArgumentException(
286               String.format(
287                   "Unrecognized response type %s for method LookupEntry, expected %s or %s",
288                   response == null ? "null" : response.getClass().getName(),
289                   Entry.class.getName(),
290                   Exception.class.getName())));
291     }
292   }
293 
294   @Override
listEntries( ListEntriesRequest request, StreamObserver<ListEntriesResponse> responseObserver)295   public void listEntries(
296       ListEntriesRequest request, StreamObserver<ListEntriesResponse> responseObserver) {
297     Object response = responses.poll();
298     if (response instanceof ListEntriesResponse) {
299       requests.add(request);
300       responseObserver.onNext(((ListEntriesResponse) response));
301       responseObserver.onCompleted();
302     } else if (response instanceof Exception) {
303       responseObserver.onError(((Exception) response));
304     } else {
305       responseObserver.onError(
306           new IllegalArgumentException(
307               String.format(
308                   "Unrecognized response type %s for method ListEntries, expected %s or %s",
309                   response == null ? "null" : response.getClass().getName(),
310                   ListEntriesResponse.class.getName(),
311                   Exception.class.getName())));
312     }
313   }
314 
315   @Override
modifyEntryOverview( ModifyEntryOverviewRequest request, StreamObserver<EntryOverview> responseObserver)316   public void modifyEntryOverview(
317       ModifyEntryOverviewRequest request, StreamObserver<EntryOverview> responseObserver) {
318     Object response = responses.poll();
319     if (response instanceof EntryOverview) {
320       requests.add(request);
321       responseObserver.onNext(((EntryOverview) response));
322       responseObserver.onCompleted();
323     } else if (response instanceof Exception) {
324       responseObserver.onError(((Exception) response));
325     } else {
326       responseObserver.onError(
327           new IllegalArgumentException(
328               String.format(
329                   "Unrecognized response type %s for method ModifyEntryOverview, expected %s or %s",
330                   response == null ? "null" : response.getClass().getName(),
331                   EntryOverview.class.getName(),
332                   Exception.class.getName())));
333     }
334   }
335 
336   @Override
modifyEntryContacts( ModifyEntryContactsRequest request, StreamObserver<Contacts> responseObserver)337   public void modifyEntryContacts(
338       ModifyEntryContactsRequest request, StreamObserver<Contacts> responseObserver) {
339     Object response = responses.poll();
340     if (response instanceof Contacts) {
341       requests.add(request);
342       responseObserver.onNext(((Contacts) response));
343       responseObserver.onCompleted();
344     } else if (response instanceof Exception) {
345       responseObserver.onError(((Exception) response));
346     } else {
347       responseObserver.onError(
348           new IllegalArgumentException(
349               String.format(
350                   "Unrecognized response type %s for method ModifyEntryContacts, expected %s or %s",
351                   response == null ? "null" : response.getClass().getName(),
352                   Contacts.class.getName(),
353                   Exception.class.getName())));
354     }
355   }
356 
357   @Override
createTagTemplate( CreateTagTemplateRequest request, StreamObserver<TagTemplate> responseObserver)358   public void createTagTemplate(
359       CreateTagTemplateRequest request, StreamObserver<TagTemplate> responseObserver) {
360     Object response = responses.poll();
361     if (response instanceof TagTemplate) {
362       requests.add(request);
363       responseObserver.onNext(((TagTemplate) response));
364       responseObserver.onCompleted();
365     } else if (response instanceof Exception) {
366       responseObserver.onError(((Exception) response));
367     } else {
368       responseObserver.onError(
369           new IllegalArgumentException(
370               String.format(
371                   "Unrecognized response type %s for method CreateTagTemplate, expected %s or %s",
372                   response == null ? "null" : response.getClass().getName(),
373                   TagTemplate.class.getName(),
374                   Exception.class.getName())));
375     }
376   }
377 
378   @Override
getTagTemplate( GetTagTemplateRequest request, StreamObserver<TagTemplate> responseObserver)379   public void getTagTemplate(
380       GetTagTemplateRequest request, StreamObserver<TagTemplate> responseObserver) {
381     Object response = responses.poll();
382     if (response instanceof TagTemplate) {
383       requests.add(request);
384       responseObserver.onNext(((TagTemplate) response));
385       responseObserver.onCompleted();
386     } else if (response instanceof Exception) {
387       responseObserver.onError(((Exception) response));
388     } else {
389       responseObserver.onError(
390           new IllegalArgumentException(
391               String.format(
392                   "Unrecognized response type %s for method GetTagTemplate, expected %s or %s",
393                   response == null ? "null" : response.getClass().getName(),
394                   TagTemplate.class.getName(),
395                   Exception.class.getName())));
396     }
397   }
398 
399   @Override
updateTagTemplate( UpdateTagTemplateRequest request, StreamObserver<TagTemplate> responseObserver)400   public void updateTagTemplate(
401       UpdateTagTemplateRequest request, StreamObserver<TagTemplate> responseObserver) {
402     Object response = responses.poll();
403     if (response instanceof TagTemplate) {
404       requests.add(request);
405       responseObserver.onNext(((TagTemplate) response));
406       responseObserver.onCompleted();
407     } else if (response instanceof Exception) {
408       responseObserver.onError(((Exception) response));
409     } else {
410       responseObserver.onError(
411           new IllegalArgumentException(
412               String.format(
413                   "Unrecognized response type %s for method UpdateTagTemplate, expected %s or %s",
414                   response == null ? "null" : response.getClass().getName(),
415                   TagTemplate.class.getName(),
416                   Exception.class.getName())));
417     }
418   }
419 
420   @Override
deleteTagTemplate( DeleteTagTemplateRequest request, StreamObserver<Empty> responseObserver)421   public void deleteTagTemplate(
422       DeleteTagTemplateRequest request, StreamObserver<Empty> responseObserver) {
423     Object response = responses.poll();
424     if (response instanceof Empty) {
425       requests.add(request);
426       responseObserver.onNext(((Empty) response));
427       responseObserver.onCompleted();
428     } else if (response instanceof Exception) {
429       responseObserver.onError(((Exception) response));
430     } else {
431       responseObserver.onError(
432           new IllegalArgumentException(
433               String.format(
434                   "Unrecognized response type %s for method DeleteTagTemplate, expected %s or %s",
435                   response == null ? "null" : response.getClass().getName(),
436                   Empty.class.getName(),
437                   Exception.class.getName())));
438     }
439   }
440 
441   @Override
createTagTemplateField( CreateTagTemplateFieldRequest request, StreamObserver<TagTemplateField> responseObserver)442   public void createTagTemplateField(
443       CreateTagTemplateFieldRequest request, StreamObserver<TagTemplateField> responseObserver) {
444     Object response = responses.poll();
445     if (response instanceof TagTemplateField) {
446       requests.add(request);
447       responseObserver.onNext(((TagTemplateField) response));
448       responseObserver.onCompleted();
449     } else if (response instanceof Exception) {
450       responseObserver.onError(((Exception) response));
451     } else {
452       responseObserver.onError(
453           new IllegalArgumentException(
454               String.format(
455                   "Unrecognized response type %s for method CreateTagTemplateField, expected %s or %s",
456                   response == null ? "null" : response.getClass().getName(),
457                   TagTemplateField.class.getName(),
458                   Exception.class.getName())));
459     }
460   }
461 
462   @Override
updateTagTemplateField( UpdateTagTemplateFieldRequest request, StreamObserver<TagTemplateField> responseObserver)463   public void updateTagTemplateField(
464       UpdateTagTemplateFieldRequest request, StreamObserver<TagTemplateField> responseObserver) {
465     Object response = responses.poll();
466     if (response instanceof TagTemplateField) {
467       requests.add(request);
468       responseObserver.onNext(((TagTemplateField) response));
469       responseObserver.onCompleted();
470     } else if (response instanceof Exception) {
471       responseObserver.onError(((Exception) response));
472     } else {
473       responseObserver.onError(
474           new IllegalArgumentException(
475               String.format(
476                   "Unrecognized response type %s for method UpdateTagTemplateField, expected %s or %s",
477                   response == null ? "null" : response.getClass().getName(),
478                   TagTemplateField.class.getName(),
479                   Exception.class.getName())));
480     }
481   }
482 
483   @Override
renameTagTemplateField( RenameTagTemplateFieldRequest request, StreamObserver<TagTemplateField> responseObserver)484   public void renameTagTemplateField(
485       RenameTagTemplateFieldRequest request, StreamObserver<TagTemplateField> responseObserver) {
486     Object response = responses.poll();
487     if (response instanceof TagTemplateField) {
488       requests.add(request);
489       responseObserver.onNext(((TagTemplateField) response));
490       responseObserver.onCompleted();
491     } else if (response instanceof Exception) {
492       responseObserver.onError(((Exception) response));
493     } else {
494       responseObserver.onError(
495           new IllegalArgumentException(
496               String.format(
497                   "Unrecognized response type %s for method RenameTagTemplateField, expected %s or %s",
498                   response == null ? "null" : response.getClass().getName(),
499                   TagTemplateField.class.getName(),
500                   Exception.class.getName())));
501     }
502   }
503 
504   @Override
renameTagTemplateFieldEnumValue( RenameTagTemplateFieldEnumValueRequest request, StreamObserver<TagTemplateField> responseObserver)505   public void renameTagTemplateFieldEnumValue(
506       RenameTagTemplateFieldEnumValueRequest request,
507       StreamObserver<TagTemplateField> responseObserver) {
508     Object response = responses.poll();
509     if (response instanceof TagTemplateField) {
510       requests.add(request);
511       responseObserver.onNext(((TagTemplateField) response));
512       responseObserver.onCompleted();
513     } else if (response instanceof Exception) {
514       responseObserver.onError(((Exception) response));
515     } else {
516       responseObserver.onError(
517           new IllegalArgumentException(
518               String.format(
519                   "Unrecognized response type %s for method RenameTagTemplateFieldEnumValue, expected %s or %s",
520                   response == null ? "null" : response.getClass().getName(),
521                   TagTemplateField.class.getName(),
522                   Exception.class.getName())));
523     }
524   }
525 
526   @Override
deleteTagTemplateField( DeleteTagTemplateFieldRequest request, StreamObserver<Empty> responseObserver)527   public void deleteTagTemplateField(
528       DeleteTagTemplateFieldRequest request, StreamObserver<Empty> responseObserver) {
529     Object response = responses.poll();
530     if (response instanceof Empty) {
531       requests.add(request);
532       responseObserver.onNext(((Empty) response));
533       responseObserver.onCompleted();
534     } else if (response instanceof Exception) {
535       responseObserver.onError(((Exception) response));
536     } else {
537       responseObserver.onError(
538           new IllegalArgumentException(
539               String.format(
540                   "Unrecognized response type %s for method DeleteTagTemplateField, expected %s or %s",
541                   response == null ? "null" : response.getClass().getName(),
542                   Empty.class.getName(),
543                   Exception.class.getName())));
544     }
545   }
546 
547   @Override
createTag(CreateTagRequest request, StreamObserver<Tag> responseObserver)548   public void createTag(CreateTagRequest request, StreamObserver<Tag> responseObserver) {
549     Object response = responses.poll();
550     if (response instanceof Tag) {
551       requests.add(request);
552       responseObserver.onNext(((Tag) response));
553       responseObserver.onCompleted();
554     } else if (response instanceof Exception) {
555       responseObserver.onError(((Exception) response));
556     } else {
557       responseObserver.onError(
558           new IllegalArgumentException(
559               String.format(
560                   "Unrecognized response type %s for method CreateTag, expected %s or %s",
561                   response == null ? "null" : response.getClass().getName(),
562                   Tag.class.getName(),
563                   Exception.class.getName())));
564     }
565   }
566 
567   @Override
updateTag(UpdateTagRequest request, StreamObserver<Tag> responseObserver)568   public void updateTag(UpdateTagRequest request, StreamObserver<Tag> responseObserver) {
569     Object response = responses.poll();
570     if (response instanceof Tag) {
571       requests.add(request);
572       responseObserver.onNext(((Tag) response));
573       responseObserver.onCompleted();
574     } else if (response instanceof Exception) {
575       responseObserver.onError(((Exception) response));
576     } else {
577       responseObserver.onError(
578           new IllegalArgumentException(
579               String.format(
580                   "Unrecognized response type %s for method UpdateTag, expected %s or %s",
581                   response == null ? "null" : response.getClass().getName(),
582                   Tag.class.getName(),
583                   Exception.class.getName())));
584     }
585   }
586 
587   @Override
deleteTag(DeleteTagRequest request, StreamObserver<Empty> responseObserver)588   public void deleteTag(DeleteTagRequest request, StreamObserver<Empty> responseObserver) {
589     Object response = responses.poll();
590     if (response instanceof Empty) {
591       requests.add(request);
592       responseObserver.onNext(((Empty) response));
593       responseObserver.onCompleted();
594     } else if (response instanceof Exception) {
595       responseObserver.onError(((Exception) response));
596     } else {
597       responseObserver.onError(
598           new IllegalArgumentException(
599               String.format(
600                   "Unrecognized response type %s for method DeleteTag, expected %s or %s",
601                   response == null ? "null" : response.getClass().getName(),
602                   Empty.class.getName(),
603                   Exception.class.getName())));
604     }
605   }
606 
607   @Override
listTags(ListTagsRequest request, StreamObserver<ListTagsResponse> responseObserver)608   public void listTags(ListTagsRequest request, StreamObserver<ListTagsResponse> responseObserver) {
609     Object response = responses.poll();
610     if (response instanceof ListTagsResponse) {
611       requests.add(request);
612       responseObserver.onNext(((ListTagsResponse) response));
613       responseObserver.onCompleted();
614     } else if (response instanceof Exception) {
615       responseObserver.onError(((Exception) response));
616     } else {
617       responseObserver.onError(
618           new IllegalArgumentException(
619               String.format(
620                   "Unrecognized response type %s for method ListTags, expected %s or %s",
621                   response == null ? "null" : response.getClass().getName(),
622                   ListTagsResponse.class.getName(),
623                   Exception.class.getName())));
624     }
625   }
626 
627   @Override
reconcileTags( ReconcileTagsRequest request, StreamObserver<Operation> responseObserver)628   public void reconcileTags(
629       ReconcileTagsRequest request, StreamObserver<Operation> responseObserver) {
630     Object response = responses.poll();
631     if (response instanceof Operation) {
632       requests.add(request);
633       responseObserver.onNext(((Operation) response));
634       responseObserver.onCompleted();
635     } else if (response instanceof Exception) {
636       responseObserver.onError(((Exception) response));
637     } else {
638       responseObserver.onError(
639           new IllegalArgumentException(
640               String.format(
641                   "Unrecognized response type %s for method ReconcileTags, expected %s or %s",
642                   response == null ? "null" : response.getClass().getName(),
643                   Operation.class.getName(),
644                   Exception.class.getName())));
645     }
646   }
647 
648   @Override
starEntry( StarEntryRequest request, StreamObserver<StarEntryResponse> responseObserver)649   public void starEntry(
650       StarEntryRequest request, StreamObserver<StarEntryResponse> responseObserver) {
651     Object response = responses.poll();
652     if (response instanceof StarEntryResponse) {
653       requests.add(request);
654       responseObserver.onNext(((StarEntryResponse) response));
655       responseObserver.onCompleted();
656     } else if (response instanceof Exception) {
657       responseObserver.onError(((Exception) response));
658     } else {
659       responseObserver.onError(
660           new IllegalArgumentException(
661               String.format(
662                   "Unrecognized response type %s for method StarEntry, expected %s or %s",
663                   response == null ? "null" : response.getClass().getName(),
664                   StarEntryResponse.class.getName(),
665                   Exception.class.getName())));
666     }
667   }
668 
669   @Override
unstarEntry( UnstarEntryRequest request, StreamObserver<UnstarEntryResponse> responseObserver)670   public void unstarEntry(
671       UnstarEntryRequest request, StreamObserver<UnstarEntryResponse> responseObserver) {
672     Object response = responses.poll();
673     if (response instanceof UnstarEntryResponse) {
674       requests.add(request);
675       responseObserver.onNext(((UnstarEntryResponse) response));
676       responseObserver.onCompleted();
677     } else if (response instanceof Exception) {
678       responseObserver.onError(((Exception) response));
679     } else {
680       responseObserver.onError(
681           new IllegalArgumentException(
682               String.format(
683                   "Unrecognized response type %s for method UnstarEntry, expected %s or %s",
684                   response == null ? "null" : response.getClass().getName(),
685                   UnstarEntryResponse.class.getName(),
686                   Exception.class.getName())));
687     }
688   }
689 
690   @Override
setIamPolicy(SetIamPolicyRequest request, StreamObserver<Policy> responseObserver)691   public void setIamPolicy(SetIamPolicyRequest request, StreamObserver<Policy> responseObserver) {
692     Object response = responses.poll();
693     if (response instanceof Policy) {
694       requests.add(request);
695       responseObserver.onNext(((Policy) response));
696       responseObserver.onCompleted();
697     } else if (response instanceof Exception) {
698       responseObserver.onError(((Exception) response));
699     } else {
700       responseObserver.onError(
701           new IllegalArgumentException(
702               String.format(
703                   "Unrecognized response type %s for method SetIamPolicy, expected %s or %s",
704                   response == null ? "null" : response.getClass().getName(),
705                   Policy.class.getName(),
706                   Exception.class.getName())));
707     }
708   }
709 
710   @Override
getIamPolicy(GetIamPolicyRequest request, StreamObserver<Policy> responseObserver)711   public void getIamPolicy(GetIamPolicyRequest request, StreamObserver<Policy> responseObserver) {
712     Object response = responses.poll();
713     if (response instanceof Policy) {
714       requests.add(request);
715       responseObserver.onNext(((Policy) response));
716       responseObserver.onCompleted();
717     } else if (response instanceof Exception) {
718       responseObserver.onError(((Exception) response));
719     } else {
720       responseObserver.onError(
721           new IllegalArgumentException(
722               String.format(
723                   "Unrecognized response type %s for method GetIamPolicy, expected %s or %s",
724                   response == null ? "null" : response.getClass().getName(),
725                   Policy.class.getName(),
726                   Exception.class.getName())));
727     }
728   }
729 
730   @Override
testIamPermissions( TestIamPermissionsRequest request, StreamObserver<TestIamPermissionsResponse> responseObserver)731   public void testIamPermissions(
732       TestIamPermissionsRequest request,
733       StreamObserver<TestIamPermissionsResponse> responseObserver) {
734     Object response = responses.poll();
735     if (response instanceof TestIamPermissionsResponse) {
736       requests.add(request);
737       responseObserver.onNext(((TestIamPermissionsResponse) response));
738       responseObserver.onCompleted();
739     } else if (response instanceof Exception) {
740       responseObserver.onError(((Exception) response));
741     } else {
742       responseObserver.onError(
743           new IllegalArgumentException(
744               String.format(
745                   "Unrecognized response type %s for method TestIamPermissions, expected %s or %s",
746                   response == null ? "null" : response.getClass().getName(),
747                   TestIamPermissionsResponse.class.getName(),
748                   Exception.class.getName())));
749     }
750   }
751 
752   @Override
importEntries( ImportEntriesRequest request, StreamObserver<Operation> responseObserver)753   public void importEntries(
754       ImportEntriesRequest request, StreamObserver<Operation> responseObserver) {
755     Object response = responses.poll();
756     if (response instanceof Operation) {
757       requests.add(request);
758       responseObserver.onNext(((Operation) response));
759       responseObserver.onCompleted();
760     } else if (response instanceof Exception) {
761       responseObserver.onError(((Exception) response));
762     } else {
763       responseObserver.onError(
764           new IllegalArgumentException(
765               String.format(
766                   "Unrecognized response type %s for method ImportEntries, expected %s or %s",
767                   response == null ? "null" : response.getClass().getName(),
768                   Operation.class.getName(),
769                   Exception.class.getName())));
770     }
771   }
772 }
773