### Question:
NewsSubscriberServiceImpl implements NewsSubscriberService { public Long unsubscribe(String email, String unsubscribeToken) { NewsSubscriber newsSubscriber = findByEmail(email) .orElseThrow(() -> new NewsSubscriberPresentException(NEWS_SUBSCRIBER_BY_EMAIL_NOT_FOUND + email)); if (newsSubscriber.getUnsubscribeToken().equals(unsubscribeToken)) { newsSubscriberRepo.delete(newsSubscriber); } else { throw new InvalidUnsubscribeToken(INVALID_UNSUBSCRIBE_TOKEN); } return newsSubscriber.getId(); } @Autowired  NewsSubscriberServiceImpl(NewsSubscriberRepo newsSubscriberRepo, ModelMapper modelMapper); @Transactional @Override NewsSubscriberRequestDto save(NewsSubscriberRequestDto dto); Long unsubscribe(String email, String unsubscribeToken); @Override List<NewsSubscriberResponseDto> findAll();  }### Answer:
@Test public void unsubscribeTest() { String email = "test.mail.ua"; String token = "token"; doNothing().when(newsSubscriberRepo).delete(any()); when(newsSubscriberRepo.findByEmail(email)).thenReturn(Optional.of(entity)); assertEquals(new Long(1), newsSubscriberService.unsubscribe(email, token)); }