Search in sources :

Example 1 with CANCELED

use of eu.ggnet.dwoss.redtape.ee.entity.Document.Condition.CANCELED in project dwoss by gg-net.

the class RedTapeCloserOperationIT method testDayClosing.

/**
 * Tests if something gets closed and if the appropriated stock units are gone.
 * <p>
 * @throws UserInfoException
 */
@Test
public void testDayClosing() throws UserInfoException {
    assertFalse(customerGenerator.makeCustomers(10).isEmpty());
    receiptCustomers = customerGenerator.makeReceiptCustomers(ACER);
    systemCustomers = customerGenerator.makeSpecialCustomers(BLOCK);
    assertFalse(systemCustomers == null);
    assertFalse(receiptCustomers == null);
    assertFalse(receiptGenerator.makeUniqueUnits(200, true, true).isEmpty());
    assertFalse(redTapeGenerator.makeSalesDossiers(30).isEmpty());
    // dossier ids from created blockers
    List<Long> blockerIds = buildBlocker().stream().mapToLong(d -> d.getId()).boxed().collect(Collectors.toList());
    assertThat(stockAgent.findAllEager(StockTransaction.class).stream().map(StockTransaction::getPositions).flatMap(Collection::stream).anyMatch(t -> t.getStockUnit() != null)).overridingErrorMessage("Their exist a StockTransaction, which is not complete (blocking a stockUnit), impossible!").isFalse();
    long stockUnits = stockAgent.count(StockUnit.class);
    assertThat(stockUnits).isPositive();
    List<LogicTransaction> allLts = stockAgent.findAllEager(LogicTransaction.class);
    assertThat(allLts.size()).overridingErrorMessage("No LogicTransactions exist, impossible!").isPositive();
    redTapeCloser.executeManual("Junit");
    List<Dossier> blockerDossiers = new ArrayList<>();
    for (Long blockerId : blockerIds) {
        blockerDossiers.add(redTapeAgent.findByIdEager(Dossier.class, blockerId));
    }
    assertEquals("More/Less Blockers than expected passed closing", 3, blockerDossiers.stream().filter(d -> d.isClosed()).collect(Collectors.toList()).size());
    warnIfStockSizeDidNotChange(stockUnits);
    List<Dossier> allDossiers = redTapeAgent.findAllEager(Dossier.class);
    for (Dossier dos : allDossiers) {
        if (dos.isClosed()) {
            for (Document doc : dos.getActiveDocuments()) {
                // These are just ignored.
                if (doc.containsAny(CANCELED))
                    continue;
                for (Integer uuId : doc.getPositionsUniqueUnitIds()) {
                    StockUnit su = stockAgent.findStockUnitByUniqueUnitIdEager(uuId);
                    assertNull("There is a StockUnit for a closed Dossier (doc.id= " + doc.getId() + "):\n" + dos.toMultiLine() + "\n\n" + su + "\n\n" + "Original LTS: " + allLts.stream().filter(x -> x.getUnits().contains(su)).findAny().orElse(null), su);
                }
            }
        } else {
            for (Integer uuId : dos.getRelevantUniqueUnitIds()) {
                StockUnit su = stockAgent.findStockUnitByUniqueUnitIdEager(uuId);
                assertNotNull("There is no StockUnit for an open Dossier\n" + dos, su);
            }
        }
    }
    long reportSize = reportAgent.count(ReportLine.class);
    assertFalse(reportSize == 0);
    redTapeCloser.executeManual("Junit");
    assertEquals("Second call should not add anything new", reportSize, reportAgent.count(ReportLine.class));
}
Also used : UnitPositionHook(eu.ggnet.dwoss.redtape.ee.api.UnitPositionHook) java.util(java.util) CustomerServiceBean(eu.ggnet.dwoss.customer.ee.CustomerServiceBean) Arquillian(org.jboss.arquillian.junit.Arquillian) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) CustomerGeneratorOperation(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGeneratorOperation) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) BLOCK(eu.ggnet.dwoss.rules.DocumentType.BLOCK) RedTapeWorker(eu.ggnet.dwoss.redtapext.ee.RedTapeWorker) eu.ggnet.dwoss.rules(eu.ggnet.dwoss.rules) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) RedTapeCloser(eu.ggnet.dwoss.redtapext.ee.reporting.RedTapeCloser) Inject(javax.inject.Inject) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) ProductEao(eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao) After(org.junit.After) Result(eu.ggnet.dwoss.util.interactiveresult.Result) RedTapeGeneratorOperation(eu.ggnet.dwoss.redtapext.ee.gen.RedTapeGeneratorOperation) EJB(javax.ejb.EJB) UniqueUnitFormater(eu.ggnet.dwoss.uniqueunit.ee.format.UniqueUnitFormater) PriceType(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType) CustomerMetaData(eu.ggnet.dwoss.customer.opi.CustomerMetaData) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Test(org.junit.Test) CANCELED(eu.ggnet.dwoss.redtape.ee.entity.Document.Condition.CANCELED) Collectors(java.util.stream.Collectors) eu.ggnet.dwoss.mandator.api.value(eu.ggnet.dwoss.mandator.api.value) eu.ggnet.dwoss.redtapext.op.itest.support(eu.ggnet.dwoss.redtapext.op.itest.support) REFURBISHED_ID(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit.Identifier.REFURBISHED_ID) ReportAgent(eu.ggnet.dwoss.report.ee.ReportAgent) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) PRODUCT_BATCH(eu.ggnet.dwoss.rules.PositionType.PRODUCT_BATCH) eu.ggnet.dwoss.redtape.ee.entity(eu.ggnet.dwoss.redtape.ee.entity) ACER(eu.ggnet.dwoss.rules.TradeName.ACER) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) Assert(org.junit.Assert) RedTapeAgent(eu.ggnet.dwoss.redtape.ee.RedTapeAgent) ReceiptGeneratorOperation(eu.ggnet.dwoss.receipt.ee.gen.ReceiptGeneratorOperation) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Test(org.junit.Test)

