Search in sources :

Example 1 with ListCustomClassesPagedResponse

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()));
}
Also used : ListCustomClassesPagedResponse(com.google.cloud.speech.v1p1beta1.AdaptationClient.ListCustomClassesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 2 with ListCustomClassesPagedResponse

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()));
}
Also used : ListCustomClassesPagedResponse(com.google.cloud.speech.v1p1beta1.AdaptationClient.ListCustomClassesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

ListCustomClassesPagedResponse (com.google.cloud.speech.v1p1beta1.AdaptationClient.ListCustomClassesPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2