Search in sources :

Example 1 with ListReferenceImagesRequest

use of com.google.cloud.vision.v1.ListReferenceImagesRequest in project java-vision by googleapis.

the class ProductSearchClientTest method listReferenceImagesTest.

@Test
public void listReferenceImagesTest() throws Exception {
    ReferenceImage responsesElement = ReferenceImage.newBuilder().build();
    ListReferenceImagesResponse expectedResponse = ListReferenceImagesResponse.newBuilder().setNextPageToken("").addAllReferenceImages(Arrays.asList(responsesElement)).build();
    mockProductSearch.addResponse(expectedResponse);
    ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
    ListReferenceImagesPagedResponse pagedListResponse = client.listReferenceImages(parent);
    List<ReferenceImage> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getReferenceImagesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockProductSearch.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListReferenceImagesRequest actualRequest = ((ListReferenceImagesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListReferenceImagesPagedResponse(com.google.cloud.vision.v1.ProductSearchClient.ListReferenceImagesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 2 with ListReferenceImagesRequest

use of com.google.cloud.vision.v1.ListReferenceImagesRequest in project java-vision by googleapis.

the class ITSystemTest method listReferenceImagesTest.

@Test
public void listReferenceImagesTest() {
    ListReferenceImagesRequest request = ListReferenceImagesRequest.newBuilder().setParent(formatProductName).build();
    for (ReferenceImage actualReferenceImage : productSearchClient.listReferenceImages(request).iterateAll()) {
        assertEquals(referenceImage.getName(), actualReferenceImage.getName());
        assertEquals(referenceImage.getUri(), actualReferenceImage.getUri());
    }
}
Also used : ListReferenceImagesRequest(com.google.cloud.vision.v1.ListReferenceImagesRequest) ReferenceImage(com.google.cloud.vision.v1.ReferenceImage) Test(org.junit.Test)

Example 3 with ListReferenceImagesRequest

use of com.google.cloud.vision.v1.ListReferenceImagesRequest in project java-vision by googleapis.

the class ProductSearchClientTest method listReferenceImagesTest2.

@Test
public void listReferenceImagesTest2() throws Exception {
    ReferenceImage responsesElement = ReferenceImage.newBuilder().build();
    ListReferenceImagesResponse expectedResponse = ListReferenceImagesResponse.newBuilder().setNextPageToken("").addAllReferenceImages(Arrays.asList(responsesElement)).build();
    mockProductSearch.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListReferenceImagesPagedResponse pagedListResponse = client.listReferenceImages(parent);
    List<ReferenceImage> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getReferenceImagesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockProductSearch.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListReferenceImagesRequest actualRequest = ((ListReferenceImagesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListReferenceImagesPagedResponse(com.google.cloud.vision.v1.ProductSearchClient.ListReferenceImagesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 ListReferenceImagesPagedResponse (com.google.cloud.vision.v1.ProductSearchClient.ListReferenceImagesPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 ListReferenceImagesRequest (com.google.cloud.vision.v1.ListReferenceImagesRequest)1 ReferenceImage (com.google.cloud.vision.v1.ReferenceImage)1