use of com.google.cloud.vision.v1.ListProductsInProductSetRequest in project java-vision by googleapis.
the class ITSystemTest method listProductsInProductSetTest.
@Test
public void listProductsInProductSetTest() {
ListProductsInProductSetRequest request = ListProductsInProductSetRequest.newBuilder().setName(formatProductSetName).build();
for (Product actualProduct : productSearchClient.listProductsInProductSet(request).iterateAll()) {
assertEquals(product.getName(), actualProduct.getName());
assertEquals(PRODUCT_DISPLAY_NAME, actualProduct.getDisplayName());
assertEquals(PRODUCT_CATEGORY, actualProduct.getProductCategory());
}
}
use of com.google.cloud.vision.v1.ListProductsInProductSetRequest in project java-vision by googleapis.
the class ProductSearchClientTest method listProductsInProductSetTest.
@Test
public void listProductsInProductSetTest() throws Exception {
Product responsesElement = Product.newBuilder().build();
ListProductsInProductSetResponse expectedResponse = ListProductsInProductSetResponse.newBuilder().setNextPageToken("").addAllProducts(Arrays.asList(responsesElement)).build();
mockProductSearch.addResponse(expectedResponse);
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ListProductsInProductSetPagedResponse pagedListResponse = client.listProductsInProductSet(name);
List<Product> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockProductSearch.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListProductsInProductSetRequest actualRequest = ((ListProductsInProductSetRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.vision.v1.ListProductsInProductSetRequest in project java-vision by googleapis.
the class ProductSearchClientTest method listProductsInProductSetTest2.
@Test
public void listProductsInProductSetTest2() throws Exception {
Product responsesElement = Product.newBuilder().build();
ListProductsInProductSetResponse expectedResponse = ListProductsInProductSetResponse.newBuilder().setNextPageToken("").addAllProducts(Arrays.asList(responsesElement)).build();
mockProductSearch.addResponse(expectedResponse);
String name = "name3373707";
ListProductsInProductSetPagedResponse pagedListResponse = client.listProductsInProductSet(name);
List<Product> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockProductSearch.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListProductsInProductSetRequest actualRequest = ((ListProductsInProductSetRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations