@Test public void shouldFindNextMatchingDateInclusiveOfDateProvided() { LocalDate fromAndInclusiveOf = new LocalDate(); DateTime expectedDateTimeToStartSearchFrom = fromAndInclusiveOf.minusDays(1).toDateMidnight().toDateTime(); DateTime nextMatchingDate = new DateTime(); when(scheduledEvent.nextEventDateAfter(expectedDateTimeToStartSearchFrom)).thenReturn(nextMatchingDate); LocalDate result = loanDisbursementStrategy.findClosestMatchingDateFromAndInclusiveOf(fromAndInclusiveOf); assertThat(result, is(nextMatchingDate.toLocalDate())); }
@Override public LocalDate findClosestMatchingDateFromAndInclusiveOf(LocalDate fromAndInclusiveOf) { LocalDate closestMatch = nextValidCustomerMeetingDate; if (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); while (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); } } return closestMatch; }
LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl implements LoanDisbursementStrategy { @Override public LocalDate findClosestMatchingDateFromAndInclusiveOf(LocalDate fromAndInclusiveOf) { LocalDate closestMatch = nextValidCustomerMeetingDate; if (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); while (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); } } return closestMatch; } }
LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl implements LoanDisbursementStrategy { @Override public LocalDate findClosestMatchingDateFromAndInclusiveOf(LocalDate fromAndInclusiveOf) { LocalDate closestMatch = nextValidCustomerMeetingDate; if (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); while (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); } } return closestMatch; } LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl(ScheduledEvent scheduledEvent, LocalDate nextValidCustomerMeetingDate); }
LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl implements LoanDisbursementStrategy { @Override public LocalDate findClosestMatchingDateFromAndInclusiveOf(LocalDate fromAndInclusiveOf) { LocalDate closestMatch = nextValidCustomerMeetingDate; if (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); while (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); } } return closestMatch; } LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl(ScheduledEvent scheduledEvent, LocalDate nextValidCustomerMeetingDate); @Override LocalDate findClosestMatchingDateFromAndInclusiveOf(LocalDate fromAndInclusiveOf); @Override boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate); }
LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl implements LoanDisbursementStrategy { @Override public LocalDate findClosestMatchingDateFromAndInclusiveOf(LocalDate fromAndInclusiveOf) { LocalDate closestMatch = nextValidCustomerMeetingDate; if (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); while (closestMatch.isBefore(fromAndInclusiveOf)) { closestMatch = new LocalDate(scheduledEvent.nextEventDateAfter(closestMatch.toDateMidnight().toDateTime())); } } return closestMatch; } LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl(ScheduledEvent scheduledEvent, LocalDate nextValidCustomerMeetingDate); @Override LocalDate findClosestMatchingDateFromAndInclusiveOf(LocalDate fromAndInclusiveOf); @Override boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate);  }