### Question:
StaffMessageServiceImpl implements StaffMessageService { boolean isMessageTimeWithinBlackoutPeriod(Date deliveryDate) { Date checkForDate = (deliveryDate != null ? deliveryDate : new Date()); Blackout blackout = motechService().getBlackoutSettings(); if (blackout == null) { return false; } Calendar blackoutCalendar = new DateUtil().calendarFor(checkForDate); adjustForBlackoutStartDate(checkForDate, blackout, blackoutCalendar); Date blackoutStart = blackoutCalendar.getTime(); setBlackOutTime(blackout.getEndTime(), blackoutCalendar); if (blackoutCalendar.getTime().before(blackoutStart)) { blackoutCalendar.add(Calendar.DATE, 1); } Date blackoutEnd = blackoutCalendar.getTime(); return checkForDate.after(blackoutStart) && checkForDate.before(blackoutEnd); } StaffMessageServiceImpl();  StaffMessageServiceImpl(
            ContextService contextService,
            MessageService mobileService
    ); void sendStaffCareMessages(Date startDate, Date endDate,
                                      Date deliveryDate, Date deliveryTime,
                                      String[] careGroups,
                                      boolean sendUpcoming,
                                      boolean blackoutEnabled,
                                      boolean sendNoDefaulterAndNoUpcomingCareMessage); void sendUpcomingMessages(Date startDate, Date endDate, Date deliveryDate, String[] careGroups, Facility facility, Boolean sendNoUpcomingCareMessage); void sendDefaulterMessages(Date startDate, Date deliveryDate, String[] careGroups, Facility facility, Boolean sendNoDefaulterMessage); void setContextService(ContextService contextService); void setExpectedEncountersFilter(FilterChain expectedEncountersFilter); void setExpectedObsFilter(FilterChain expectedObsFilter); void setMobileService(MessageService mobileService); void setCareModelConverter(WebServiceCareModelConverter careModelConverter);  }### Answer:
@Test public void testShouldFindOutIfMessageTimeIsDuringBlackoutPeriod() { DateUtil dateUtil = new DateUtil(); Calendar calendar = dateUtil.getCalendarWithTime(23, 13, 54); Date morningMessageTime = calendar.getTime(); calendar = dateUtil.getCalendarWithTime(3, 13, 54); Date nightMessageTime = calendar.getTime(); calendar = dateUtil.getCalendarWithTime(19, 30, 30); Date eveningMessageTime = calendar.getTime(); Blackout blackout = new Blackout(Time.valueOf("23:00:00"), Time.valueOf("06:00:00")); expect(contextService.getMotechService()).andReturn(motechService).times(3); expect(motechService.getBlackoutSettings()).andReturn(blackout).times(3); replay(contextService, adminService, motechService); assertTrue(staffMessageServiceImpl.isMessageTimeWithinBlackoutPeriod(morningMessageTime)); assertTrue(staffMessageServiceImpl.isMessageTimeWithinBlackoutPeriod(nightMessageTime)); assertFalse(staffMessageServiceImpl.isMessageTimeWithinBlackoutPeriod(eveningMessageTime)); verify(contextService, adminService, motechService); }