use of edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture in project cu-kfs by CU-CommunityApps.
the class ConcurStandardAccountingExtractCollectorBatchBuilderTest method assertReportStatisticHasCorrectTotals.
protected void assertReportStatisticHasCorrectTotals(List<ConcurSAEDetailLineFixture> lineFixtures, Predicate<ConcurSAEDetailLineFixture> fixtureFilter, ConcurBatchReportSummaryItem actualSummary) throws Exception {
ConcurSAEDetailLineFixture[] filteredItems = lineFixtures.stream().filter(fixtureFilter).toArray(ConcurSAEDetailLineFixture[]::new);
KualiDecimal expectedAmount = Arrays.stream(filteredItems).mapToDouble(ConcurSAEDetailLineFixture::getJournalAmount).mapToObj(KualiDecimal::new).reduce(KualiDecimal.ZERO, KualiDecimal::add);
assertEquals("Wrong record count for statistic", filteredItems.length, actualSummary.getRecordCount());
assertEquals("Wrong dollar amount for statistic", expectedAmount, actualSummary.getDollarAmount());
}
use of edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture in project cu-kfs by CU-CommunityApps.
the class ConcurStandardAccountingExtractCollectorBatchBuilderTest method assertCollectorBatchIsBuiltProperly.
protected void assertCollectorBatchIsBuiltProperly(ConcurCollectorBatchFixture expectedFixture, ConcurSAEFileFixture fixtureToBuildFrom) throws Exception {
CollectorBatch expected = expectedFixture.toCollectorBatch();
List<ConcurSAEDetailLineFixture> lineFixtures = ConcurFixtureUtils.getFixturesContainingParentFixture(ConcurSAEDetailLineFixture.class, fixtureToBuildFrom, ConcurSAEDetailLineFixture::getExtractFile);
ConcurStandardAccountingExtractFile saeFileContents = fixtureToBuildFrom.toExtractFile();
ConcurStandardAccountingExtractBatchReportData reportData = new ConcurStandardAccountingExtractBatchReportData();
CollectorBatch actual = builder.buildCollectorBatchFromStandardAccountingExtract(1, saeFileContents, reportData);
assertNotNull("The SAE file contents should have been converted to a CollectorBatch successfully", actual);
assertCollectorBatchHasCorrectData(expected, actual);
assertReportHasCorrectErrorLinesAndOrdering(lineFixtures, reportData);
assertReportHasCorrectPendingClientLinesAndOrdering(lineFixtures, reportData);
assertReportHasCorrectCashAdvanceStatistics(lineFixtures, reportData);
assertReportHasCorrectCorporateCardStatistics(lineFixtures, reportData);
assertReportHasCorrectPseudoPaymentCodeStatistics(lineFixtures, reportData);
}
use of edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture in project cu-kfs by CU-CommunityApps.
the class ConcurStandardAccountingExtractCashAdvanceServiceImplTest method buildSAELines.
private List<ConcurStandardAccountingExtractDetailLine> buildSAELines() {
List<ConcurSAEDetailLineFixture> lineFixtures = ConcurFixtureUtils.getFixturesContainingParentFixture(ConcurSAEDetailLineFixture.class, ConcurSAEFileFixture.PDP_TEST, ConcurSAEDetailLineFixture::getExtractFile);
List<ConcurStandardAccountingExtractDetailLine> saeLines = new ArrayList<ConcurStandardAccountingExtractDetailLine>();
for (ConcurSAEDetailLineFixture fixture : lineFixtures) {
saeLines.add(fixture.toDetailLine());
}
return saeLines;
}
use of edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture in project cu-kfs by CU-CommunityApps.
the class ConcurStandardAccountingExtractCollectorBatchBuilderTest method assertReportHasCorrectLinesAndOrdering.
protected <T extends ConcurBatchReportLineValidationErrorItem> void assertReportHasCorrectLinesAndOrdering(List<ConcurSAEDetailLineFixture> lineFixtures, Predicate<ConcurSAEDetailLineFixture> lineFilter, List<T> actualLines, BiConsumer<ConcurSAEDetailLineFixture, T> extraValidation) throws Exception {
ConcurSAEDetailLineFixture[] expectedLines = lineFixtures.stream().filter(lineFilter).toArray(ConcurSAEDetailLineFixture[]::new);
// Expected sequence numbers are the fixtures' positions in the lineFixtures List, plus one.
String[] expectedSequenceNumbers = Arrays.stream(expectedLines).mapToInt(lineFixtures::indexOf).map(Math::incrementExact).mapToObj(String::valueOf).toArray(String[]::new);
assertEquals("Wrong number of error-related lines in report", expectedLines.length, actualLines.size());
int i = 0;
for (ConcurSAEDetailLineFixture expectedLine : expectedLines) {
T actualLine = actualLines.get(i);
String expectedObjectCode;
if (StringUtils.equals(ConcurConstants.PENDING_CLIENT, expectedLine.journalAccountCode)) {
expectedObjectCode = ConcurTestConstants.ParameterTestValues.OBJECT_CODE_OVERRIDE;
} else {
expectedObjectCode = expectedLine.journalAccountCode;
}
assertEquals("Wrong sequence number", expectedSequenceNumbers[i], actualLine.getLineId());
assertEquals("Wrong report ID", expectedLine.reportId, actualLine.getReportId());
assertEquals("Wrong employee ID", expectedLine.employee.employeeId, actualLine.getEmployeeId());
assertEquals("Wrong last name", expectedLine.employee.lastName, actualLine.getLastName());
assertEquals("Wrong first name", expectedLine.employee.firstName, actualLine.getFirstName());
assertEquals("Wrong middle initial", expectedLine.employee.middleInitial, actualLine.getMiddleInitial());
assertEquals("Wrong chart code", expectedLine.chartOfAccountsCode, actualLine.getChartOfAccountsCode());
assertEquals("Wrong account number", expectedLine.accountNumber, actualLine.getAccountNumber());
assertEquals("Wrong sub-account number", expectedLine.subAccountNumber, actualLine.getSubAccountNumber());
assertEquals("Wrong object code", expectedObjectCode, actualLine.getObjectCode());
assertEquals("Wrong sub-object code", expectedLine.subObjectCode, actualLine.getSubObjectCode());
assertEquals("Wrong project code", expectedLine.projectCode, actualLine.getProjectCode());
assertEquals("Wrong org reference ID", expectedLine.orgRefId, actualLine.getOrgRefId());
assertEquals("Wrong line amount", new KualiDecimal(expectedLine.journalAmount), actualLine.getLineAmount());
List<String> messages = actualLine.getItemErrorResults();
assertNotNull("Error messages list should not be null", messages);
assertEquals("Wrong number of error messages in list", 1, messages.size());
assertTrue("Error message should have been non-blank", StringUtils.isNotBlank(messages.get(0)));
extraValidation.accept(expectedLine, actualLine);
i++;
}
}
Aggregations