### Question:
OpenHoursServiceImpl implements OpenHoursService { @Override public OpeningHours findById(Long id) { log.info(LogMessage.IN_FIND_BY_ID, id); return hoursRepo .findById(id) .orElseThrow( () -> new NotFoundException(ErrorMessage.OPEN_HOURS_NOT_FOUND_BY_ID + id)); }  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);  }### Answer:
@Test public void findByIdTest() { OpeningHours genericEntity = new OpeningHours(); when(openHoursRepo.findById(anyLong())).thenReturn(Optional.of(genericEntity)); OpeningHours foundEntity = openHoursService.findById(anyLong()); assertEquals(genericEntity, foundEntity); }
@Test(expected = NotFoundException.class) public void findByIdGivenIdNullThenThrowException() { openHoursService.findById(null); }