Skip to content

Commit

Permalink
KFSPTS-30631 Fix handling of bad create-acct-doc create dates (#1539)
Browse files Browse the repository at this point in the history
  • Loading branch information
cah292 committed Jan 10, 2024
1 parent e994f8c commit e83b685
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,14 @@ private AccountingXmlDocumentListWrapper unmarshalAccountingDocumentFile(String

private void createFileEntry(AccountingXmlDocumentListWrapper accountingXmlDocuments, String fileName) {
CreateAccountingDocumentFileEntry fileEntry = new CreateAccountingDocumentFileEntry();
fileEntry.setFileName(getCleanedFileName(fileName));
fileEntry.setFileCreatedDate(new Timestamp(accountingXmlDocuments.getCreateDate().getTime()));
String cleanedFileName = getCleanedFileName(fileName);
fileEntry.setFileName(cleanedFileName);
if (accountingXmlDocuments.getCreateDate() != null) {
fileEntry.setFileCreatedDate(new Timestamp(accountingXmlDocuments.getCreateDate().getTime()));
} else {
LOG.warn("createFileEntry, File {} has a missing or malformed create date. "
+ "The invalid date will be ignored.", cleanedFileName);
}
fileEntry.setFileProcessedDate(dateTimeService.getCurrentTimestamp());
fileEntry.setReportEmailAddress(
StringUtils.left(accountingXmlDocuments.getReportEmail(), FileEntryFieldLengths.REPORT_EMAIL_ADDRESS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public void testLoadSingleFileWithSingleDIDocumentWithBadAttachmentUrl() throws
AccountingXmlDocumentListWrapperFixture.SINGLE_DI_DOCUMENT_WITH_BAD_ATTACHMENT_TEST);
}

@Test
public void testLoadSingleFileWithSingleDIDocumentAndIgnoringOfInvalidCreateDate() throws Exception {
copyTestFilesAndCreateDoneFiles("single-di-invalid-create-date-test");
assertDocumentsAreGeneratedCorrectlyByBatchProcess(
AccountingXmlDocumentListWrapperFixture.SINGLE_DI_DOCUMENT_TEST);
}

@Test
public void testLoadSingleFileWithSingleYEDIDocument() throws Exception {
copyTestFilesAndCreateDoneFiles("single-yedi-document-test");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DocumentWrapper>
<CreateDate>January fourth, twenty twenty-four</CreateDate>
<ReportEmail>abc123@cornell.edu</ReportEmail>
<Overview>Example XML file</Overview>
<DocumentList>
<Document>
<Index>1</Index>
<DocumentType>DI</DocumentType>
<Description>Test Document</Description>
<Explanation>This is only a test document!</Explanation>
<OrganizationDocumentNumber>ABCD1234</OrganizationDocumentNumber>
<SourceAccountingLineList>
<Accounting>
<coa_cd>IT</coa_cd>
<account_nbr>R504700</account_nbr>
<sub_account_nbr></sub_account_nbr>
<object_cd>2640</object_cd>
<sub_object_cd></sub_object_cd>
<project></project>
<org_ref_id></org_ref_id>
<line_description></line_description>
<amount>100.00</amount>
</Accounting>
<Accounting>
<coa_cd>IT</coa_cd>
<account_nbr>1000718</account_nbr>
<sub_account_nbr></sub_account_nbr>
<object_cd>4000</object_cd>
<sub_object_cd></sub_object_cd>
<project></project>
<org_ref_id></org_ref_id>
<line_description></line_description>
<amount>50</amount>
</Accounting>
</SourceAccountingLineList>
<TargetAccountingLineList>
<Accounting>
<coa_cd>IT</coa_cd>
<account_nbr>R504706</account_nbr>
<sub_account_nbr></sub_account_nbr>
<object_cd>2640</object_cd>
<sub_object_cd></sub_object_cd>
<project></project>
<org_ref_id></org_ref_id>
<line_description></line_description>
<amount>100.00</amount>
</Accounting>
<Accounting>
<coa_cd>IT</coa_cd>
<account_nbr>1000710</account_nbr>
<sub_account_nbr></sub_account_nbr>
<object_cd>4000</object_cd>
<sub_object_cd></sub_object_cd>
<project></project>
<org_ref_id></org_ref_id>
<line_description></line_description>
<amount>50</amount>
</Accounting>
</TargetAccountingLineList>
<NoteList>
<Note>
<Description>A fun testing note</Description>
</Note>
<Note>
<Description>Another note</Description>
</Note>
</NoteList>
<AdhocRecipientList>
<Recipient>
<Netid>jdh34</Netid>
<ActionRequested>Approve</ActionRequested>
</Recipient>
<Recipient>
<Netid>se12</Netid>
<ActionRequested>FYI</ActionRequested>
</Recipient>
<Recipient>
<Netid>ccs1</Netid>
<ActionRequested>Complete</ActionRequested>
</Recipient>
<Recipient>
<Netid>nkk4</Netid>
<ActionRequested>Acknowledge</ActionRequested>
</Recipient>
</AdhocRecipientList>
<BackupDocumentLinks>
<BackupLink>
<Link>http://www.cornell.edu/index.html</Link>
<Description>Cornell index page</Description>
<FileName>index.html</FileName>
<CredentialGroupCode>TESTGRP</CredentialGroupCode>
</BackupLink>
<BackupLink>
<Link>https://www.dfa.cornell.edu/index.cfm</Link>
<Description>DFA index page</Description>
<FileName>index.cfm</FileName>
<CredentialGroupCode>TESTGRP</CredentialGroupCode>
</BackupLink>
</BackupDocumentLinks>
</Document>
</DocumentList>
</DocumentWrapper>

0 comments on commit e83b685

Please sign in to comment.