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