Search in sources :

Example 1 with AccountingXmlDocumentEntryFixture

use of edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentEntryFixture in project cu-kfs by CU-CommunityApps.

the class CreateAccountingDocumentServiceImplTest method buildExpectedDocumentsAndAppendToLists.

private void buildExpectedDocumentsAndAppendToLists(Consumer<AccountingXmlDocumentEntryFixture> fixtureListAppender, Consumer<AccountingDocument> documentListAppender, AccountingXmlDocumentEntryFixture... fixtures) {
    MutableInt idCounter = new MutableInt(DOCUMENT_NUMBER_START);
    Stream.of(fixtures).filter(this::isDocumentExpectedToReachInitiationPoint).map((fixture) -> buildDocumentIdToFixtureMapping(idCounter, fixture)).filter((mapping) -> isDocumentExpectedToPassBusinessRulesValidation(mapping.getValue())).peek((mapping) -> fixtureListAppender.accept(mapping.getValue())).map(this::buildExpectedDocument).forEach(documentListAppender);
}
Also used : CUMarshalServiceImpl(edu.cornell.kfs.sys.service.impl.CUMarshalServiceImpl) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) ValidationException(org.kuali.kfs.krad.exception.ValidationException) BatchInputFileServiceImpl(org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl) AdHocRoutePerson(org.kuali.kfs.krad.bo.AdHocRoutePerson) Date(java.util.Date) CreateAccountingDocumentReportService(edu.cornell.kfs.fp.batch.service.CreateAccountingDocumentReportService) BiFunction(java.util.function.BiFunction) AccountingXmlDocumentEntryFixture(edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentEntryFixture) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService) AccountingXmlDocumentListWrapperFixture(edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentListWrapperFixture) GlobalVariables(org.kuali.kfs.krad.util.GlobalVariables) CuFPConstants(edu.cornell.kfs.fp.CuFPConstants) ByteArrayInputStream(java.io.ByteArrayInputStream) CuFPKeyConstants(edu.cornell.kfs.fp.CuFPKeyConstants) WebServiceCredentialFixture(edu.cornell.kfs.sys.businessobject.fixture.WebServiceCredentialFixture) MockPersonUtil(edu.cornell.kfs.sys.util.MockPersonUtil) Map(java.util.Map) After(org.junit.After) KFSConstants(org.kuali.kfs.sys.KFSConstants) URI(java.net.URI) AttachmentService(org.kuali.kfs.krad.service.AttachmentService) FileStorageService(org.kuali.kfs.sys.service.FileStorageService) PersonService(org.kuali.rice.kim.api.identity.PersonService) MutableInt(org.apache.commons.lang.mutable.MutableInt) KRADConstants(org.kuali.kfs.krad.util.KRADConstants) Person(org.kuali.rice.kim.api.identity.Person) Note(org.kuali.kfs.krad.bo.Note) AccountingXmlDocumentDownloadAttachmentService(edu.cornell.kfs.fp.batch.service.AccountingXmlDocumentDownloadAttachmentService) GeneralLedgerConstants(org.kuali.kfs.gl.GeneralLedgerConstants) InternalBillingItem(org.kuali.kfs.fp.businessobject.InternalBillingItem) Invocation(javax.ws.rs.client.Invocation) Collectors(java.util.stream.Collectors) WebServiceCredentialService(edu.cornell.kfs.sys.service.WebServiceCredentialService) JAXBXmlBatchInputFileTypeBase(edu.cornell.kfs.sys.batch.JAXBXmlBatchInputFileTypeBase) List(java.util.List) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) Assert.assertFalse(org.junit.Assert.assertFalse) AccountingDocumentMapping(edu.cornell.kfs.fp.batch.xml.fixture.AccountingDocumentMapping) AccountingDocumentGenerator(edu.cornell.kfs.fp.batch.service.AccountingDocumentGenerator) UserNameFixture(org.kuali.kfs.sys.fixture.UserNameFixture) CuFPTestConstants(edu.cornell.kfs.fp.CuFPTestConstants) UserSession(org.kuali.kfs.krad.UserSession) Document(org.kuali.kfs.krad.document.Document) Client(javax.ws.rs.client.Client) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) MockObjectUtils(edu.cornell.kfs.sys.util.MockObjectUtils) DocumentService(org.kuali.kfs.krad.service.DocumentService) BiConsumer(java.util.function.BiConsumer) CreateAccountingDocumentReportItem(edu.cornell.kfs.fp.batch.CreateAccountingDocumentReportItem) MockDocumentUtils(edu.cornell.kfs.sys.util.MockDocumentUtils) Before(org.junit.Before) Attachment(org.kuali.kfs.krad.bo.Attachment) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) Capture(org.easymock.Capture) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) EasyMock(org.easymock.EasyMock) InternalBillingDocument(org.kuali.kfs.fp.document.InternalBillingDocument) AccountingXmlDocumentListWrapper(edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentListWrapper) File(java.io.File) Consumer(java.util.function.Consumer) AccountingDocumentClassMappingUtils(edu.cornell.kfs.fp.batch.xml.fixture.AccountingDocumentClassMappingUtils) AbstractMap(java.util.AbstractMap) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) Assert.assertNull(org.junit.Assert.assertNull) CuFPParameterConstants(edu.cornell.kfs.fp.CuFPParameterConstants) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) FileSystemFileStorageServiceImpl(org.kuali.kfs.sys.service.impl.FileSystemFileStorageServiceImpl) WebTarget(javax.ws.rs.client.WebTarget) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) MutableInt(org.apache.commons.lang.mutable.MutableInt)

