@Test
  public void testExample1WithLineItems() throws Exception {
    context.checking(
        new Expectations() {
          {
            one(sponsorHierarchyService).isSponsorNihMultiplePi(NIH_SPONSOR_CODE);
            will(returnValue(true));
          }
        });

    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));

    for (BudgetPeriod period : budget.getBudgetPeriods()) {
      BudgetLineItem newLineItem = new BudgetLineItem();
      newLineItem.setBudgetSubAward(subAward);
      newLineItem.setSubAwardNumber(subAward.getSubAwardNumber());
      newLineItem.setDirectCost(new ScaleTwoDecimal(100L));
      newLineItem.setCostSharingAmount(new ScaleTwoDecimal(100L));
      newLineItem.setCostElement(directLt);
      newLineItem.setLineItemNumber(1);
      period.getBudgetLineItems().add(newLineItem);
      newLineItem = (BudgetLineItem) org.kuali.rice.krad.util.ObjectUtils.deepCopy(newLineItem);
      newLineItem.setCostElement(directGt);
      newLineItem.setLineItemNumber(2);
      period.getBudgetLineItems().add(newLineItem);
      newLineItem = (BudgetLineItem) org.kuali.rice.krad.util.ObjectUtils.deepCopy(newLineItem);
      newLineItem.setCostElement(indirectLt);
      newLineItem.setLineItemNumber(3);
      period.getBudgetLineItems().add(newLineItem);
      newLineItem = (BudgetLineItem) org.kuali.rice.krad.util.ObjectUtils.deepCopy(newLineItem);
      newLineItem.setCostElement(indirectGt);
      newLineItem.setLineItemNumber(4);
      period.getBudgetLineItems().add(newLineItem);
    }

    List<Map<String, ScaleTwoDecimal>> expectedResults = new ArrayList<>();
    expectedResults.add(new HashMap<>());
    expectedResults.add(new HashMap<>());
    expectedResults.add(new HashMap<>());
    expectedResults.get(0).put(indirectGt, new ScaleTwoDecimal(75000L));
    expectedResults.get(0).put(indirectLt, ScaleTwoDecimal.ZERO);
    expectedResults.get(0).put(directGt, new ScaleTwoDecimal(125000L));
    expectedResults.get(0).put(directLt, new ScaleTwoDecimal(25000L));
    expectedResults.get(1).put(indirectGt, new ScaleTwoDecimal(75000L));
    expectedResults.get(1).put(indirectLt, ScaleTwoDecimal.ZERO);
    expectedResults.get(1).put(directGt, new ScaleTwoDecimal(150000L));
    expectedResults.get(1).put(directLt, ScaleTwoDecimal.ZERO);
    service.generateSubAwardLineItems(subAward, budget);
    assertExpectedResults(expectedResults);
    assertCostShare(0);
  }
 protected BudgetLineItem getTravelLineItem(
     BudgetPeriod budgetPeriod, Date startDate, Date endDate) {
   BudgetLineItem lineItem = new BudgetLineItemMock();
   lineItem.setBudgetCategory(createBudgetCategory("20", "Test", "E"));
   lineItem.setBudgetCategoryCode("20");
   lineItem.setCostElement("420050");
   lineItem.setLineItemCost(new ScaleTwoDecimal(10000.00));
   lineItem.setEndDate(endDate);
   lineItem.setStartDate(startDate);
   lineItem.setCostElementBO(getCostElementTravel());
   lineItem.setApplyInRateFlag(Boolean.TRUE);
   lineItem.setOnOffCampusFlag(Boolean.TRUE);
   lineItem.setBudgetPeriodBO(budgetPeriod);
   lineItem.setBudgetPeriod(1);
   lineItem.setLineItemNumber(2);
   lineItem.setBudgetLineItemId(6L);
   return lineItem;
 }
  protected BudgetLineItem getPersonnelLineItem(
      BudgetPeriod budgetPeriod, Date startDate, Date endDate) {
    BudgetLineItem lineItem = new BudgetLineItemMock();
    lineItem.setBudgetCategory(createBudgetCategory("26", "Test", "E"));
    lineItem.setBudgetCategoryCode("26");
    lineItem.setCostElement("400350");
    lineItem.setLineItemCost(new ScaleTwoDecimal(10000.00));
    lineItem.setEndDate(endDate);
    lineItem.setStartDate(startDate);
    lineItem.setCostElementBO(getCostElementTravel());
    lineItem.setApplyInRateFlag(Boolean.TRUE);
    lineItem.setOnOffCampusFlag(Boolean.TRUE);
    lineItem.setBudgetPeriodBO(budgetPeriod);
    lineItem.setBudgetPeriod(1);
    lineItem.setBudgetLineItemId(5L);
    lineItem.setLineItemNumber(3);
    lineItem.setBudgetCategoryCode(PERSONNEL_CATEGORY_CODE);
    final BudgetCategory budgetCategory = new BudgetCategory();
    budgetCategory.setBudgetCategoryTypeCode(PERSONNEL_CATEGORY_CODE);
    lineItem.setBudgetCategory(budgetCategory);

    BudgetPersonnelDetails budgetPersonnelDetails = new BudgetPersonnelDetails();
    budgetPersonnelDetails.setLineItemNumber(3);
    budgetPersonnelDetails.setPersonNumber(1);
    budgetPersonnelDetails.setOnOffCampusFlag(Boolean.TRUE);
    budgetPersonnelDetails.setEndDate(endDate);
    budgetPersonnelDetails.setStartDate(startDate);
    budgetPersonnelDetails.setApplyInRateFlag(Boolean.TRUE);
    budgetPersonnelDetails.setJobCode("AA000");
    budgetPersonnelDetails.setPercentCharged(ScaleTwoDecimal.ONE_HUNDRED);
    budgetPersonnelDetails.setPercentEffort(ScaleTwoDecimal.ONE_HUNDRED);
    budgetPersonnelDetails.setPersonId("10000000002");
    budgetPersonnelDetails.setSalaryRequested(new ScaleTwoDecimal(102000L));
    budgetPersonnelDetails.setCostElement("400350");
    budgetPersonnelDetails.setCostElementBO(getCostElementPersonnel());
    budgetPersonnelDetails.setBudgetLineItem(lineItem);
    budgetPersonnelDetails.setBudgetPeriod(1);
    budgetPersonnelDetails.setBudgetPeriodBO(budgetPeriod);
    lineItem.getBudgetPersonnelDetailsList().add(budgetPersonnelDetails);
    lineItem.setCostElementBO(getCostElementPersonnel());
    return lineItem;
  }