  @Test
  public void getNextScheduledPayment() throws Exception {

    final LocalDate roughEndDate = ScheduledActionHelpers.getRoughEndDate(testCase.initialDisbursementDate, testCase.caseParameters);

    testCase.expectedResultContents.stream()
        .filter(x -> x.getAction() == Action.ACCEPT_PAYMENT)
        .forEach(expectedResultContents -> {
      final ScheduledAction nextScheduledPayment = ScheduledActionHelpers.getNextScheduledPayment(
          testCase.initialDisbursementDate,
          expectedResultContents.getWhen().minusDays(1),
          roughEndDate,
          testCase.caseParameters);
      Assert.assertEquals(expectedResultContents, nextScheduledPayment);
    });

    final ScheduledAction afterAction = ScheduledActionHelpers.getNextScheduledPayment(
        testCase.initialDisbursementDate,
        roughEndDate.plusDays(1),
        roughEndDate,
        testCase.caseParameters);

    Assert.assertNotNull(afterAction.getActionPeriod());
    Assert.assertTrue(afterAction.getActionPeriod().isLastPeriod());
  }