Example 2 with AccountingXmlDocumentEntryFixture

use of edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentEntryFixture in project cu-kfs by CU-CommunityApps.

the class CreateAccountingDocumentServiceImplTest method assertDocumentsWereCreatedAndRoutedCorrectly.

private void assertDocumentsWereCreatedAndRoutedCorrectly(AccountingXmlDocumentEntryFixture... fixtures) {
    List<AccountingXmlDocumentEntryFixture> expectedRoutableFixtures = new ArrayList<>(fixtures.length);
    List<AccountingDocument> expectedAccountingDocuments = new ArrayList<>(fixtures.length);
    buildExpectedDocumentsAndAppendToLists(expectedRoutableFixtures::add, expectedAccountingDocuments::add, fixtures);
    assertEquals("Wrong number of routed documents", expectedAccountingDocuments.size(), routedAccountingDocuments.size());
    for (int i = 0; i < expectedAccountingDocuments.size(); i++) {
        AccountingXmlDocumentEntryFixture fixture = expectedRoutableFixtures.get(i);
        Class<? extends AccountingDocument> expectedDocumentClass = AccountingDocumentClassMappingUtils.getDocumentClassByDocumentType(fixture.documentTypeCode);
        assertAccountingDocumentIsCorrect(expectedDocumentClass, expectedAccountingDocuments.get(i), routedAccountingDocuments.get(i));
    }
}
Also used : AccountingXmlDocumentEntryFixture(edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentEntryFixture) ArrayList(java.util.ArrayList) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Aggregations

AccountingXmlDocumentEntryFixture (edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentEntryFixture)2 ArrayList (java.util.ArrayList)2 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)2 CuFPConstants (edu.cornell.kfs.fp.CuFPConstants)1 CuFPKeyConstants (edu.cornell.kfs.fp.CuFPKeyConstants)1 CuFPParameterConstants (edu.cornell.kfs.fp.CuFPParameterConstants)1 CuFPTestConstants (edu.cornell.kfs.fp.CuFPTestConstants)1 CreateAccountingDocumentReportItem (edu.cornell.kfs.fp.batch.CreateAccountingDocumentReportItem)1 AccountingDocumentGenerator (edu.cornell.kfs.fp.batch.service.AccountingDocumentGenerator)1 AccountingXmlDocumentDownloadAttachmentService (edu.cornell.kfs.fp.batch.service.AccountingXmlDocumentDownloadAttachmentService)1 CreateAccountingDocumentReportService (edu.cornell.kfs.fp.batch.service.CreateAccountingDocumentReportService)1 AccountingXmlDocumentListWrapper (edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentListWrapper)1 AccountingDocumentClassMappingUtils (edu.cornell.kfs.fp.batch.xml.fixture.AccountingDocumentClassMappingUtils)1 AccountingDocumentMapping (edu.cornell.kfs.fp.batch.xml.fixture.AccountingDocumentMapping)1 AccountingXmlDocumentListWrapperFixture (edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentListWrapperFixture)1 JAXBXmlBatchInputFileTypeBase (edu.cornell.kfs.sys.batch.JAXBXmlBatchInputFileTypeBase)1 WebServiceCredentialFixture (edu.cornell.kfs.sys.businessobject.fixture.WebServiceCredentialFixture)1 WebServiceCredentialService (edu.cornell.kfs.sys.service.WebServiceCredentialService)1 CUMarshalServiceImpl (edu.cornell.kfs.sys.service.impl.CUMarshalServiceImpl)1 MockDocumentUtils (edu.cornell.kfs.sys.util.MockDocumentUtils)1