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