@Test public void onClaimed() { long requestId = 3124L; final RequestDto requestDto = RequestDtoMother.fundRequestArea51(); requestDto.setId(requestId); final RequestClaim requestClaim1 = RequestClaim.builder().status(ClaimRequestStatus.PENDING).build(); final RequestClaim requestClaim2 = RequestClaim.builder().status(ClaimRequestStatus.PENDING).build(); when(requestClaimRepository.findByRequestId(requestId)).thenReturn(Arrays.asList(requestClaim1, requestClaim2)); claimService.onClaimed(RequestClaimedEvent.builder() .blockchainEventId(324L) .requestDto(requestDto) .build()); assertThat(requestClaim1.getStatus()).isEqualTo(PROCESSED); assertThat(requestClaim2.getStatus()).isEqualTo(PROCESSED); verify(requestClaimRepository).save(requestClaim1); verify(requestClaimRepository).save(requestClaim2); }
@EventListener public void onClaimed(final RequestClaimedEvent claimedEvent) { requestClaimRepository.findByRequestId(claimedEvent.getRequestDto().getId()) .forEach(requestClaim -> { requestClaim.setStatus(ClaimRequestStatus.PROCESSED); requestClaimRepository.save(requestClaim); }); }
ClaimServiceImpl implements ClaimService { @EventListener public void onClaimed(final RequestClaimedEvent claimedEvent) { requestClaimRepository.findByRequestId(claimedEvent.getRequestDto().getId()) .forEach(requestClaim -> { requestClaim.setStatus(ClaimRequestStatus.PROCESSED); requestClaimRepository.save(requestClaim); }); } }
ClaimServiceImpl implements ClaimService { @EventListener public void onClaimed(final RequestClaimedEvent claimedEvent) { requestClaimRepository.findByRequestId(claimedEvent.getRequestDto().getId()) .forEach(requestClaim -> { requestClaim.setStatus(ClaimRequestStatus.PROCESSED); requestClaimRepository.save(requestClaim); }); } 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 { @EventListener public void onClaimed(final RequestClaimedEvent claimedEvent) { requestClaimRepository.findByRequestId(claimedEvent.getRequestDto().getId()) .forEach(requestClaim -> { requestClaim.setStatus(ClaimRequestStatus.PROCESSED); requestClaimRepository.save(requestClaim); }); } 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 { @EventListener public void onClaimed(final RequestClaimedEvent claimedEvent) { requestClaimRepository.findByRequestId(claimedEvent.getRequestDto().getId()) .forEach(requestClaim -> { requestClaim.setStatus(ClaimRequestStatus.PROCESSED); requestClaimRepository.save(requestClaim); }); } 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);  }