@Test void findByIdTest() { HabitDictionary expected = getHabitDictionary(); when(habitDictionaryRepo.findById(expected.getId())).thenReturn(Optional.of(expected)); habitDictionaryService.findById(1L); verify(habitDictionaryRepo, times(1)).findById(anyLong()); }
@Override public HabitDictionary findById(Long id) { return habitDictionaryRepo.findById(id) .orElseThrow(() -> new NotFoundException(ErrorMessage.HABIT_NOT_FOUND_BY_ID + id)); }
HabitDictionaryServiceImpl implements HabitDictionaryService { @Override public HabitDictionary findById(Long id) { return habitDictionaryRepo.findById(id) .orElseThrow(() -> new NotFoundException(ErrorMessage.HABIT_NOT_FOUND_BY_ID + id)); } }
HabitDictionaryServiceImpl implements HabitDictionaryService { @Override public HabitDictionary findById(Long id) { return habitDictionaryRepo.findById(id) .orElseThrow(() -> new NotFoundException(ErrorMessage.HABIT_NOT_FOUND_BY_ID + id)); }  }
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); }
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);  }