@Test public void getClaimedBy() { final long requestId = 567L; final List<Claim> claims = new ArrayList<>(); final List<ClaimDto> claimDtos = new ArrayList<>(); final Principal principal = mock(Principal.class); final ClaimsByTransactionAggregate claimsByTransactionAggregate = mock(ClaimsByTransactionAggregate.class); when(principal.getName()).thenReturn("hfgj"); when(claimRepository.findByRequestId(requestId)).thenReturn(claims); when(mappers.mapList(eq(Claim.class), eq(ClaimDto.class), same(claims))).thenReturn(claimDtos); when(claimDtoAggregator.aggregateClaims(same(claimDtos))).thenReturn(claimsByTransactionAggregate); final ClaimsByTransactionAggregate result = claimService.getAggregatedClaimsForRequest(requestId); assertThat(result).isSameAs(claimsByTransactionAggregate); }
@Override @Transactional(readOnly = true) public ClaimsByTransactionAggregate getAggregatedClaimsForRequest(final long requestId) { return claimDtoAggregator.aggregateClaims(mappers.mapList(Claim.class, ClaimDto.class, claimRepository.findByRequestId(requestId))); }
ClaimServiceImpl implements ClaimService { @Override @Transactional(readOnly = true) public ClaimsByTransactionAggregate getAggregatedClaimsForRequest(final long requestId) { return claimDtoAggregator.aggregateClaims(mappers.mapList(Claim.class, ClaimDto.class, claimRepository.findByRequestId(requestId))); } }
ClaimServiceImpl implements ClaimService { @Override @Transactional(readOnly = true) public ClaimsByTransactionAggregate getAggregatedClaimsForRequest(final long requestId) { return claimDtoAggregator.aggregateClaims(mappers.mapList(Claim.class, ClaimDto.class, claimRepository.findByRequestId(requestId))); } ClaimServiceImpl(final RequestRepository requestRepository,
                            final ClaimRepository claimRepository,
                            final RequestClaimRepository requestClaimRepository,
                            final GithubClaimResolver githubClaimResolver,
                            final Mappers mappers,
                            final ClaimDtoAggregator claimDtoAggregator,
                            final ApplicationEventPublisher eventPublisher); }
ClaimServiceImpl implements ClaimService { @Override @Transactional(readOnly = true) public ClaimsByTransactionAggregate getAggregatedClaimsForRequest(final long requestId) { return claimDtoAggregator.aggregateClaims(mappers.mapList(Claim.class, ClaimDto.class, claimRepository.findByRequestId(requestId))); } ClaimServiceImpl(final RequestRepository requestRepository,
                            final ClaimRepository claimRepository,
                            final RequestClaimRepository requestClaimRepository,
                            final GithubClaimResolver githubClaimResolver,
                            final Mappers mappers,
                            final ClaimDtoAggregator claimDtoAggregator,
                            final ApplicationEventPublisher eventPublisher); @Override @Transactional(readOnly = true) Optional<ClaimDto> findOne(final Long id); @Transactional @Override void claim(Principal user, UserClaimRequest userClaimRequest); @Override @Transactional(readOnly = true) ClaimsByTransactionAggregate getAggregatedClaimsForRequest(final long requestId); @EventListener void onClaimed(final RequestClaimedEvent claimedEvent); }
ClaimServiceImpl implements ClaimService { @Override @Transactional(readOnly = true) public ClaimsByTransactionAggregate getAggregatedClaimsForRequest(final long requestId) { return claimDtoAggregator.aggregateClaims(mappers.mapList(Claim.class, ClaimDto.class, claimRepository.findByRequestId(requestId))); } ClaimServiceImpl(final RequestRepository requestRepository,
                            final ClaimRepository claimRepository,
                            final RequestClaimRepository requestClaimRepository,
                            final GithubClaimResolver githubClaimResolver,
                            final Mappers mappers,
                            final ClaimDtoAggregator claimDtoAggregator,
                            final ApplicationEventPublisher eventPublisher); @Override @Transactional(readOnly = true) Optional<ClaimDto> findOne(final Long id); @Transactional @Override void claim(Principal user, UserClaimRequest userClaimRequest); @Override @Transactional(readOnly = true) ClaimsByTransactionAggregate getAggregatedClaimsForRequest(final long requestId); @EventListener void onClaimed(final RequestClaimedEvent claimedEvent);  }