### Question:
AdviceServiceImpl implements AdviceService { @Override public Long delete(Long id) { try { adviceRepo.deleteById(id); } catch (EmptyResultDataAccessException e) { throw new NotDeletedException(ErrorMessage.ADVICE_NOT_DELETED); } return id; } @Autowired  AdviceServiceImpl(AdviceRepo adviceRepo, HabitDictionaryRepo habitDictionaryRepo,
                             AdviceTranslationRepo adviceTranslationRepo, ModelMapper modelMapper); @Override List<LanguageTranslationDTO> getAllAdvices(); @Override LanguageTranslationDTO getRandomAdviceByHabitIdAndLanguage(Long id, String language); @Override AdviceDTO getAdviceById(Long id); @Override AdviceDTO getAdviceByName(String language, String name); @Override Advice save(AdvicePostDTO advicePostDTO); @Override Advice update(AdvicePostDTO advice, Long id); @Override Long delete(Long id);  }### Answer:
@Test public void delete() { assertEquals(advice.getId(), adviceService.delete(advice.getId())); verify(adviceRepo, times(1)).deleteById(anyLong()); }
@Test(expected = NotDeletedException.class) public void deleteFailed() { doThrow(new EmptyResultDataAccessException(1)).when(adviceRepo).deleteById(advice.getId()); adviceService.delete(advice.getId()); }