Search in sources :

Example 1 with ListTableSpecsPagedResponse

use of com.google.cloud.automl.v1beta1.AutoMlClient.ListTableSpecsPagedResponse in project java-automl by googleapis.

the class AutoMlClientTest method listTableSpecsTest.

@Test
public void listTableSpecsTest() throws Exception {
    TableSpec responsesElement = TableSpec.newBuilder().build();
    ListTableSpecsResponse expectedResponse = ListTableSpecsResponse.newBuilder().setNextPageToken("").addAllTableSpecs(Arrays.asList(responsesElement)).build();
    mockAutoMl.addResponse(expectedResponse);
    DatasetName parent = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
    ListTableSpecsPagedResponse pagedListResponse = client.listTableSpecs(parent);
    List<TableSpec> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTableSpecsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockAutoMl.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTableSpecsRequest actualRequest = ((ListTableSpecsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListTableSpecsPagedResponse(com.google.cloud.automl.v1beta1.AutoMlClient.ListTableSpecsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 2 with ListTableSpecsPagedResponse

use of com.google.cloud.automl.v1beta1.AutoMlClient.ListTableSpecsPagedResponse in project java-automl by googleapis.

the class AutoMlClientTest method listTableSpecsTest2.

@Test
public void listTableSpecsTest2() throws Exception {
    TableSpec responsesElement = TableSpec.newBuilder().build();
    ListTableSpecsResponse expectedResponse = ListTableSpecsResponse.newBuilder().setNextPageToken("").addAllTableSpecs(Arrays.asList(responsesElement)).build();
    mockAutoMl.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListTableSpecsPagedResponse pagedListResponse = client.listTableSpecs(parent);
    List<TableSpec> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTableSpecsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockAutoMl.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTableSpecsRequest actualRequest = ((ListTableSpecsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListTableSpecsPagedResponse(com.google.cloud.automl.v1beta1.AutoMlClient.ListTableSpecsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

ListTableSpecsPagedResponse (com.google.cloud.automl.v1beta1.AutoMlClient.ListTableSpecsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2