use of com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsPagedResponse in project java-vision by googleapis.
the class ProductSearchClientTest method listProductsTest2.
@Test
public void listProductsTest2() throws Exception {
Product responsesElement = Product.newBuilder().build();
ListProductsResponse expectedResponse = ListProductsResponse.newBuilder().setNextPageToken("").addAllProducts(Arrays.asList(responsesElement)).build();
mockProductSearch.addResponse(expectedResponse);
String parent = "parent-995424086";
ListProductsPagedResponse pagedListResponse = client.listProducts(parent);
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());
ListProductsRequest actualRequest = ((ListProductsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsPagedResponse in project java-vision by googleapis.
the class ProductSearchClientTest method listProductsTest2.
@Test
public void listProductsTest2() throws Exception {
Product responsesElement = Product.newBuilder().build();
ListProductsResponse expectedResponse = ListProductsResponse.newBuilder().setNextPageToken("").addAllProducts(Arrays.asList(responsesElement)).build();
mockProductSearch.addResponse(expectedResponse);
String parent = "parent-995424086";
ListProductsPagedResponse pagedListResponse = client.listProducts(parent);
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());
ListProductsRequest actualRequest = ((ListProductsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsPagedResponse in project java-vision by googleapis.
the class ProductSearchClientTest method listProductsTest.
@Test
public void listProductsTest() throws Exception {
Product responsesElement = Product.newBuilder().build();
ListProductsResponse expectedResponse = ListProductsResponse.newBuilder().setNextPageToken("").addAllProducts(Arrays.asList(responsesElement)).build();
mockProductSearch.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListProductsPagedResponse pagedListResponse = client.listProducts(parent);
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());
ListProductsRequest actualRequest = ((ListProductsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsPagedResponse in project java-vision by googleapis.
the class ProductSearchClientTest method listProductsTest2.
@Test
public void listProductsTest2() throws Exception {
Product responsesElement = Product.newBuilder().build();
ListProductsResponse expectedResponse = ListProductsResponse.newBuilder().setNextPageToken("").addAllProducts(Arrays.asList(responsesElement)).build();
mockProductSearch.addResponse(expectedResponse);
String parent = "parent-995424086";
ListProductsPagedResponse pagedListResponse = client.listProducts(parent);
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());
ListProductsRequest actualRequest = ((ListProductsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsPagedResponse in project java-vision by googleapis.
the class ProductSearchClientTest method listProductsTest.
@Test
public void listProductsTest() throws Exception {
Product responsesElement = Product.newBuilder().build();
ListProductsResponse expectedResponse = ListProductsResponse.newBuilder().setNextPageToken("").addAllProducts(Arrays.asList(responsesElement)).build();
mockProductSearch.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListProductsPagedResponse pagedListResponse = client.listProducts(parent);
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());
ListProductsRequest actualRequest = ((ListProductsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations