### Question:
HabitDictionaryServiceImpl implements HabitDictionaryService { @Override public HabitDictionary findById(Long id) { return habitDictionaryRepo.findById(id) .orElseThrow(() -> new NotFoundException(ErrorMessage.HABIT_NOT_FOUND_BY_ID + id)); }  @Override HabitDictionary findById(Long id);  }### Answer:
@Test void findByIdTest() { HabitDictionary expected = getHabitDictionary(); when(habitDictionaryRepo.findById(expected.getId())).thenReturn(Optional.of(expected)); habitDictionaryService.findById(1L); verify(habitDictionaryRepo, times(1)).findById(anyLong()); }
@Test void findByIdNotFoundExceptionTest() { Long habitDictionaryId = getHabitDictionary().getId(); assertThrows(NotFoundException.class, () -> { habitDictionaryService.findById(habitDictionaryId); }); }