use of com.google.cloud.speech.v1p1beta1.AdaptationClient.ListCustomClassesPagedResponse in project java-speech by googleapis.
the class AdaptationClientTest method listCustomClassesTest.
@Test
public void listCustomClassesTest() throws Exception {
CustomClass responsesElement = CustomClass.newBuilder().build();
ListCustomClassesResponse expectedResponse = ListCustomClassesResponse.newBuilder().setNextPageToken("").addAllCustomClasses(Arrays.asList(responsesElement)).build();
mockAdaptation.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListCustomClassesPagedResponse pagedListResponse = client.listCustomClasses(parent);
List<CustomClass> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCustomClassesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockAdaptation.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCustomClassesRequest actualRequest = ((ListCustomClassesRequest) 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.ListCustomClassesPagedResponse in project java-speech by googleapis.
the class AdaptationClientTest method listCustomClassesTest2.
@Test
public void listCustomClassesTest2() throws Exception {
CustomClass responsesElement = CustomClass.newBuilder().build();
ListCustomClassesResponse expectedResponse = ListCustomClassesResponse.newBuilder().setNextPageToken("").addAllCustomClasses(Arrays.asList(responsesElement)).build();
mockAdaptation.addResponse(expectedResponse);
String parent = "parent-995424086";
ListCustomClassesPagedResponse pagedListResponse = client.listCustomClasses(parent);
List<CustomClass> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCustomClassesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockAdaptation.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCustomClassesRequest actualRequest = ((ListCustomClassesRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations