use of com.google.cloud.speech.v1p1beta1.AdaptationClient.ListPhraseSetPagedResponse in project java-speech by googleapis.
the class AdaptationClientTest method listPhraseSetTest.
@Test
public void listPhraseSetTest() throws Exception {
PhraseSet responsesElement = PhraseSet.newBuilder().build();
ListPhraseSetResponse expectedResponse = ListPhraseSetResponse.newBuilder().setNextPageToken("").addAllPhraseSets(Arrays.asList(responsesElement)).build();
mockAdaptation.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListPhraseSetPagedResponse pagedListResponse = client.listPhraseSet(parent);
List<PhraseSet> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getPhraseSetsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockAdaptation.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListPhraseSetRequest actualRequest = ((ListPhraseSetRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.speech.v1p1beta1.AdaptationClient.ListPhraseSetPagedResponse in project java-speech by googleapis.
the class AdaptationClientTest method listPhraseSetTest2.
@Test
public void listPhraseSetTest2() throws Exception {
PhraseSet responsesElement = PhraseSet.newBuilder().build();
ListPhraseSetResponse expectedResponse = ListPhraseSetResponse.newBuilder().setNextPageToken("").addAllPhraseSets(Arrays.asList(responsesElement)).build();
mockAdaptation.addResponse(expectedResponse);
String parent = "parent-995424086";
ListPhraseSetPagedResponse pagedListResponse = client.listPhraseSet(parent);
List<PhraseSet> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getPhraseSetsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockAdaptation.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListPhraseSetRequest actualRequest = ((ListPhraseSetRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations