@Test public void saveTestWOBreakTime() { OpeningHours openingHours = OpeningHours.builder() .openTime(LocalTime.of(9, 0)) .closeTime(LocalTime.of(20, 0)) .build(); when(openHoursRepo.save(openingHours)).thenReturn(openingHours); assertEquals(openingHours, openHoursService.save(openingHours)); }
@Override public OpeningHours save(OpeningHours hours) { log.info(LogMessage.IN_SAVE); if (hours.getOpenTime().getHour() > hours.getCloseTime().getHour()) { throw new BadRequestException(ErrorMessage.CLOSE_TIME_LATE_THAN_OPEN_TIME); } if (hours.getBreakTime() != null) { if (hours.getBreakTime().getStartTime().getHour() > hours.getOpenTime().getHour() && hours.getBreakTime().getEndTime().getHour() < hours.getCloseTime().getHour()) { breakTimeService.save(hours.getBreakTime()); } else { throw new BadRequestException(ErrorMessage.WRONG_BREAK_TIME); } } return hoursRepo.save(hours); }
OpenHoursServiceImpl implements OpenHoursService { @Override public OpeningHours save(OpeningHours hours) { log.info(LogMessage.IN_SAVE); if (hours.getOpenTime().getHour() > hours.getCloseTime().getHour()) { throw new BadRequestException(ErrorMessage.CLOSE_TIME_LATE_THAN_OPEN_TIME); } if (hours.getBreakTime() != null) { if (hours.getBreakTime().getStartTime().getHour() > hours.getOpenTime().getHour() && hours.getBreakTime().getEndTime().getHour() < hours.getCloseTime().getHour()) { breakTimeService.save(hours.getBreakTime()); } else { throw new BadRequestException(ErrorMessage.WRONG_BREAK_TIME); } } return hoursRepo.save(hours); } }
OpenHoursServiceImpl implements OpenHoursService { @Override public OpeningHours save(OpeningHours hours) { log.info(LogMessage.IN_SAVE); if (hours.getOpenTime().getHour() > hours.getCloseTime().getHour()) { throw new BadRequestException(ErrorMessage.CLOSE_TIME_LATE_THAN_OPEN_TIME); } if (hours.getBreakTime() != null) { if (hours.getBreakTime().getStartTime().getHour() > hours.getOpenTime().getHour() && hours.getBreakTime().getEndTime().getHour() < hours.getCloseTime().getHour()) { breakTimeService.save(hours.getBreakTime()); } else { throw new BadRequestException(ErrorMessage.WRONG_BREAK_TIME); } } return hoursRepo.save(hours); }  }
OpenHoursServiceImpl implements OpenHoursService { @Override public OpeningHours save(OpeningHours hours) { log.info(LogMessage.IN_SAVE); if (hours.getOpenTime().getHour() > hours.getCloseTime().getHour()) { throw new BadRequestException(ErrorMessage.CLOSE_TIME_LATE_THAN_OPEN_TIME); } if (hours.getBreakTime() != null) { if (hours.getBreakTime().getStartTime().getHour() > hours.getOpenTime().getHour() && hours.getBreakTime().getEndTime().getHour() < hours.getCloseTime().getHour()) { breakTimeService.save(hours.getBreakTime()); } else { throw new BadRequestException(ErrorMessage.WRONG_BREAK_TIME); } } return hoursRepo.save(hours); }  List<OpeningHours> getOpenHoursByPlace(Place place); @Override OpeningHours save(OpeningHours hours); @Override List<OpeningHours> findAll(); @Override OpeningHours findById(Long id); @Override OpeningHours update(Long id, OpeningHours updatedHours); @Override Long deleteById(Long id); @Override Set<OpeningHours> findAllByPlaceId(Long placeId); @Override void deleteAllByPlaceId(Long placeId); }
OpenHoursServiceImpl implements OpenHoursService { @Override public OpeningHours save(OpeningHours hours) { log.info(LogMessage.IN_SAVE); if (hours.getOpenTime().getHour() > hours.getCloseTime().getHour()) { throw new BadRequestException(ErrorMessage.CLOSE_TIME_LATE_THAN_OPEN_TIME); } if (hours.getBreakTime() != null) { if (hours.getBreakTime().getStartTime().getHour() > hours.getOpenTime().getHour() && hours.getBreakTime().getEndTime().getHour() < hours.getCloseTime().getHour()) { breakTimeService.save(hours.getBreakTime()); } else { throw new BadRequestException(ErrorMessage.WRONG_BREAK_TIME); } } return hoursRepo.save(hours); }  List<OpeningHours> getOpenHoursByPlace(Place place); @Override OpeningHours save(OpeningHours hours); @Override List<OpeningHours> findAll(); @Override OpeningHours findById(Long id); @Override OpeningHours update(Long id, OpeningHours updatedHours); @Override Long deleteById(Long id); @Override Set<OpeningHours> findAllByPlaceId(Long placeId); @Override void deleteAllByPlaceId(Long placeId);  }