Search in sources :

Example 31 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class ProductGenerator method generateProduct.

/**
 * Generate a specific amount of products with random data.
 *
 * @param amount of products that get created
 * @return list of Product
 */
public List<Product> generateProduct(int amount) {
    List<Product> products = new ArrayList<>();
    for (int i = 0; i < amount; i++) {
        Product p = new Product(productGroups.get(rand.nextInt(productGroups.size())), tradeNames.get(rand.nextInt(tradeNames.size())), "" + rand.nextInt(15000), names.get(rand.nextInt(names.size())));
        p.setImageId(rand.nextInt(15000));
        p.setGtin(rand.nextInt(15000));
        p.setEol(dates.get(rand.nextInt(dates.size())));
        p.setPrice(priceTypes.get(rand.nextInt(priceTypes.size())), rand.nextInt(9999), "");
        ucGen.generateUnitCollections().forEach((generateUnitCollection) -> {
            p.getUnitCollections().add(generateUnitCollection);
        });
        for (UnitCollection collection : p.getUnitCollections()) {
            for (UniqueUnit unit : collection.getUnits()) {
                unit.setProduct(p);
            }
        }
        for (int j = 0; j < 5; j++) {
            p.getUniqueUnits().add(uuGen.makeUniqueUnit(p.getTradeName(), p.getGroup()));
        }
        products.add(p);
    }
    return products;
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UnitCollection(eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product)

Example 32 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class ProductGenerator method generateProduct.

/**
 * Generate a specific amount of products with random data.
 *
 * @param amount of products that get created
 * @return list of Product
 */
public List<Product> generateProduct(int amount) {
    List<Product> products = new ArrayList<>();
    for (int i = 0; i < amount; i++) {
        Product p = new Product(productGroups.get(rand.nextInt(productGroups.size())), tradeNames.get(rand.nextInt(tradeNames.size())), "" + rand.nextInt(15000), names.get(rand.nextInt(names.size())));
        p.setImageId(rand.nextInt(15000));
        p.setGtin(rand.nextInt(15000));
        p.setEol(dates.get(rand.nextInt(dates.size())));
        p.setPrice(priceTypes.get(rand.nextInt(priceTypes.size())), rand.nextInt(9999), "");
        ucGen.generateUnitCollections().forEach((generateUnitCollection) -> {
            p.getUnitCollections().add(generateUnitCollection);
        });
        for (UnitCollection collection : p.getUnitCollections()) {
            for (UniqueUnit unit : collection.getUnits()) {
                unit.setProduct(p);
            }
        }
        for (int j = 0; j < 5; j++) {
            p.getUniqueUnits().add(uuGen.makeUniqueUnit(p.getTradeName(), p.getGroup()));
        }
        products.add(p);
    }
    return products;
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UnitCollection(eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product)

Example 33 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class RedTapeWorkerOperation method createSalesProduct.

/**
 * Creates a new SalesProduct for the PartNo.
 * <p/>
 * @param partNo the partNo to use.
 * @return the new SalesProduct.
 * @throws UserInfoException if the PartNo does not exist.
 */
@Override
public SalesProduct createSalesProduct(String partNo) throws UserInfoException {
    ProductEao productEao = new ProductEao(uuEm);
    Product findByPartNo = productEao.findByPartNo(partNo);
    if (findByPartNo == null)
        throw new UserInfoException("Part Nummer exestiert Nicht!");
    SalesProduct salesProduct = new SalesProduct(partNo, findByPartNo.getName(), findByPartNo.getPrice(PriceType.SALE), findByPartNo.getId(), findByPartNo.getDescription());
    redTapeEm.persist(salesProduct);
    return salesProduct;
}
Also used : Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ProductEao(eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao) UserInfoException(eu.ggnet.dwoss.util.UserInfoException)

Example 34 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class ReceiptProductLogicProductSpecIT method testCreateProductSpec.

@Test
public void testCreateProductSpec() throws Exception {
    final long GTIN = 123456782;
    // Create a CPU and GPU and persist it.
    Cpu cpu = productProcessor.create(new Cpu(Cpu.Series.AMD_V, "TestCPU", Cpu.Type.MOBILE, 2.0, 5));
    Gpu gpu = productProcessor.create(new Gpu(Gpu.Type.MOBILE, Gpu.Series.GEFORCE_100, "TestGPU"));
    // Persist Display
    Display display = new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE);
    ProductModel productModel = new ProductModel("M", new ProductFamily("F", new ProductSeries(ACER, NOTEBOOK, "S")));
    Notebook notebook = new Notebook();
    notebook.setDisplay(display);
    notebook.setGpu(gpu);
    notebook.setCpu(cpu);
    notebook.setMemory(2048);
    notebook.setOs(Desktop.Os.LINUX);
    notebook.add(Desktop.Hdd.SSD_0016);
    notebook.add(Desktop.Hdd.ROTATING_2000);
    notebook.add(Desktop.Odd.DVD_ROM);
    notebook.setExtras(ProductSpec.Extra.E_SATA, ProductSpec.Extra.HIGHT_CHANGEABLE);
    notebook.setPartNo("LX.ASDFG.GHJ");
    notebook.setModel(productModel);
    ProductSpec testSpec = productProcessor.create(notebook, productModel, 0);
    assertNotNull(testSpec);
    Notebook notebook2 = new Notebook();
    notebook2.setDisplay(display);
    notebook2.setGpu(gpu);
    notebook2.setCpu(cpu);
    notebook2.setMemory(2048);
    notebook2.setOs(Desktop.Os.LINUX);
    notebook2.add(Desktop.Hdd.SSD_0016);
    notebook2.add(Desktop.Hdd.ROTATING_2000);
    notebook2.add(Desktop.Odd.DVD_ROM);
    notebook2.setExtras(ProductSpec.Extra.E_SATA, ProductSpec.Extra.HIGHT_CHANGEABLE);
    notebook2.setPartNo("LX.ASDFG.GH2");
    notebook2.setModel(productModel);
    ProductSpec testSpec2 = productProcessor.create(notebook2, productModel, GTIN);
    assertNotNull(testSpec2);
    assertNotSame(testSpec2, testSpec);
    Product product = uuAgent.findById(Product.class, testSpec2.getProductId());
    assertThat(product).isNotNull().returns(GTIN, Product::getGtin);
}
Also used : ProductFamily(eu.ggnet.dwoss.spec.ee.entity.ProductFamily) Notebook(eu.ggnet.dwoss.spec.ee.entity.Notebook) Cpu(eu.ggnet.dwoss.spec.ee.entity.piece.Cpu) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) Gpu(eu.ggnet.dwoss.spec.ee.entity.piece.Gpu) ProductModel(eu.ggnet.dwoss.spec.ee.entity.ProductModel) Display(eu.ggnet.dwoss.spec.ee.entity.piece.Display) Test(org.junit.Test)

