@Test public void findAllTest() { NewsSubscriber entity = new NewsSubscriber(1L, "test@mail.ua", "token"); List<NewsSubscriber> entityList = Collections.singletonList(entity); List<NewsSubscriberResponseDto> dtoList = Collections.singletonList( new NewsSubscriberResponseDto("test@mail.ua", "token")); when(newsSubscriberRepo.findAll()).thenReturn(entityList); when(modelMapper.map(entity, NewsSubscriberResponseDto.class)) .thenReturn(new NewsSubscriberResponseDto("test@mail.ua", "token")); assertEquals(dtoList, newsSubscriberService.findAll()); }
@Override public List<NewsSubscriberResponseDto> findAll() { return newsSubscriberRepo.findAll().stream() .map(el -> modelMapper.map(el, NewsSubscriberResponseDto.class)) .collect(Collectors.toList()); }
NewsSubscriberServiceImpl implements NewsSubscriberService { @Override public List<NewsSubscriberResponseDto> findAll() { return newsSubscriberRepo.findAll().stream() .map(el -> modelMapper.map(el, NewsSubscriberResponseDto.class)) .collect(Collectors.toList()); } }
NewsSubscriberServiceImpl implements NewsSubscriberService { @Override public List<NewsSubscriberResponseDto> findAll() { return newsSubscriberRepo.findAll().stream() .map(el -> modelMapper.map(el, NewsSubscriberResponseDto.class)) .collect(Collectors.toList()); } @Autowired  NewsSubscriberServiceImpl(NewsSubscriberRepo newsSubscriberRepo, ModelMapper modelMapper); }
NewsSubscriberServiceImpl implements NewsSubscriberService { @Override public List<NewsSubscriberResponseDto> findAll() { return newsSubscriberRepo.findAll().stream() .map(el -> modelMapper.map(el, NewsSubscriberResponseDto.class)) .collect(Collectors.toList()); } @Autowired  NewsSubscriberServiceImpl(NewsSubscriberRepo newsSubscriberRepo, ModelMapper modelMapper); @Transactional @Override NewsSubscriberRequestDto save(NewsSubscriberRequestDto dto); Long unsubscribe(String email, String unsubscribeToken); @Override List<NewsSubscriberResponseDto> findAll(); }
NewsSubscriberServiceImpl implements NewsSubscriberService { @Override public List<NewsSubscriberResponseDto> findAll() { return newsSubscriberRepo.findAll().stream() .map(el -> modelMapper.map(el, NewsSubscriberResponseDto.class)) .collect(Collectors.toList()); } @Autowired  NewsSubscriberServiceImpl(NewsSubscriberRepo newsSubscriberRepo, ModelMapper modelMapper); @Transactional @Override NewsSubscriberRequestDto save(NewsSubscriberRequestDto dto); Long unsubscribe(String email, String unsubscribeToken); @Override List<NewsSubscriberResponseDto> findAll();  }