DropScheduleService { DateTime getDropCreatedDate(DateTime dropDueDate) { DateTime dropCreatedDate = dropDueDate.withTime(dropScheduleConfig.getCreatedLocalTime()); Integer dropDueDateDay = dropDueDate.getDayOfWeek(); Integer dropStartDateDay = getDueDayToStartDay().get(dropDueDateDay); dropCreatedDate = dropCreatedDate.withDayOfWeek(dropStartDateDay); if (dropStartDateDay > dropDueDateDay) { dropCreatedDate = dropCreatedDate.minusWeeks(1); } return dropCreatedDate; }  DateTime getLastDropCreatedDate();  }
@Test public void testGetDropCreatedDate() { DateTime before = new DateTime("2018-06-08T14:00:00.000-07:00", dateTimeZone); assertEquals("2018-06-06T20:00:00.000-07:00", dropSchedule.getDropCreatedDate(before).toString()); }
@Test public void testGetDropCreatedDatePreviousWeek() { DateTime before = new DateTime("2018-06-05T14:00:00.000-07:00", dateTimeZone); assertEquals("2018-06-01T20:00:00.000-07:00", dropSchedule.getDropCreatedDate(before).toString()); }