@Test public void testExample1WithNonNih() throws Exception { context.checking( new Expectations() { { one(sponsorHierarchyService).isSponsorNihMultiplePi(NON_NIH_SPONSOR_CODE); will(returnValue(false)); } }); budget.getDevelopmentProposal().setSponsorCode(NON_NIH_SPONSOR_CODE); subAward.getBudgetSubAwardPeriodDetails().get(0).setDirectCost(new ScaleTwoDecimal(150000L)); subAward.getBudgetSubAwardPeriodDetails().get(0).setIndirectCost(new ScaleTwoDecimal(75000L)); subAward.getBudgetSubAwardPeriodDetails().get(1).setDirectCost(new ScaleTwoDecimal(150000L)); subAward.getBudgetSubAwardPeriodDetails().get(1).setIndirectCost(new ScaleTwoDecimal(75000L)); List<Map<String, ScaleTwoDecimal>> expectedResults = new ArrayList<>(); expectedResults.add(new HashMap<>()); expectedResults.add(new HashMap<>()); expectedResults.add(new HashMap<>()); expectedResults.get(0).put(indirectGt, ScaleTwoDecimal.ZERO); expectedResults.get(0).put(indirectLt, ScaleTwoDecimal.ZERO); expectedResults.get(0).put(directGt, new ScaleTwoDecimal(200000L)); expectedResults.get(0).put(directLt, new ScaleTwoDecimal(25000L)); expectedResults.get(1).put(indirectGt, ScaleTwoDecimal.ZERO); expectedResults.get(1).put(indirectLt, ScaleTwoDecimal.ZERO); expectedResults.get(1).put(directGt, new ScaleTwoDecimal(225000L)); expectedResults.get(1).put(directLt, ScaleTwoDecimal.ZERO); service.generateSubAwardLineItems(subAward, budget); assertExpectedResults(expectedResults); assertCostShare(0); }
@Before public void setUp() throws Exception { context = new JUnit4Mockery() { { setThreadingPolicy(new Synchroniser()); } }; service = new PropDevPropDevBudgetSubAwardServiceImpl(); budget = new ProposalDevelopmentBudgetExt(); budget.setBudgetId(1L + 12); budget.setDevelopmentProposal(new DevelopmentProposal()); budget.getDevelopmentProposal().setSponsorCode(NIH_SPONSOR_CODE); subAward = new BudgetSubAwards(); subAward.setBudgetId(budget.getBudgetId()); subAward.setSubAwardNumber(1 + 206); Organization testOrg = new Organization(); testOrg.setOrganizationName("University of Maine"); testOrg.setOrganizationId("000040"); subAward.setOrganization(testOrg); budget.getBudgetSubAwards().add(subAward); for (int i = 0; i < 2; i++) { BudgetPeriod period = new BudgetPeriod(); period.setBudget(budget); period.setBudgetPeriod(i); period.setBudgetPeriodId(i + 1029L); budget.getBudgetPeriods().add(period); BudgetSubAwardPeriodDetail detail = new BudgetSubAwardPeriodDetail(subAward, period); detail.setBudgetSubAward(subAward); subAward.getBudgetSubAwardPeriodDetails().add(detail); } final ParameterService parmService = context.mock(ParameterService.class); sponsorHierarchyService = context.mock(SponsorHierarchyService.class); context.checking( new Expectations() { { one(parmService) .getParameterValueAsString( Budget.class, Constants.SUBCONTRACTOR_DIRECT_LT_25K_PARAM); will(returnValue(directLt)); one(parmService) .getParameterValueAsString( Budget.class, Constants.SUBCONTRACTOR_DIRECT_GT_25K_PARAM); will(returnValue(directGt)); one(parmService) .getParameterValueAsString( Budget.class, Constants.SUBCONTRACTOR_F_AND_A_LT_25K_PARAM); will(returnValue(indirectLt)); one(parmService) .getParameterValueAsString( Budget.class, Constants.SUBCONTRACTOR_F_AND_A_GT_25K_PARAM); will(returnValue(indirectGt)); } }); service.setParameterService(parmService); service.setSponsorHierarchyService(sponsorHierarchyService); service.setBudgetService(new BudgetServiceMock()); }