@Test public void testCalculateAwardFundingEmptyId() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setAwardService(getAwardService()); protocolFundingSourceService.setFundingSourceTypeService(getFundingSourceTypeService()); protocolFundingSourceService.setParameterService(getParameterService()); ProtocolFundingSource fundingSource = (ProtocolFundingSource) protocolFundingSourceService.updateProtocolFundingSource( AWARD_SOURCE_TYPE_ID, EMPTY_NUMBER, null); assertNull(fundingSource); }
@Test public void testUpdateSourceNameEditable() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setParameterService(getParameterService()); assertFalse(protocolFundingSourceService.isEditable(FundingSourceType.INSTITUTIONAL_PROPOSAL)); assertTrue(protocolFundingSourceService.isEditable(FundingSourceType.OTHER)); assertFalse(protocolFundingSourceService.isEditable(FundingSourceType.AWARD)); assertFalse(protocolFundingSourceService.isEditable(FundingSourceType.PROPOSAL_DEVELOPMENT)); assertFalse(protocolFundingSourceService.isEditable(FundingSourceType.SPONSOR)); assertFalse(protocolFundingSourceService.isEditable(FundingSourceType.UNIT)); }
@Test public void testCalculateDevProposalFundingNegativeEmptyID() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setParameterService(getParameterService()); protocolFundingSourceService.setBusinessObjectService(getBusinessObjectService()); protocolFundingSourceService.setFundingSourceTypeService(getFundingSourceTypeService()); ProtocolFundingSource fundingSource = (ProtocolFundingSource) protocolFundingSourceService.updateProtocolFundingSource( DEVELOPMENT_PROP_SOURCE_TYPE_ID, EMPTY_NUMBER, null); assertNull(fundingSource); }
@Test public void testIsValidIdForTypeAward() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setFundingSourceTypeService(getFundingSourceTypeService()); protocolFundingSourceService.setAwardService(getAwardService()); protocolFundingSourceService.setParameterService(getParameterService()); ProtocolFundingSource fundingSource = new ProtocolFundingSource(AWARD_NUMBER_GOOD, FundingSourceType.AWARD, null, null); assertTrue(protocolFundingSourceService.isValidIdForType(fundingSource)); fundingSource = new ProtocolFundingSource(AWARD_NUMBER_BAD, FundingSourceType.AWARD, null, null); assertFalse(protocolFundingSourceService.isValidIdForType(fundingSource)); }
@Test public void testIsLookupableFundingSource() throws Exception { String badFundingTypeCode = "-99"; protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setParameterService(getParameterService()); assertFalse(protocolFundingSourceService.isLookupable(FundingSourceType.OTHER)); assertFalse(protocolFundingSourceService.isLookupable(badFundingTypeCode)); assertTrue(protocolFundingSourceService.isLookupable(FundingSourceType.INSTITUTIONAL_PROPOSAL)); assertTrue(protocolFundingSourceService.isLookupable(FundingSourceType.UNIT)); assertTrue(protocolFundingSourceService.isLookupable(FundingSourceType.SPONSOR)); assertTrue(protocolFundingSourceService.isLookupable(FundingSourceType.AWARD)); assertTrue(protocolFundingSourceService.isLookupable(FundingSourceType.PROPOSAL_DEVELOPMENT)); }
@Test public void testCalculateAwardFundingBadIdBadNumber() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setAwardService(getAwardService()); protocolFundingSourceService.setFundingSourceTypeService(getFundingSourceTypeService()); protocolFundingSourceService.setParameterService(getParameterService()); ProtocolFundingSource fundingSource = (ProtocolFundingSource) protocolFundingSourceService.updateProtocolFundingSource( AWARD_SOURCE_TYPE_ID, AWARD_NUMBER_BAD, null); assertNotNull(fundingSource); assertTrue(StringUtils.isEmpty(fundingSource.getFundingSourceName())); assertTrue(StringUtils.isEmpty(fundingSource.getFundingSourceTitle())); }
@Test public void testCalculateDevProposalFundingBadID() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setParameterService(getParameterService()); protocolFundingSourceService.setBusinessObjectService(getBusinessObjectService()); protocolFundingSourceService.setFundingSourceTypeService(getFundingSourceTypeService()); ProtocolFundingSource fundingSource = (ProtocolFundingSource) protocolFundingSourceService.updateProtocolFundingSource( DEVELOPMENT_PROP_SOURCE_TYPE_ID, DEV_PROPOSAL_NUMBER_BAD, null); assertNotNull(fundingSource); assertTrue(StringUtils.isEmpty(fundingSource.getFundingSourceName())); assertTrue(StringUtils.isEmpty(fundingSource.getFundingSourceTitle())); }
@Test public void testCalculateAwardFundingBadIdGoodNumber() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setAwardService(getAwardService()); protocolFundingSourceService.setFundingSourceTypeService(getFundingSourceTypeService()); protocolFundingSourceService.setParameterService(getParameterService()); ProtocolFundingSource fundingSource = (ProtocolFundingSource) protocolFundingSourceService.updateProtocolFundingSource( AWARD_SOURCE_TYPE_ID, AWARD_NUMBER_GOOD, null); assertNotNull(fundingSource); assertNotNull(fundingSource.getFundingSourceName()); assertTrue(fundingSource.getFundingSourceName().equalsIgnoreCase(sponsorNameAirForce)); assertTrue(fundingSource.getFundingSourceTitle().equalsIgnoreCase(AWARD_TITLE_GOOD)); }
@Test public void testCalculateInstProposalFundingBadIdBadNumber() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setParameterService(getParameterService()); protocolFundingSourceService.setInstitutionalProposalService(getInstProposalService()); protocolFundingSourceService.setFundingSourceTypeService(getFundingSourceTypeService()); protocolFundingSourceService.setBusinessObjectService(getBusinessObjectService()); ProtocolFundingSource fundingSource = (ProtocolFundingSource) protocolFundingSourceService.updateProtocolFundingSource( INSTITUTE_PROP_SOURCE_TYPE_ID, INST_PROPOSAL_NUMBER_BAD, null); assertNotNull(fundingSource); assertTrue(StringUtils.isEmpty(fundingSource.getFundingSourceName())); assertTrue(StringUtils.isEmpty(fundingSource.getFundingSourceTitle())); }
@Test public void testCalculateDevProposalFunding() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setParameterService(getParameterService()); protocolFundingSourceService.setBusinessObjectService(getBusinessObjectService()); protocolFundingSourceService.setFundingSourceTypeService(getFundingSourceTypeService()); ProtocolFundingSource fundingSource = (ProtocolFundingSource) protocolFundingSourceService.updateProtocolFundingSource( DEVELOPMENT_PROP_SOURCE_TYPE_ID, DEV_PROPOSAL_NUMBER_GOOD, null); assertNotNull(fundingSource); assertNotNull(fundingSource.getFundingSourceName()); assertTrue(fundingSource.getFundingSourceName().equalsIgnoreCase(sponsorNameAirForce)); assertTrue(fundingSource.getFundingSourceTitle().equalsIgnoreCase(DEV_PROPOSAL_TITLE_GOOD)); }
@Test public void testCalculateInstProposalFundingBadIdGoodNumber() throws Exception { protocolFundingSourceService = new ProtocolFundingSourceServiceImpl(); protocolFundingSourceService.setParameterService(getParameterService()); protocolFundingSourceService.setInstitutionalProposalService(getInstProposalService()); protocolFundingSourceService.setFundingSourceTypeService(getFundingSourceTypeService()); protocolFundingSourceService.setBusinessObjectService(getBusinessObjectService()); ProtocolFundingSource fundingSource = (ProtocolFundingSource) protocolFundingSourceService.updateProtocolFundingSource( INSTITUTE_PROP_SOURCE_TYPE_ID, INST_PROPOSAL_NUMBER_GOOD, null); assertNotNull(fundingSource); assertNotNull(fundingSource.getFundingSourceName()); assertTrue(fundingSource.getFundingSourceName().equalsIgnoreCase(sponsorNameAirForce)); assertTrue(fundingSource.getFundingSourceTitle().equalsIgnoreCase(INST_PROPOSAL_TITLE_GOOD)); }