use of com.google.cloud.retail.v2.GetProductRequest in project java-vision by googleapis.
the class ITSystemTest method getProductTest.
@Test
public void getProductTest() {
GetProductRequest request = GetProductRequest.newBuilder().setName(formatProductName).build();
Product actualProduct = productSearchClient.getProduct(request);
assertEquals(product.getName(), actualProduct.getName());
assertEquals(PRODUCT_DISPLAY_NAME, actualProduct.getDisplayName());
assertEquals(PRODUCT_CATEGORY, actualProduct.getProductCategory());
}
use of com.google.cloud.retail.v2.GetProductRequest in project java-retail by googleapis.
the class SetupCleanup method getProduct.
public static Product getProduct(String productName) throws IOException {
Product product = Product.newBuilder().build();
GetProductRequest getProductRequest = GetProductRequest.newBuilder().setName(productName).build();
try (ProductServiceClient serviceClient = ProductServiceClient.create()) {
product = serviceClient.getProduct(getProductRequest);
System.out.println("Get product response: " + product);
return product;
} catch (NotFoundException e) {
System.out.printf("Product %s not found", productName);
return product;
}
}
use of com.google.cloud.retail.v2.GetProductRequest in project java-retail by googleapis.
the class CrudProduct method getProduct.
// get product
public static Product getProduct(String productName) throws IOException {
Product product = Product.newBuilder().build();
GetProductRequest getProductRequest = GetProductRequest.newBuilder().setName(productName).build();
try (ProductServiceClient serviceClient = ProductServiceClient.create()) {
product = serviceClient.getProduct(getProductRequest);
System.out.println("Get product response: " + product);
return product;
} catch (NotFoundException e) {
System.out.printf("Product %s not found", productName);
return product;
}
}
use of com.google.cloud.retail.v2.GetProductRequest in project java-retail by googleapis.
the class GetProduct method getProduct.
// call the Retail API to get product
public static Product getProduct(String productName) throws IOException {
Product product = Product.newBuilder().build();
GetProductRequest getProductRequest = GetProductRequest.newBuilder().setName(productName).build();
try {
product = ProductServiceClient.create().getProduct(getProductRequest);
System.out.println("Get product response: " + product);
return product;
} catch (NotFoundException e) {
System.out.printf("Product %s not found", productName);
return product;
}
}
Aggregations