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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations