@Transactional(readOnly = true) @Override public List<FundDto> findAll() { return mappers.mapList(Fund.class, FundDto.class, fundRepository.findAll()); }
@Transactional(readOnly = true) @Override public List<FundDto> findAll(Iterable<Long> ids) { return mappers.mapList(Fund.class, FundDto.class, fundRepository.findAll(ids)); }
@Test public void findAllByIterable() { List<Fund> funds = singletonList(FundMother.fndFundFunderKnown().build()); Set<Long> ids = funds.stream().map(Fund::getId).collect(Collectors.toSet()); when(fundRepository.findAll(ids)).thenReturn(funds); List<FundDto> expecedFunds = singletonList(FundDtoMother.aFundDto().build()); when(mappers.mapList(Fund.class, FundDto.class, funds)).thenReturn(expecedFunds); List<FundDto> result = fundService.findAll(ids); assertThat(result).isEqualTo(expecedFunds); }
@Test public void findAll() { List<Fund> funds = singletonList(FundMother.fndFundFunderKnown().build()); when(fundRepository.findAll()).thenReturn(funds); List<FundDto> expecedFunds = singletonList(FundDtoMother.aFundDto().build()); when(mappers.mapList(Fund.class, FundDto.class, funds)).thenReturn(expecedFunds); List<FundDto> result = fundService.findAll(); assertThat(result).isEqualTo(expecedFunds); }