@Test public void testCheckForMultiplePIs() { AwardPerson newPerson = new AwardPerson( KcPersonFixtureFactory.createKcPerson(KP_PERSON_ID), ContactRoleFixtureFactory.MOCK_PI); newPerson.setPropAwardPersonRoleService(roleService); award.add(newPerson); Assert.assertFalse( "Multiple PIs not detected", rule.checkForOnePrincipalInvestigator(award.getProjectPersons())); checkErrorState( AwardProjectPersonsSaveRule.AWARD_PROJECT_PERSON_LIST_ERROR_KEY, AwardProjectPersonsSaveRule.ERROR_AWARD_PROJECT_PERSON_MULTIPLE_PI_EXISTS); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof AwardPersonUnit)) { return false; } AwardPersonUnit other = (AwardPersonUnit) obj; if (awardPerson == null) { if (other.awardPerson != null) { return false; } } else if (!awardPerson.equals(other.awardPerson)) { return false; } if (unit == null) { if (other.unit != null) { return false; } } else if (!unit.equals(other.unit)) { return false; } return true; }
@Override public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ((awardPerson == null) ? 0 : awardPerson.hashCode()); result = PRIME * result + ((unit == null) ? 0 : unit.hashCode()); return result; }
@Test public void testProjectRolesChanges() { // when a coi is changed to key person coiPerson.setContactRole(ContactRoleFixtureFactory.MOCK_KEY_PERSON); Assert.assertFalse( "Key Person Role not checked for", rule.checkForKeyPersonProjectRoles(award.getProjectPersons())); coiPerson.setKeyPersonRole("fromCOI"); Assert.assertTrue( "Key Person Role not checked for", rule.checkForKeyPersonProjectRoles(award.getProjectPersons())); // when a key person is changed to coi kpPerson.setContactRole(ContactRoleFixtureFactory.MOCK_COI); Assert.assertTrue( "rule should return true", rule.processSaveAwardProjectPersonsBusinessRules(award.getProjectPersons())); }
@Test public void testCheckForDuplicateUnits_DupeFound() { piPerson.add(new AwardPersonUnit(piPerson, unitA, false)); Assert.assertFalse( "Duplicate should have been found", rule.checkForDuplicateUnits(award.getProjectPersons())); checkErrorState( AwardProjectPersonsSaveRule.AWARD_PROJECT_PERSON_LIST_ERROR_KEY, AwardProjectPersonsSaveRule.ERROR_AWARD_PROJECT_PERSON_DUPLICATE_UNITS); }
@Test public void testCheckForKeyPersonRole_NotFound() { kpPerson.setKeyPersonRole(null); Assert.assertFalse( "Key Person Role not checked for", rule.checkForKeyPersonProjectRoles(award.getProjectPersons())); checkErrorState( AwardProjectPersonsSaveRule.AWARD_PROJECT_PERSON_LIST_ERROR_KEY, AwardProjectPersonsSaveRule.ERROR_AWARD_PROJECT_KEY_PERSON_ROLE_REQUIRED); }
@Test public void testCheckForUnitDetailsNotRequired_KP() { Assert.assertTrue( MISSING_UNIT_DETAILS_NOT_IDENTIFIED, rule.checkForRequiredUnitDetails(award.getProjectPersons())); kpPerson.getUnits().clear(); Assert.assertTrue( MISSING_UNIT_DETAILS_NOT_IDENTIFIED, rule.checkForRequiredUnitDetails(award.getProjectPersons())); Assert.assertEquals(0, GlobalVariables.getMessageMap().getErrorCount()); }
public boolean checkAwardPersonUnitCreditSplitTotals(AwardPersonUnitCreditSplitRuleEvent event) { int errorCount = 0; AwardPerson person = event.getProjectPerson(); for (InvestigatorCreditType creditType : loadInvestigatorCreditTypes()) { if (creditType.addsToHundred()) { KualiDecimal value = event.getTotalsByCreditSplitType().get(creditType.getInvCreditTypeCode()); if (value == null) { break; // value may not have been initialized yet, so we don't want to block save } if (!MAX_TOTAL_VALUE.subtract(value).isZero()) { reportError( AWARD_CREDIT_SPLIT_LIST_ERROR_KEY, AWARD_PERSON_UNIT_CREDIT_SPLIT_ERROR_MSG_KEY, creditType.getDescription(), person.getFullName()); errorCount++; } } } return errorCount == 0; }
@Test public void testCheckForLeadUnit_NoneFound() { Assert.assertTrue( "No lead unit was found", rule.checkForLeadUnitForPI(award.getProjectPersons())); piPerson.getUnit(0).setLeadUnit(false); Assert.assertFalse( "No lead unit should have been found", rule.checkForLeadUnitForPI(award.getProjectPersons())); checkErrorState( AwardProjectPersonsSaveRule.AWARD_PROJECT_PERSON_LIST_ERROR_KEY, AwardProjectPersonsSaveRule.ERROR_AWARD_PROJECT_PERSON_LEAD_UNIT_REQUIRED); }
@Test public void testCheckForRequiredUnitDetails_COI() { Assert.assertTrue( MISSING_UNIT_DETAILS_NOT_IDENTIFIED, rule.checkForRequiredUnitDetails(award.getProjectPersons())); coiPerson.getUnits().clear(); Assert.assertFalse( MISSING_UNIT_DETAILS_NOT_IDENTIFIED, rule.checkForRequiredUnitDetails(award.getProjectPersons())); checkErrorState( AwardProjectPersonsSaveRule.AWARD_PROJECT_PERSON_LIST_ERROR_KEY, AwardProjectPersonsSaveRule.ERROR_AWARD_PROJECT_PERSON_UNIT_DETAILS_REQUIRED); }
public Award getSequenceOwner() { return awardPerson != null ? awardPerson.getAward() : null; }
/** @param awardPerson */ public void setAwardPerson(AwardPerson awardPerson) { this.awardPerson = awardPerson; this.awardContactId = awardPerson != null ? awardPerson.getAwardContactId() : null; }
public String getFullName() { return awardPerson != null ? (awardPerson.getContact() != null ? awardPerson.getContact().getFullName() : null) : null; }
@Test public void testCheckForDuplicateUnits_NoneFound() { piPerson.add(new AwardPersonUnit(piPerson, unitB, false)); Assert.assertTrue(rule.checkForDuplicateUnits(award.getProjectPersons())); }
public void setSequenceOwner(Award newlyVersionedOwner) { if (awardPerson != null) { awardPerson.setAward(newlyVersionedOwner); } }
public Integer getSequenceNumber() { return awardPerson != null ? awardPerson.getSequenceNumber() : 0; }
@Before public void setUp() { context = new JUnit4Mockery() { { setThreadingPolicy(new Synchroniser()); } }; roleListBuilder = GenericQueryResults.Builder.create(); roleListBuilder.setResults( new ArrayList<PropAwardPersonRole>() { { add(createTestRole(3L, "PI", PropAwardPersonRoleServiceImpl.NIH_MULTIPLE_PI_HIERARCHY)); add(createTestRole(4L, "KP", PropAwardPersonRoleServiceImpl.NIH_MULTIPLE_PI_HIERARCHY)); add( createTestRole( 5L, "MPI", PropAwardPersonRoleServiceImpl.NIH_MULTIPLE_PI_HIERARCHY)); add( createTestRole( 6L, "COI", PropAwardPersonRoleServiceImpl.NIH_MULTIPLE_PI_HIERARCHY)); } }); rule = new AwardProjectPersonsSaveRuleImpl(); award = new Award(); award.setSponsorCode(SPONSOR_CODE); unitA = new Unit(); unitA.setUnitName("a"); unitA.setUnitNumber("1"); unitB = new Unit(); unitB.setUnitName("b"); unitB.setUnitNumber("2"); KcPerson employee = KcPersonFixtureFactory.createKcPerson(PERSON_ID); piPerson = new AwardPerson(employee, ContactRoleFixtureFactory.MOCK_PI); piPerson.add(new AwardPersonUnit(piPerson, unitA, true)); NonOrganizationalRolodex nonEmployee; nonEmployee = new NonOrganizationalRolodex(); nonEmployee.setRolodexId(ROLODEX_ID); coiPerson = new AwardPerson(nonEmployee, ContactRoleFixtureFactory.MOCK_COI); coiPerson.add(new AwardPersonUnit(coiPerson, unitA, false)); KcPerson employee2 = KcPersonFixtureFactory.createKcPerson(KP_PERSON_ID); kpPerson = new AwardPerson(employee2, ContactRoleFixtureFactory.MOCK_KEY_PERSON); kpPerson.setKeyPersonRole("Tester"); kpPerson.add(new AwardPersonUnit(kpPerson, unitA, false)); piPerson.setAward(award); coiPerson.setAward(award); kpPerson.setAward(award); roleService = getPropAwardPersonRoleService(); piPerson.setPropAwardPersonRoleService(roleService); coiPerson.setPropAwardPersonRoleService(roleService); kpPerson.setPropAwardPersonRoleService(roleService); award.add(piPerson); award.add(coiPerson); award.add(kpPerson); GlobalVariables.setMessageMap(new MessageMap()); }