### Question:
WriteOffPaymentBuilderService implements PaymentBuilderService { @Override public PaymentBuilder getPaymentBuilder( final @Nonnull DataContextOfAction dataContextOfAction, final @Nullable BigDecimal ignored, final LocalDate forDate, final RunningBalances runningBalances) { final CaseParametersEntity caseParameters = dataContextOfAction.getCaseParametersEntity(); final int minorCurrencyUnitDigits = dataContextOfAction.getProductEntity().getMinorCurrencyUnitDigits(); final Stream<ScheduledCharge> scheduledChargesForAccruals = chargeDefinitionService.getChargeDefinitionsMappedByAccrueAction(dataContextOfAction.getProductEntity().getIdentifier()) .values().stream().flatMap(Collection::stream) .map(x -> getReverseAccrualScheduledCharge(x, forDate)); final List<ScheduledCharge> scheduledChargesForAccrualsAndWriteOff = Stream.concat(scheduledChargesForAccruals, Stream.of(getScheduledChargeForWriteOff(forDate))) .collect(Collectors.toList()); final BigDecimal loanPaymentSize = dataContextOfAction.getCaseParametersEntity().getPaymentSize(); return CostComponentService.getCostComponentsForScheduledCharges( scheduledChargesForAccrualsAndWriteOff, caseParameters.getBalanceRangeMaximum(), runningBalances, loanPaymentSize, BigDecimal.ZERO, BigDecimal.ZERO, dataContextOfAction.getInterest(), minorCurrencyUnitDigits, true); } @Autowired  WriteOffPaymentBuilderService(
      final ChargeDefinitionService chargeDefinitionService); @Override PaymentBuilder getPaymentBuilder(
      final @Nonnull DataContextOfAction dataContextOfAction,
      final @Nullable BigDecimal ignored,
      final LocalDate forDate,
      final RunningBalances runningBalances);  }### Answer:
@Test public void getPaymentBuilder() throws Exception { final PaymentBuilder paymentBuilder = PaymentBuilderServiceTestHarness.constructCallToPaymentBuilder( (scheduledChargesService) -> new WriteOffPaymentBuilderService(DefaultChargeDefinitionsMocker.getChargeDefinitionService(Collections.emptyList())), testCase); final Payment payment = paymentBuilder.buildPayment(Action.WRITE_OFF, Collections.emptySet(), testCase.forDate.toLocalDate()); Assert.assertNotNull(payment); final Map<String, CostComponent> mappedCostComponents = payment.getCostComponents().stream() .collect(Collectors.toMap(CostComponent::getChargeIdentifier, x -> x)); Assert.assertEquals( testCase.remainingPrincipal, mappedCostComponents.get(ChargeIdentifiers.WRITE_OFF_ID).getAmount()); }