use of com.google.cloud.vision.v1.UpdateProductRequest in project java-retail by googleapis.
the class CrudProduct method updateProduct.
// update product
public static void updateProduct(Product originalProduct, String productName) throws IOException {
UpdateProductRequest updateProductRequest = UpdateProductRequest.newBuilder().setProduct(generateProductForUpdate(originalProduct.getId(), productName)).setAllowMissing(true).build();
System.out.printf("Update product request: %s%n", updateProductRequest);
try (ProductServiceClient serviceClient = ProductServiceClient.create()) {
Product updatedProduct = serviceClient.updateProduct(updateProductRequest);
System.out.printf("Updated product: %s%n", updatedProduct);
}
}
use of com.google.cloud.vision.v1.UpdateProductRequest in project java-retail by googleapis.
the class UpdateProduct method getUpdateProductRequest.
// get update product request
public static UpdateProductRequest getUpdateProductRequest(Product productToUpdate) {
UpdateProductRequest updateProductRequest = UpdateProductRequest.newBuilder().setProduct(productToUpdate).setAllowMissing(true).build();
System.out.printf("Update product request: %s%n", updateProductRequest);
return updateProductRequest;
}
use of com.google.cloud.vision.v1.UpdateProductRequest in project java-vision by googleapis.
the class ITSystemTest method updateProductTest.
@Test
public void updateProductTest() {
Product updateProduct = product.toBuilder().addProductLabels(KEY_VALUE).build();
UpdateProductRequest request = UpdateProductRequest.newBuilder().setProduct(updateProduct).build();
Product actualProduct = productSearchClient.updateProduct(request);
assertEquals(product.getName(), actualProduct.getName());
assertEquals(PRODUCT_DISPLAY_NAME, actualProduct.getDisplayName());
assertEquals(PRODUCT_CATEGORY, actualProduct.getProductCategory());
assertEquals(ImmutableList.of(KEY_VALUE), actualProduct.getProductLabelsList());
assertEquals(1, actualProduct.getProductLabelsCount());
}
Aggregations