Example 35 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class ReceiptUnitOperationIT method testReceiptAndUpdate.

@Test
public void testReceiptAndUpdate() throws InterruptedException {
    customerGenerator.makeSystemCustomers(contractors.all().toArray(new TradeName[0]));
    // Constants ,later permutate throug all
    Stock stock = stockGenerator.makeStocksAndLocations(2).get(0);
    List<ReceiptOperation> operations = Arrays.asList(SALEABLE, INTERNAL_REWORK, MISSING_PARTS, REPAIR);
    // Receipt a Unit
    ProductSpec productSpec = receiptGenerator.makeProductSpec();
    Product product = uniqueUnitAgent.findById(Product.class, productSpec.getProductId());
    StockTransaction stockTransaction = stockTransactionEmo.requestRollInPrepared(stock.getId(), "No User", "Rollin via ReceiptUnitOperationHelper.findOrCreateRollInTransaction");
    for (TradeName contractor : contractors.all()) {
        Shipment productShipment = stockAgent.persist(new Shipment("SHIPMENTNAME_" + contractor, contractor, TradeName.ACER, Shipment.Status.OPENED));
        for (ReceiptOperation receiptOperation : operations) {
            UniqueUnit receiptUnit = unitGenerator.makeUniqueUnit(contractor, product);
            unitProcessor.receipt(receiptUnit, product, productShipment, stockTransaction, receiptOperation, "Receipt Operation from Test", "Testuser");
            asserts(receiptUnit, stockTransaction, receiptOperation, contractor);
            for (ReceiptOperation updateOperation : operations) {
                UniqueUnit uniqueUnit = uniqueUnitAgent.findUnitByIdentifierEager(Identifier.REFURBISHED_ID, receiptUnit.getIdentifier(Identifier.REFURBISHED_ID));
                unitProcessor.update(uniqueUnit, product, updateOperation, "Update Operation from Test", "Testuser");
                assertsUpdate(receiptUnit, stockTransaction, updateOperation, contractor);
            }
        }
    }
    Thread.sleep(3000);
}
Also used : ReceiptOperation(eu.ggnet.dwoss.rules.ReceiptOperation) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) Shipment(eu.ggnet.dwoss.stock.ee.entity.Shipment) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Test(org.junit.Test)

Aggregations

Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)50 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)29 Test (org.junit.Test)16 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)13 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)11 ProductEao (eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao)11 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)9 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)8 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)5 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)5 PriceType (eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType)5 java.util (java.util)5 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)4 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)4 CategoryProduct (eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct)4 UnitCollection (eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection)4 JExcelLucidCalcReader (eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcReader)4 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)3 TradeName (eu.ggnet.dwoss.rules.TradeName)3 CustomerMetaData (eu.ggnet.dwoss.customer.opi.CustomerMetaData)2