Skip to content

Commit

Permalink
Merge pull request #1612 from leoherbie/training-budget
Browse files Browse the repository at this point in the history
RESKC-938, RESKC-939: upgrading s2s and adding tests #norelease
  • Loading branch information
blackcathacker committed Mar 23, 2016
2 parents 832bf00 + e39d2f7 commit bf4d791
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 1 deletion.
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);

}
}
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);
}
}
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();
}
}
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();
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<cas-client-core.version>3.3.3</cas-client-core.version>
<cglib.version>3.1</cglib.version>
<coeus-api-all.version>1602.0001</coeus-api-all.version>
<coeus-s2sgen.version>1603.0008</coeus-s2sgen.version>
<coeus-s2sgen.version>1603.0009</coeus-s2sgen.version>
<commons-beanutils.version>1.8.3-kuali-4</commons-beanutils.version>
<commons-codec.version>1.10</commons-codec.version>
<commons-collections.version>3.2.2</commons-collections.version>
Expand Down

0 comments on commit bf4d791

Please sign in to comment.