Search in sources :

Example 11 with Product

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());
    }
}
Also used : ListProductsInProductSetRequest(com.google.cloud.vision.v1.ListProductsInProductSetRequest) Product(com.google.cloud.vision.v1.Product) Test(org.junit.Test)

Example 12 with Product

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());
}
Also used : GetProductRequest(com.google.cloud.vision.v1.GetProductRequest) Product(com.google.cloud.vision.v1.Product) Test(org.junit.Test)

Example 13 with Product

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListProductsPagedResponse(com.google.cloud.retail.v2.ProductServiceClient.ListProductsPagedResponse) Test(org.junit.Test)

Example 14 with Product

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());
}
Also used : SetupCleanup.deleteProduct(setup.SetupCleanup.deleteProduct) Product(com.google.cloud.retail.v2.Product)

Example 15 with Product

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();
}
Also used : PriceInfo(com.google.cloud.retail.v2.PriceInfo)

Aggregations

Product (com.google.cloud.retail.v2.Product)20 ProductServiceClient (com.google.cloud.retail.v2.ProductServiceClient)12 Product (com.google.cloud.vision.v1.Product)10 SetupCleanup.deleteProduct (setup.SetupCleanup.deleteProduct)9 PriceInfo (com.google.cloud.retail.v2.PriceInfo)7 Test (org.junit.Test)6 SetupCleanup.createProduct (setup.SetupCleanup.createProduct)6 DeleteProductRequest (com.google.cloud.retail.v2.DeleteProductRequest)5 ImportProductsRequest (com.google.cloud.retail.v2.ImportProductsRequest)5 ProductSearchClient (com.google.cloud.vision.v1.ProductSearchClient)5 Product (com.haulmont.cuba.testmodel.sales_1.Product)5 ListProductsPagedResponse (com.google.cloud.retail.v2.ProductServiceClient.ListProductsPagedResponse)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 PrintStream (java.io.PrintStream)4 Before (org.junit.Before)4 Test (org.junit.jupiter.api.Test)4 NotFoundException (com.google.api.gax.rpc.NotFoundException)3 CreateProductRequest (com.google.cloud.retail.v2.CreateProductRequest)3 FulfillmentInfo (com.google.cloud.retail.v2.FulfillmentInfo)3 GetProductRequest (com.google.cloud.retail.v2.GetProductRequest)3