@Override public Iterable<Product> extractResources(ListProductsResponse payload) { return payload.getProductsList(); } };
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.vision.v1.ListProductsResponse)) { return super.equals(obj); } com.google.cloud.vision.v1.ListProductsResponse other = (com.google.cloud.vision.v1.ListProductsResponse) obj; boolean result = true; result = result && getProductsList().equals(other.getProductsList()); result = result && getNextPageToken().equals(other.getNextPageToken()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getProductsCount() > 0) { hash = (37 * hash) + PRODUCTS_FIELD_NUMBER; hash = (53 * hash) + getProductsList().hashCode(); } hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; hash = (53 * hash) + getNextPageToken().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@Test @SuppressWarnings("all") public void listProductsTest() { String nextPageToken = ""; Product productsElement = Product.newBuilder().build(); List<Product> products = Arrays.asList(productsElement); ListProductsResponse expectedResponse = ListProductsResponse.newBuilder() .setNextPageToken(nextPageToken) .addAllProducts(products) .build(); mockProductSearch.addResponse(expectedResponse); String formattedParent = ProductSearchClient.formatLocationName("[PROJECT]", "[LOCATION]"); ListProductsPagedResponse pagedListResponse = client.listProducts(formattedParent); List<Product> resources = Lists.newArrayList(pagedListResponse.iterateAll()); Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); List<GeneratedMessageV3> actualRequests = mockProductSearch.getRequests(); Assert.assertEquals(1, actualRequests.size()); ListProductsRequest actualRequest = (ListProductsRequest) actualRequests.get(0); Assert.assertEquals(formattedParent, actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Override public Iterable<Product> extractResources(ListProductsResponse payload) { return payload.getProductsList(); } };
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.vision.v1.ListProductsResponse)) { return super.equals(obj); } com.google.cloud.vision.v1.ListProductsResponse other = (com.google.cloud.vision.v1.ListProductsResponse) obj; boolean result = true; result = result && getProductsList().equals(other.getProductsList()); result = result && getNextPageToken().equals(other.getNextPageToken()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getProductsCount() > 0) { hash = (37 * hash) + PRODUCTS_FIELD_NUMBER; hash = (53 * hash) + getProductsList().hashCode(); } hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; hash = (53 * hash) + getNextPageToken().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }