Search in sources :

Example 1 with ConcurSAEDetailLineFixture

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());
}
Also used : ConcurSAEDetailLineFixture(edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 2 with ConcurSAEDetailLineFixture

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);
}
Also used : CollectorBatch(org.kuali.kfs.gl.batch.CollectorBatch) ConcurSAEDetailLineFixture(edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture) ConcurStandardAccountingExtractFile(edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractFile) ConcurStandardAccountingExtractBatchReportData(edu.cornell.kfs.concur.batch.report.ConcurStandardAccountingExtractBatchReportData)

Example 3 with ConcurSAEDetailLineFixture

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;
}
Also used : ConcurSAEDetailLineFixture(edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture) ArrayList(java.util.ArrayList) ConcurStandardAccountingExtractDetailLine(edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)

Example 4 with ConcurSAEDetailLineFixture

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++;
    }
}
Also used : ConcurSAEDetailLineFixture(edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Aggregations

ConcurSAEDetailLineFixture (edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)2 ConcurStandardAccountingExtractDetailLine (edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)1 ConcurStandardAccountingExtractFile (edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractFile)1 ConcurStandardAccountingExtractBatchReportData (edu.cornell.kfs.concur.batch.report.ConcurStandardAccountingExtractBatchReportData)1 ArrayList (java.util.ArrayList)1 CollectorBatch (org.kuali.kfs.gl.batch.CollectorBatch)1