Aggregations

CustomerServiceBean (eu.ggnet.dwoss.customer.ee.CustomerServiceBean)1 CustomerGeneratorOperation (eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGeneratorOperation)1 CustomerMetaData (eu.ggnet.dwoss.customer.opi.CustomerMetaData)1 eu.ggnet.dwoss.mandator.api.value (eu.ggnet.dwoss.mandator.api.value)1 ReceiptGeneratorOperation (eu.ggnet.dwoss.receipt.ee.gen.ReceiptGeneratorOperation)1 RedTapeAgent (eu.ggnet.dwoss.redtape.ee.RedTapeAgent)1 UnitPositionHook (eu.ggnet.dwoss.redtape.ee.api.UnitPositionHook)1 eu.ggnet.dwoss.redtape.ee.entity (eu.ggnet.dwoss.redtape.ee.entity)1 CANCELED (eu.ggnet.dwoss.redtape.ee.entity.Document.Condition.CANCELED)1 RedTapeWorker (eu.ggnet.dwoss.redtapext.ee.RedTapeWorker)1 RedTapeGeneratorOperation (eu.ggnet.dwoss.redtapext.ee.gen.RedTapeGeneratorOperation)1 RedTapeCloser (eu.ggnet.dwoss.redtapext.ee.reporting.RedTapeCloser)1 eu.ggnet.dwoss.redtapext.op.itest.support (eu.ggnet.dwoss.redtapext.op.itest.support)1 ReportAgent (eu.ggnet.dwoss.report.ee.ReportAgent)1 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)1 eu.ggnet.dwoss.rules (eu.ggnet.dwoss.rules)1 BLOCK (eu.ggnet.dwoss.rules.DocumentType.BLOCK)1 PRODUCT_BATCH (eu.ggnet.dwoss.rules.PositionType.PRODUCT_BATCH)1 ACER (eu.ggnet.dwoss.rules.TradeName.ACER)1 StockAgent (eu.ggnet.dwoss.stock.ee.StockAgent)1