### Question:
DiscountServiceImpl implements DiscountService { @Override public DiscountValue findById(Long id) { log.info(LogMessage.IN_FIND_BY_ID, id); return repo .findById(id) .orElseThrow( () -> new NotFoundException(ErrorMessage.DISCOUNT_NOT_FOUND_BY_ID + id)); }  @Override DiscountValue save(DiscountValue discountValue); @Override DiscountValue findById(Long id); @Override Set<DiscountValue> findAllByPlaceId(Long placeId); @Override void deleteAllByPlaceId(Long placeId);  }### Answer:
@Test public void findById() { DiscountValue genericEntity = new DiscountValue(); when(discountValuesRepo.findById(anyLong())).thenReturn(Optional.of(genericEntity)); DiscountValue foundEntity = discountService.findById(anyLong()); assertEquals(genericEntity, foundEntity); }
@Test(expected = NotFoundException.class) public void findByIdGivenIdNullThenThrowException() { discountService.findById(null); }