@Test public void shouldDetermineDateAsValidForScheduleWhenReturnsSameDate() { LocalDate disbursementDate = new LocalDate(); DateTime disbursementDateAsDateTime = disbursementDate.toDateMidnight().toDateTime(); when(scheduledEvent.nearestMatchingDateBeginningAt(disbursementDateAsDateTime)).thenReturn(disbursementDateAsDateTime); boolean result = loanDisbursementStrategy.isDisbursementDateValidInRelationToSchedule(disbursementDate); assertTrue("given nearest matching valid date is same as date provided, then dibursement date should be valid.", result); }
@Override public boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate) { boolean result = false; if (disbursementDate.isEqual(this.nextValidCustomerMeetingDate)) { result = true; } else if (disbursementDate.isAfter(this.nextValidCustomerMeetingDate)) { LocalDate matchingDate = this.nextValidCustomerMeetingDate; matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); while(matchingDate.isBefore(disbursementDate)) { matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); } if (matchingDate.isEqual(disbursementDate)) { result = true; } } return result; }
LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl implements LoanDisbursementStrategy { @Override public boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate) { boolean result = false; if (disbursementDate.isEqual(this.nextValidCustomerMeetingDate)) { result = true; } else if (disbursementDate.isAfter(this.nextValidCustomerMeetingDate)) { LocalDate matchingDate = this.nextValidCustomerMeetingDate; matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); while(matchingDate.isBefore(disbursementDate)) { matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); } if (matchingDate.isEqual(disbursementDate)) { result = true; } } return result; } }
LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl implements LoanDisbursementStrategy { @Override public boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate) { boolean result = false; if (disbursementDate.isEqual(this.nextValidCustomerMeetingDate)) { result = true; } else if (disbursementDate.isAfter(this.nextValidCustomerMeetingDate)) { LocalDate matchingDate = this.nextValidCustomerMeetingDate; matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); while(matchingDate.isBefore(disbursementDate)) { matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); } if (matchingDate.isEqual(disbursementDate)) { result = true; } } return result; } LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl(ScheduledEvent scheduledEvent, LocalDate nextValidCustomerMeetingDate); }
LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl implements LoanDisbursementStrategy { @Override public boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate) { boolean result = false; if (disbursementDate.isEqual(this.nextValidCustomerMeetingDate)) { result = true; } else if (disbursementDate.isAfter(this.nextValidCustomerMeetingDate)) { LocalDate matchingDate = this.nextValidCustomerMeetingDate; matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); while(matchingDate.isBefore(disbursementDate)) { matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); } if (matchingDate.isEqual(disbursementDate)) { result = true; } } return result; } LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl(ScheduledEvent scheduledEvent, LocalDate nextValidCustomerMeetingDate); @Override LocalDate findClosestMatchingDateFromAndInclusiveOf(LocalDate fromAndInclusiveOf); @Override boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate); }
LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl implements LoanDisbursementStrategy { @Override public boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate) { boolean result = false; if (disbursementDate.isEqual(this.nextValidCustomerMeetingDate)) { result = true; } else if (disbursementDate.isAfter(this.nextValidCustomerMeetingDate)) { LocalDate matchingDate = this.nextValidCustomerMeetingDate; matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); while(matchingDate.isBefore(disbursementDate)) { matchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); } if (matchingDate.isEqual(disbursementDate)) { result = true; } } return result; } LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl(ScheduledEvent scheduledEvent, LocalDate nextValidCustomerMeetingDate); @Override LocalDate findClosestMatchingDateFromAndInclusiveOf(LocalDate fromAndInclusiveOf); @Override boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate);  }