### Question:
CostComponentService { private static BigDecimal getAmountProportionalTo( final ScheduledCharge scheduledCharge, final BigDecimal maximumBalance, final RunningBalances runningBalances, final BigDecimal contractualRepayment, final BigDecimal requestedDisbursement, final BigDecimal requestedRepayment, final PaymentBuilder paymentBuilder) { final Optional<ChargeProportionalDesignator> optionalChargeProportionalTo = ChargeProportionalDesignator.fromString(scheduledCharge.getChargeDefinition().getProportionalTo()); return optionalChargeProportionalTo.map(chargeProportionalTo -> getAmountProportionalTo( scheduledCharge, chargeProportionalTo, maximumBalance, runningBalances, contractualRepayment, requestedDisbursement, requestedRepayment, paymentBuilder)) .orElse(BigDecimal.ZERO); }  static PaymentBuilder getCostComponentsForScheduledCharges(
      final Collection<ScheduledCharge> scheduledCharges,
      final BigDecimal maximumBalance,
      final RunningBalances preChargeBalances,
      final BigDecimal contractualRepayment,
      final BigDecimal requestedDisbursement,
      final BigDecimal requestedRepayment,
      final BigDecimal percentPoints,
      final int minorCurrencyUnitDigits,
      final boolean accrualAccounting); static BigDecimal getLoanPaymentSize(
      final BigDecimal maximumBalanceSize,
      final BigDecimal disbursementSize,
      final BigDecimal interest,
      final int minorCurrencyUnitDigits,
      final List<ScheduledCharge> scheduledCharges); static LocalDate today();  }### Answer:
@Test public void getAmountProportionalTo() { final SimulatedRunningBalances runningBalances = new SimulatedRunningBalances(); runningBalances.adjustBalance(AccountDesignators.CUSTOMER_LOAN_PRINCIPAL, testCase.runningBalance.negate()); final BigDecimal amount = CostComponentService.getAmountProportionalTo( null, testCase.chargeProportionalDesignator, testCase.maximumBalance, runningBalances, testCase.loanPaymentSize, testCase.loanPaymentSize, testCase.loanPaymentSize, new PaymentBuilder(runningBalances, false)); Assert.assertEquals(testCase.toString(), testCase.expectedAmount, amount); }