-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1612 from leoherbie/training-budget
RESKC-938, RESKC-939: upgrading s2s and adding tests #norelease
- Loading branch information
Showing
5 changed files
with
300 additions
and
1 deletion.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
...a/org/kuali/coeus/s2sgen/impl/generate/support/PHS398TrainingBudgetV1_0GeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package org.kuali.coeus.s2sgen.impl.generate.support; | ||
|
||
|
||
import org.kuali.coeus.common.budget.framework.period.BudgetPeriod; | ||
import org.kuali.coeus.common.framework.org.Organization; | ||
import org.kuali.coeus.propdev.impl.attachment.Narrative; | ||
import org.kuali.coeus.propdev.impl.budget.ProposalDevelopmentBudgetExt; | ||
import org.kuali.coeus.propdev.impl.core.ProposalDevelopmentDocument; | ||
import org.kuali.coeus.propdev.impl.person.ProposalPerson; | ||
import org.kuali.rice.core.api.criteria.QueryByCriteria; | ||
|
||
import org.kuali.rice.krad.data.DataObjectService; | ||
|
||
import java.sql.Date; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.kuali.coeus.sys.framework.service.KcServiceLocator.getService; | ||
|
||
public class PHS398TrainingBudgetV1_0GeneratorTest extends S2SModularBudgetTestBase { | ||
|
||
@Override | ||
protected String getFormGeneratorName() { | ||
return PHS398TrainingBudgetV1_0Generator.class.getSimpleName(); | ||
} | ||
|
||
@Override | ||
protected void prepareData(ProposalDevelopmentDocument document) throws Exception { | ||
Organization organization = getService(DataObjectService.class).findUnique(Organization.class, | ||
QueryByCriteria.Builder.forAttribute("organizationId", "000001").build()); | ||
document.getDevelopmentProposal().getApplicantOrganization().setOrganization(organization); | ||
|
||
List<Narrative> naList = new ArrayList<>(); | ||
|
||
Narrative narrative1 = createNarrative("130"); | ||
|
||
narrative1.setDevelopmentProposal(document.getDevelopmentProposal()); | ||
naList.add(narrative1); | ||
document.getDevelopmentProposal().setNarratives(naList); | ||
|
||
List<ProposalPerson> proposalPersons = new ArrayList<ProposalPerson>(); | ||
ProposalPerson principalInvestigator = new ProposalPerson(); | ||
principalInvestigator.setFirstName("ALAN"); | ||
principalInvestigator.setLastName("MCAFEE"); | ||
principalInvestigator.setProposalPersonRoleId("PI"); | ||
principalInvestigator.setPersonId("0001"); | ||
principalInvestigator.setRolodexId(0010); | ||
principalInvestigator.setProposalPersonNumber(1); | ||
principalInvestigator.setDevelopmentProposal(document.getDevelopmentProposal()); | ||
proposalPersons.add(principalInvestigator); | ||
document.getDevelopmentProposal().setProposalPersons(proposalPersons); | ||
|
||
ProposalDevelopmentBudgetExt proposalDevelopmentBudgetExt = new ProposalDevelopmentBudgetExt(); | ||
proposalDevelopmentBudgetExt.setDevelopmentProposal(document.getDevelopmentProposal()); | ||
proposalDevelopmentBudgetExt.setBudgetVersionNumber(1); | ||
proposalDevelopmentBudgetExt.setBudgetStatus("1"); | ||
proposalDevelopmentBudgetExt.setBudgetId(1L); | ||
proposalDevelopmentBudgetExt | ||
.setName("test Document Description"); | ||
proposalDevelopmentBudgetExt.setOnOffCampusFlag("Y"); | ||
proposalDevelopmentBudgetExt.setStartDate(new Date(new Long( | ||
"1183316613046"))); | ||
proposalDevelopmentBudgetExt.setEndDate(new Date(new Long( | ||
"1214852613046"))); | ||
proposalDevelopmentBudgetExt.setOhRateTypeCode("1"); | ||
proposalDevelopmentBudgetExt.setOhRateClassCode("1"); | ||
proposalDevelopmentBudgetExt.setModularBudgetFlag(false); | ||
proposalDevelopmentBudgetExt.setUrRateClassCode("1"); | ||
|
||
List<BudgetPeriod> budgetPeriods = new ArrayList<BudgetPeriod>(); | ||
BudgetPeriod budgetPeriod = new BudgetPeriod(); | ||
budgetPeriod.setBudgetPeriodId(1L); | ||
budgetPeriod.setStartDate(new Date(new Long("1183316613046"))); | ||
budgetPeriod.setEndDate(new Date(new Long("1214852613046"))); | ||
budgetPeriod.setBudgetPeriod(1); | ||
budgetPeriod.setBudget(proposalDevelopmentBudgetExt); | ||
budgetPeriods.add(budgetPeriod); | ||
proposalDevelopmentBudgetExt.setBudgetPeriods(budgetPeriods); | ||
|
||
List<ProposalDevelopmentBudgetExt> proposalDevelopmentBudgetExtList = new ArrayList<ProposalDevelopmentBudgetExt>(); | ||
proposalDevelopmentBudgetExtList.add(proposalDevelopmentBudgetExt); | ||
document.getDevelopmentProposal().setBudgets(proposalDevelopmentBudgetExtList); | ||
document.getDevelopmentProposal().setFinalBudget(proposalDevelopmentBudgetExt); | ||
|
||
} | ||
} |
194 changes: 194 additions & 0 deletions
194
...ali/coeus/s2sgen/impl/generate/support/PHS398TrainingSubAwardBudgetBaseGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
package org.kuali.coeus.s2sgen.impl.generate.support; | ||
|
||
import gov.grants.apply.system.metaGrantApplication.GrantApplicationDocument; | ||
import org.apache.xmlbeans.XmlCursor; | ||
import org.apache.xmlbeans.XmlObject; | ||
import org.junit.Assert; | ||
import org.kuali.coeus.common.budget.framework.period.BudgetPeriod; | ||
import org.kuali.coeus.common.framework.org.Organization; | ||
import org.kuali.coeus.propdev.impl.attachment.Narrative; | ||
import org.kuali.coeus.propdev.impl.budget.ProposalDevelopmentBudgetExt; | ||
import org.kuali.coeus.propdev.impl.budget.subaward.BudgetSubAwards; | ||
import org.kuali.coeus.propdev.impl.core.DevelopmentProposal; | ||
import org.kuali.coeus.propdev.impl.core.ProposalDevelopmentDocument; | ||
import org.kuali.coeus.propdev.impl.core.ProposalDevelopmentService; | ||
import org.kuali.coeus.propdev.impl.location.ProposalSite; | ||
import org.kuali.coeus.propdev.impl.person.ProposalPerson; | ||
import org.kuali.coeus.s2sgen.impl.generate.S2SBaseFormGenerator; | ||
import org.kuali.coeus.sys.framework.service.KcServiceLocator; | ||
import org.kuali.rice.krad.data.DataObjectService; | ||
import org.kuali.rice.krad.service.DocumentService; | ||
|
||
import java.sql.Date; | ||
import java.util.ArrayList; | ||
import java.util.Calendar; | ||
import java.util.List; | ||
|
||
import static org.kuali.coeus.sys.framework.service.KcServiceLocator.getService; | ||
|
||
public abstract class PHS398TrainingSubAwardBudgetBaseGeneratorTest extends S2STestBase { | ||
|
||
@Override | ||
protected void prepareData(ProposalDevelopmentDocument document) | ||
throws Exception { | ||
ProposalDevelopmentBudgetExt proposalDevelopmentBudgetExt = new ProposalDevelopmentBudgetExt(); | ||
proposalDevelopmentBudgetExt.setBudgetVersionNumber(1); | ||
proposalDevelopmentBudgetExt.setDevelopmentProposal(document.getDevelopmentProposal()); | ||
proposalDevelopmentBudgetExt.setBudgetStatus("1"); | ||
proposalDevelopmentBudgetExt.setBudgetId(1L); | ||
proposalDevelopmentBudgetExt.setName("test Document Description"); | ||
proposalDevelopmentBudgetExt.setOnOffCampusFlag("Y"); | ||
proposalDevelopmentBudgetExt.setStartDate(new Date(new Long("1183316613046"))); | ||
proposalDevelopmentBudgetExt.setEndDate(new Date(new Long("1214852613046"))); | ||
proposalDevelopmentBudgetExt.setOhRateTypeCode("1"); | ||
|
||
BudgetSubAwards budgetSubAwards = new BudgetSubAwards(); | ||
budgetSubAwards.setSubAwardNumber(1); | ||
budgetSubAwards.setBudgetId(1L); | ||
budgetSubAwards.setBudget(proposalDevelopmentBudgetExt); | ||
budgetSubAwards.setNamespace("http://apply.grants.gov/forms/PHS398_TrainingBudget-V1.0"); | ||
Organization testOrg = new Organization(); | ||
testOrg.setOrganizationName("University of Maine"); | ||
testOrg.setOrganizationId("000040"); | ||
budgetSubAwards.setOrganization(testOrg); | ||
budgetSubAwards.setSubAwardStatusCode(1); | ||
budgetSubAwards.setHiddenInHierarchy(false); | ||
|
||
S2SBaseFormGenerator generatorObject1; | ||
generatorObject1 = KcServiceLocator.getService(PHS398TrainingBudgetV1_0Generator.class.getSimpleName()); | ||
generatorObject1.setAttachments(new ArrayList<>()); | ||
ProposalDevelopmentDocument doc = initializeDocument(); | ||
initializeDevelopmentProposal(doc); | ||
prepareDocData(doc); | ||
doc = saveDocument(doc); | ||
XmlObject object = generatorObject1.getFormObject(doc); | ||
GrantApplicationDocument.GrantApplication.Forms forms = GrantApplicationDocument.GrantApplication.Forms.Factory.newInstance(); | ||
setFormObject(forms, object); | ||
GrantApplicationDocument.GrantApplication grantApplication = GrantApplicationDocument.GrantApplication.Factory.newInstance(); | ||
grantApplication.setForms(forms); | ||
|
||
budgetSubAwards.setSubAwardXmlFileData(grantApplication.xmlText()); | ||
List<BudgetSubAwards> budgetSubAwardsList = new ArrayList<>(); | ||
budgetSubAwardsList.add(budgetSubAwards); | ||
|
||
proposalDevelopmentBudgetExt.setBudgetSubAwards(budgetSubAwardsList); | ||
proposalDevelopmentBudgetExt.setOhRateClassCode("1"); | ||
proposalDevelopmentBudgetExt.setModularBudgetFlag(false); | ||
proposalDevelopmentBudgetExt.setUrRateClassCode("1"); | ||
proposalDevelopmentBudgetExt = getService(DataObjectService.class).save(proposalDevelopmentBudgetExt); | ||
|
||
List<ProposalDevelopmentBudgetExt> proposalDevelopmentBudgetExtList = new ArrayList<>(); | ||
proposalDevelopmentBudgetExtList.add(proposalDevelopmentBudgetExt); | ||
|
||
document.getDevelopmentProposal().setBudgets(proposalDevelopmentBudgetExtList); | ||
document.getDevelopmentProposal().setFinalBudget(proposalDevelopmentBudgetExt); | ||
} | ||
|
||
private ProposalDevelopmentDocument initializeDocument() throws Exception { | ||
ProposalDevelopmentDocument pd = (ProposalDevelopmentDocument) KcServiceLocator.getService(DocumentService.class).getNewDocument("ProposalDevelopmentDocument"); | ||
Assert.assertNotNull(pd.getDocumentHeader().getWorkflowDocument()); | ||
ProposalDevelopmentService pdService = getService(ProposalDevelopmentService.class); | ||
pdService.initializeUnitOrganizationLocation(pd); | ||
pdService.initializeProposalSiteNumbers(pd); | ||
return pd; | ||
} | ||
|
||
private DevelopmentProposal initializeDevelopmentProposal( | ||
ProposalDevelopmentDocument pd) { | ||
DevelopmentProposal developmentProposal = pd.getDevelopmentProposal(); | ||
developmentProposal.setPrimeSponsorCode("000120"); | ||
developmentProposal.setActivityTypeCode("1"); | ||
developmentProposal.refreshReferenceObject("activityType"); | ||
developmentProposal.setSponsorCode("000162"); | ||
developmentProposal.setOwnedByUnitNumber("000001"); | ||
developmentProposal.refreshReferenceObject("ownedByUnit"); | ||
developmentProposal.setProposalTypeCode("1"); | ||
developmentProposal.setCreationStatusCode("1"); | ||
developmentProposal.setApplicantOrganizationId("000001"); | ||
developmentProposal.setPerformingOrganizationId("000001"); | ||
developmentProposal.setNoticeOfOpportunityCode("1"); | ||
developmentProposal.setRequestedStartDateInitial(new Date(Calendar.getInstance().getTimeInMillis())); | ||
developmentProposal.setRequestedEndDateInitial(new Date(Calendar.getInstance().getTimeInMillis())); | ||
developmentProposal.setTitle("Test s2s service title"); | ||
developmentProposal.setDeadlineType("P"); | ||
developmentProposal.setDeadlineDate(new Date(Calendar.getInstance().getTimeInMillis())); | ||
developmentProposal.setNsfCode("J.05"); | ||
return developmentProposal; | ||
} | ||
|
||
public void prepareDocData(ProposalDevelopmentDocument document) | ||
throws Exception { | ||
|
||
Organization organization = new Organization(); | ||
organization.setOrganizationName("University"); | ||
organization.setOrganizationId("000001"); | ||
organization.setContactAddressId(1); | ||
|
||
ProposalSite applicantOrganization = new ProposalSite(); | ||
applicantOrganization.setLocationTypeCode(2); | ||
applicantOrganization.setOrganization(organization); | ||
|
||
applicantOrganization.setSiteNumber(1); | ||
applicantOrganization.setLocationName(organization.getOrganizationName()); | ||
document.getDevelopmentProposal().setApplicantOrganization(applicantOrganization); | ||
document.getDevelopmentProposal().getApplicantOrganization().getOrganization().setDunsNumber("00-176-5866"); | ||
|
||
List<Narrative> naList = new ArrayList<>(); | ||
|
||
Narrative narrative1 = createNarrative("130"); | ||
|
||
narrative1.setDevelopmentProposal(document.getDevelopmentProposal()); | ||
naList.add(narrative1); | ||
document.getDevelopmentProposal().setNarratives(naList); | ||
|
||
List<ProposalPerson> proposalPersons = new ArrayList<>(); | ||
ProposalPerson principalInvestigator = new ProposalPerson(); | ||
principalInvestigator.setFirstName("ALAN"); | ||
principalInvestigator.setLastName("MCAFEE"); | ||
principalInvestigator.setProposalPersonNumber(1); | ||
principalInvestigator.setProposalPersonRoleId("PI"); | ||
principalInvestigator.setPersonId("0001"); | ||
proposalPersons.add(principalInvestigator); | ||
principalInvestigator.setDevelopmentProposal(document.getDevelopmentProposal()); | ||
document.getDevelopmentProposal().setProposalPersons(proposalPersons); | ||
|
||
|
||
ProposalDevelopmentBudgetExt proposalDevelopmentBudgetExt = new ProposalDevelopmentBudgetExt(); | ||
proposalDevelopmentBudgetExt.setBudgetVersionNumber(1); | ||
proposalDevelopmentBudgetExt.setBudgetStatus("1"); | ||
proposalDevelopmentBudgetExt.setBudgetId(1L); | ||
proposalDevelopmentBudgetExt.setName("test Document Description"); | ||
proposalDevelopmentBudgetExt.setOnOffCampusFlag("Y"); | ||
proposalDevelopmentBudgetExt.setStartDate(new Date(new Long("1183316613046"))); | ||
proposalDevelopmentBudgetExt.setEndDate(new Date(new Long("1214852613046"))); | ||
proposalDevelopmentBudgetExt.setOhRateTypeCode("1"); | ||
proposalDevelopmentBudgetExt.setOhRateClassCode("1"); | ||
proposalDevelopmentBudgetExt.setModularBudgetFlag(false); | ||
proposalDevelopmentBudgetExt.setUrRateClassCode("1"); | ||
|
||
List<BudgetPeriod> budgetPeriods = new ArrayList<>(); | ||
BudgetPeriod budgetPeriod = new BudgetPeriod(); | ||
budgetPeriod.setBudgetPeriodId(1L); | ||
budgetPeriod.setStartDate(new Date(new Long("1183316613046"))); | ||
budgetPeriod.setEndDate(new Date(new Long("1214852613046"))); | ||
budgetPeriod.setBudgetPeriod(1); | ||
budgetPeriod.setBudget(proposalDevelopmentBudgetExt); | ||
budgetPeriods.add(budgetPeriod); | ||
proposalDevelopmentBudgetExt.setBudgetPeriods(budgetPeriods); | ||
|
||
proposalDevelopmentBudgetExt.setDevelopmentProposal(document.getDevelopmentProposal()); | ||
List<ProposalDevelopmentBudgetExt> proposalDevelopmentBudgetExtList = new ArrayList<>(); | ||
proposalDevelopmentBudgetExtList.add(proposalDevelopmentBudgetExt); | ||
document.getDevelopmentProposal().setBudgets(proposalDevelopmentBudgetExtList); | ||
document.getDevelopmentProposal().setFinalBudget(proposalDevelopmentBudgetExt); | ||
} | ||
|
||
private void setFormObject(GrantApplicationDocument.GrantApplication.Forms forms, XmlObject formObject) { | ||
XmlCursor formCursor = formObject.newCursor(); | ||
formCursor.toStartDoc(); | ||
formCursor.toNextToken(); | ||
XmlCursor metaGrantCursor = forms.newCursor(); | ||
metaGrantCursor.toNextToken(); | ||
formCursor.moveXml(metaGrantCursor); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...ali/coeus/s2sgen/impl/generate/support/PHS398TrainingSubAwardBudgetV1_0GeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.kuali.coeus.s2sgen.impl.generate.support; | ||
|
||
public class PHS398TrainingSubAwardBudgetV1_0GeneratorTest extends PHS398TrainingSubAwardBudgetBaseGeneratorTest { | ||
|
||
@Override | ||
protected String getFormGeneratorName() { | ||
return PHS398TrainingSubAwardBudgetV1_0Generator.class.getSimpleName(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ali/coeus/s2sgen/impl/generate/support/PHS398TrainingSubAwardBudgetV2_0GeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.kuali.coeus.s2sgen.impl.generate.support; | ||
|
||
|
||
public class PHS398TrainingSubAwardBudgetV2_0GeneratorTest extends PHS398TrainingSubAwardBudgetBaseGeneratorTest { | ||
|
||
@Override | ||
protected String getFormGeneratorName() { | ||
return PHS398TrainingSubAwardBudgetV2_0Generator.class.getSimpleName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters