Search in sources :

Example 51 with Product

use of com.google.cloud.retail.v2.Product in project java-retail by googleapis.

the class SetupCleanup method generateProduct.

public static Product generateProduct() {
    float price = 30.0f;
    float originalPrice = 35.5f;
    PriceInfo priceInfo = PriceInfo.newBuilder().setPrice(price).setOriginalPrice(originalPrice).setCurrencyCode("USD").build();
    FulfillmentInfo fulfillmentInfo = FulfillmentInfo.newBuilder().setType("pickup-in-store").addAllPlaceIds(Arrays.asList("store0", "store1")).build();
    return Product.newBuilder().setTitle("Nest Mini").setType(Type.PRIMARY).addCategories("Speakers and displays").addBrands("Google").setPriceInfo(priceInfo).setAvailability(Availability.IN_STOCK).addFulfillmentInfo(fulfillmentInfo).build();
}
Also used : FulfillmentInfo(com.google.cloud.retail.v2.FulfillmentInfo) PriceInfo(com.google.cloud.retail.v2.PriceInfo)

Example 52 with Product

use of com.google.cloud.retail.v2.Product in project java-retail by googleapis.

the class UpdateProductTest method setUp.

@Before
public void setUp() throws IOException, InterruptedException, ExecutionException {
    String projectId = ServiceOptions.getDefaultProjectId();
    String branchName = String.format("projects/%s/locations/global/catalogs/default_catalog/branches/0", projectId);
    String generatedProductId = UUID.randomUUID().toString();
    bout = new ByteArrayOutputStream();
    PrintStream out = new PrintStream(bout);
    originalPrintStream = System.out;
    System.setOut(out);
    Product createdProduct = createProduct(generatedProductId);
    updateProduct(createdProduct, branchName);
    deleteProduct(createdProduct.getName());
}
Also used : PrintStream(java.io.PrintStream) SetupCleanup.createProduct(setup.SetupCleanup.createProduct) UpdateProduct.updateProduct(product.UpdateProduct.updateProduct) SetupCleanup.deleteProduct(setup.SetupCleanup.deleteProduct) Product(com.google.cloud.retail.v2.Product) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

Example 53 with Product

use of com.google.cloud.retail.v2.Product in project AN15 by IharDubkou.

the class CategoryServiceImpl method byInBasket.

@Override
public void byInBasket(User user, Product product) {
    System.out.println("Вы хотите купить");
    System.out.println(product);
    System.out.println("\nКорзина покупок теперь");
    for (Product product1 : user.getBasket().getProducts()) {
        System.out.println(product1);
    }
}
Also used : SvProduct(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct) Product(com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.Product)

Example 54 with Product

use of com.google.cloud.retail.v2.Product in project java-vision by googleapis.

the class ITSystemTest method setUp.

@BeforeClass
public static void setUp() throws IOException {
    imageAnnotatorClient = ImageAnnotatorClient.create();
    /* create product */
    productSearchClient = ProductSearchClient.create();
    Product createProduct = Product.newBuilder().setName(PRODUCT_ID).setDisplayName(PRODUCT_DISPLAY_NAME).setProductCategory(PRODUCT_CATEGORY).build();
    CreateProductRequest productRequest = CreateProductRequest.newBuilder().setParent(LOCATION_NAME).setProduct(createProduct).build();
    product = productSearchClient.createProduct(productRequest);
    productName = getName(product.getName());
    formatProductName = ProductName.of(PROJECT_ID, COMPUTE_REGION, productName).toString();
    /* create product set */
    ProductSet createProductSet = ProductSet.newBuilder().setDisplayName(PRODUCT_SET_DISPLAY_NAME).build();
    CreateProductSetRequest productSetRequest = CreateProductSetRequest.newBuilder().setParent(LOCATION_NAME).setProductSet(createProductSet).setProductSetId(PRODUCT_SET_ID).build();
    productSet = productSearchClient.createProductSet(productSetRequest);
    productSetName = getName(productSet.getName());
    formatProductSetName = ProductSetName.of(PROJECT_ID, COMPUTE_REGION, productSetName).toString();
    /* add product to product set */
    AddProductToProductSetRequest productToProductSetRequest = AddProductToProductSetRequest.newBuilder().setName(formatProductSetName).setProduct(formatProductName).build();
    productSearchClient.addProductToProductSet(productToProductSetRequest);
    /* create reference image */
    ReferenceImage createReferenceImage = ReferenceImage.newBuilder().setUri(SAMPLE_BUCKET + "product_search/shoes_1.jpg").build();
    CreateReferenceImageRequest imageRequest = CreateReferenceImageRequest.newBuilder().setParent(formatProductName).setReferenceImage(createReferenceImage).build();
    referenceImage = productSearchClient.createReferenceImage(imageRequest);
    referenceImageName = getName(referenceImage.getName());
    formatReferenceImageName = ReferenceImageName.of(PROJECT_ID, COMPUTE_REGION, productName, referenceImageName).toString();
}
Also used : CreateProductRequest(com.google.cloud.vision.v1.CreateProductRequest) CreateReferenceImageRequest(com.google.cloud.vision.v1.CreateReferenceImageRequest) Product(com.google.cloud.vision.v1.Product) CreateProductSetRequest(com.google.cloud.vision.v1.CreateProductSetRequest) ProductSet(com.google.cloud.vision.v1.ProductSet) ReferenceImage(com.google.cloud.vision.v1.ReferenceImage) AddProductToProductSetRequest(com.google.cloud.vision.v1.AddProductToProductSetRequest) BeforeClass(org.junit.BeforeClass)

Example 55 with Product

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

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