Search in sources :

Example 1 with ListAnnotatedDatasetsPagedResponse

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

the class DataLabelingServiceClientTest method listAnnotatedDatasetsTest2.

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

Example 2 with ListAnnotatedDatasetsPagedResponse

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

the class DataLabelingServiceClientTest method listAnnotatedDatasetsTest.

@Test
public void listAnnotatedDatasetsTest() throws Exception {
    AnnotatedDataset responsesElement = AnnotatedDataset.newBuilder().build();
    ListAnnotatedDatasetsResponse expectedResponse = ListAnnotatedDatasetsResponse.newBuilder().setNextPageToken("").addAllAnnotatedDatasets(Arrays.asList(responsesElement)).build();
    mockDataLabelingService.addResponse(expectedResponse);
    DatasetName parent = DatasetName.of("[PROJECT]", "[DATASET]");
    String filter = "filter-1274492040";
    ListAnnotatedDatasetsPagedResponse pagedListResponse = client.listAnnotatedDatasets(parent, filter);
    List<AnnotatedDataset> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getAnnotatedDatasetsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDataLabelingService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListAnnotatedDatasetsRequest actualRequest = ((ListAnnotatedDatasetsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(filter, actualRequest.getFilter());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListAnnotatedDatasetsPagedResponse(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListAnnotatedDatasetsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

ListAnnotatedDatasetsPagedResponse (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListAnnotatedDatasetsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2