Search in sources :

Example 36 with Product

use of com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.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 37 with Product

use of com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.Product in project AN15 by IharDubkou.

the class Main method main.

public static void main(String[] args) {
    Category category1 = new Category();
    Category category2 = new Category();
    Category category3 = new Category();
    Product product1 = new Product("Гречка", 1, 47);
    Product product2 = new Product("Нут", 2, 65);
    Product product3 = new Product("Пшено", 1.5, 21);
    Product[] products1 = new Product[3];
    products1[0] = product1;
    products1[1] = product2;
    products1[2] = product3;
    category1.setName("Крупы");
    category1.setProducts(products1);
    Product product4 = new Product("Молоко", 2, 14);
    Product product5 = new Product("Кефир", 1.8, 28);
    Product product6 = new Product("Сметана", 1.4, 11);
    Product[] products2 = new Product[3];
    products2[0] = product4;
    products2[1] = product5;
    products2[2] = product6;
    category2.setName("Молочка");
    category2.setProducts(products2);
    Product product7 = new Product("Пирожок с мясом", 2.5, 78);
    Product product8 = new Product("Булочка с маком", 1.3, 92);
    Product product9 = new Product("Сметанник", 1.45, 88);
    Product[] products3 = new Product[3];
    products3[0] = product4;
    products3[1] = product5;
    products3[2] = product6;
    category3.setName("Булки");
    category3.setProducts(products3);
    Product[] products = new Product[3];
    products[0] = product7;
    products[1] = product4;
    products[2] = product1;
    Basket basket = new Basket();
    basket.setProducts(products);
    User user = new User("NEMO", 1234, basket);
    AuthenticationService authenticationService = new UserAuthenticationServiceImpl();
    CategoryService categoryService = new CategoryServiceImpl();
    // authenticationService.doLoginAndPassword(user);
    categoryService.printCatalog(category1);
    categoryService.printDefiniteCatalog(category1);
    categoryService.selectInBasket(1, basket, category1);
    categoryService.byInBasket(user, product5);
}
Also used : UserAuthenticationServiceImpl(com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.service.Impl.UserAuthenticationServiceImpl) CategoryService(com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.service.CategoryService) AuthenticationService(com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.service.AuthenticationService) CategoryServiceImpl(com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.service.Impl.CategoryServiceImpl)

Example 38 with Product

use of com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.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 39 with Product

use of com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.Product in project AN15 by IharDubkou.

the class SvCatalogServiceImpl method addProductInBasket.

@Override
public void addProductInBasket(SvUser user, SvProduct product) {
    System.out.println("\nКорзина покупателя");
    SvBasket basket = user.getUserBasket();
    basket.addToBasket(product);
    user.setUserBasket(basket);
    System.out.println("В корзине теперь");
    for (SvProduct p : user.getUserBasket().getProductList()) {
        System.out.println(p);
    }
}
Also used : SvBasket(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvBasket) SvProduct(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct)

Example 40 with Product

use of com.teachMeSkills.an15.MatveevArtyom.hw6.Inheritance.task3.Product in project AN15 by IharDubkou.

the class SvCatalogServiceImpl method buyProduct.

@Override
public void buyProduct(SvUser user, SvProduct product) {
    System.out.println("\nКорзина покупок");
    for (SvProduct p : user.getUserBasket().getProductList()) {
        System.out.println(p);
    }
    System.out.println("Вы хотите купить");
    System.out.println(product);
    if (user.getUserBasket().productList.contains(product)) {
        System.out.println("Такой товар есть");
        user.getUserBasket().removeFromBasket(product);
    } else {
        System.out.println("Такого нет и что-то там делаем дальше");
    }
    System.out.println("\nКорзина покупок теперь");
    for (SvProduct p : user.getUserBasket().getProductList()) {
        System.out.println(p);
    }
}
Also used : SvProduct(com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct)

Aggregations

Product (com.google.cloud.retail.v2.Product)20 Product (com.google.cloud.vision.v1.Product)10 SetupCleanup.deleteProduct (setup.SetupCleanup.deleteProduct)9 ProductServiceClient (com.google.cloud.retail.v2.ProductServiceClient)8 SetupCleanup.createProduct (setup.SetupCleanup.createProduct)6 ProductSearchClient (com.google.cloud.vision.v1.ProductSearchClient)5 Product (com.haulmont.cuba.testmodel.sales_1.Product)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Test (org.junit.Test)4 Test (org.junit.jupiter.api.Test)4 NotFoundException (com.google.api.gax.rpc.NotFoundException)3 CreateProductRequest (com.google.cloud.retail.v2.CreateProductRequest)3 GetProductRequest (com.google.cloud.retail.v2.GetProductRequest)3 QueryRunner (com.haulmont.bali.db.QueryRunner)3 Id (com.haulmont.cuba.core.entity.contracts.Id)3 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)3 TestContainer (com.haulmont.cuba.testsupport.TestContainer)3 SvProduct (com.teachMeSkills.an15.VorobyovSergey.hwSix.Task3.models.SvProduct)3 PrintStream (java.io.PrintStream)3 Before (org.junit.Before)3