Search in sources :

Example 1 with ReceiptOperation

use of eu.ggnet.dwoss.rules.ReceiptOperation 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

ReceiptOperation (eu.ggnet.dwoss.rules.ReceiptOperation)1 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)1 Shipment (eu.ggnet.dwoss.stock.ee.entity.Shipment)1 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)1 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)1 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)1 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)1 Test (org.junit.Test)1