Search in sources :

Example 11 with ListDatasetsRequest

use of com.google.cloud.datalabeling.v1beta1.ListDatasetsRequest in project java-datalabeling by googleapis.

the class DataLabelingServiceClientTest method listDatasetsTest2.

@Test
public void listDatasetsTest2() throws Exception {
    Dataset responsesElement = Dataset.newBuilder().build();
    ListDatasetsResponse expectedResponse = ListDatasetsResponse.newBuilder().setNextPageToken("").addAllDatasets(Arrays.asList(responsesElement)).build();
    mockDataLabelingService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    String filter = "filter-1274492040";
    ListDatasetsPagedResponse pagedListResponse = client.listDatasets(parent, filter);
    List<Dataset> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getDatasetsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDataLabelingService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListDatasetsRequest actualRequest = ((ListDatasetsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(filter, actualRequest.getFilter());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListDatasetsPagedResponse(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListDatasetsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

ListDatasetsPagedResponse (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListDatasetsPagedResponse)8 DataLabelingServiceClient (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient)6 Dataset (com.google.cloud.datalabeling.v1beta1.Dataset)6 ListDatasetsRequest (com.google.cloud.datalabeling.v1beta1.ListDatasetsRequest)6 ProjectName (com.google.cloud.datalabeling.v1beta1.ProjectName)6 IOException (java.io.IOException)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 PrintStream (java.io.PrintStream)4 Before (org.junit.Before)4 AnnotationSpecSet (com.google.cloud.datalabeling.v1beta1.AnnotationSpecSet)3 ListAnnotationSpecSetsPagedResponse (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListAnnotationSpecSetsPagedResponse)3 ListInstructionsPagedResponse (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListInstructionsPagedResponse)3 Instruction (com.google.cloud.datalabeling.v1beta1.Instruction)3 ListAnnotationSpecSetsRequest (com.google.cloud.datalabeling.v1beta1.ListAnnotationSpecSetsRequest)3 ListInstructionsRequest (com.google.cloud.datalabeling.v1beta1.ListInstructionsRequest)3 AutoMlClient (com.google.cloud.automl.v1beta1.AutoMlClient)2 Dataset (com.google.cloud.automl.v1beta1.Dataset)2 ListDatasetsRequest (com.google.cloud.automl.v1beta1.ListDatasetsRequest)2 LocationName (com.google.cloud.automl.v1beta1.LocationName)2 GcsSource (com.google.cloud.datalabeling.v1beta1.GcsSource)2