### Question:
ScheduledActionHelpers { public static ScheduledAction getNextScheduledPayment(final @Nonnull LocalDate startOfTerm, final @Nonnull LocalDate fromDate, final @Nonnull LocalDate endOfTerm, final @Nonnull CaseParameters caseParameters) { final LocalDate effectiveEndOfTerm = fromDate.isAfter(endOfTerm) ? fromDate : endOfTerm; return getHypotheticalScheduledActionsForDisbursedLoan(startOfTerm, effectiveEndOfTerm, caseParameters) .filter(x -> x.getAction().equals(Action.ACCEPT_PAYMENT)) .filter(x -> x.actionIsOnOrAfter(fromDate)) .findFirst() .orElseGet(() -> new ScheduledAction(Action.ACCEPT_PAYMENT, fromDate)); }  static boolean actionHasNoActionPeriod(final Action action); static List<ScheduledAction> getHypotheticalScheduledActions(final @Nonnull LocalDate startOfTerm,
                                                        final @Nonnull CaseParameters caseParameters); static ScheduledAction getNextScheduledPayment(final @Nonnull LocalDate startOfTerm,
                                                        final @Nonnull LocalDate fromDate,
                                                        final @Nonnull LocalDate endOfTerm,
                                                        final @Nonnull CaseParameters caseParameters); static LocalDate getRoughEndDate(final @Nonnull LocalDate startOfTerm,
                                          final @Nonnull CaseParameters caseParameters); static Stream<Period> generateRepaymentPeriods(
      final LocalDate startOfTerm,
      final LocalDate endOfTerm,
      final CaseParameters caseParameters); static Optional<Duration> getAccrualPeriodDurationForAction(final Action action);  }### Answer:
@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()); }