use of com.google.cloud.retail.v2.Product 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.retail.v2.Product 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.Product in project java-retail by googleapis.
the class ProductServiceClientTest method listProductsTest2.
@Test
public void listProductsTest2() throws Exception {
Product responsesElement = Product.newBuilder().build();
ListProductsResponse expectedResponse = ListProductsResponse.newBuilder().setNextPageToken("").addAllProducts(Arrays.asList(responsesElement)).build();
mockProductService.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 = mockProductService.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.retail.v2.Product in project java-retail by googleapis.
the class CreateProduct method main.
public static void main(String[] args) throws IOException {
// TODO(developer): Replace these variables before running the sample.
String projectId = ServiceOptions.getDefaultProjectId();
String branchName = String.format("projects/%s/locations/global/catalogs/default_catalog/branches/0", projectId);
String generatedProductId = UUID.randomUUID().toString();
Product createdProduct = createProduct(generatedProductId, branchName);
deleteProduct(createdProduct.getName());
}
use of com.google.cloud.retail.v2.Product in project java-retail by googleapis.
the class CreateProduct method generateProduct.
// generate product for create
public static Product generateProduct() {
float price = 30.0f;
float originalPrice = 35.5f;
PriceInfo priceInfo = PriceInfo.newBuilder().setPrice(price).setOriginalPrice(originalPrice).setCurrencyCode("USD").build();
return Product.newBuilder().setTitle("Nest Mini").setType(Type.PRIMARY).addCategories("Speakers and displays").addBrands("Google").setPriceInfo(priceInfo).setAvailability(Availability.IN_STOCK).build();
}
Aggregations