@Test public void postsGithubComment_lessThan2CommentsPresent() { final RequestClaimedEvent event = RequestClaimedEvent.builder() .blockchainEventId(1324354L) .requestDto(RequestDtoMother.freeCodeCampNoUserStories()) .claimDto(mock(ClaimDto.class)) .solver(SOLVER) .timestamp(LocalDateTime.now()) .build(); final RequestDto request = event.getRequestDto(); final IssueInformationDto issueInformation = request.getIssueInformation(); final ClaimDto claim = event.getClaimDto(); final ArgumentCaptor<CreateGithubComment> createGithubCommentArgumentCaptor = ArgumentCaptor.forClass(CreateGithubComment.class); final List<GithubIssueCommentsResult> existingComments = Arrays.asList(createCommentFromGithubUserMock(0)); when(githubGateway.getCommentsForIssue(issueInformation.getOwner(), issueInformation.getRepo(), issueInformation.getNumber())).thenReturn(existingComments); when(githubScraper.fetchGithubIssue(issueInformation.getOwner(), issueInformation.getRepo(), issueInformation.getNumber())).thenReturn(GithubIssue.builder().solver(SOLVER).build()); when(githubCommentFactory.createClosedComment(request.getId(), SOLVER, claim.getTransactionHash())).thenReturn(EXPECTED_MESSAGE); handler.createGithubCommentOnRequestClaimed(event); final InOrder inOrder = inOrder(githubGateway); inOrder.verify(githubGateway).evictCommentsForIssue(issueInformation.getOwner(), issueInformation.getRepo(), issueInformation.getNumber()); inOrder.verify(githubGateway).getCommentsForIssue(issueInformation.getOwner(), issueInformation.getRepo(), issueInformation.getNumber()); inOrder.verify(githubGateway).createCommentOnIssue(eq(issueInformation.getOwner()), eq(issueInformation.getRepo()), eq(issueInformation.getNumber()), createGithubCommentArgumentCaptor.capture()); assertThat(createGithubCommentArgumentCaptor.getValue().getBody()).isEqualTo(EXPECTED_MESSAGE); }
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void createGithubCommentOnRequestClaimed(final RequestClaimedEvent event) { if (addComment) { final RequestDto request = event.getRequestDto(); final IssueInformationDto issueInformation = request.getIssueInformation(); final ClaimDto claim = event.getClaimDto(); if (issueInformation.getPlatform() == Platform.GITHUB) { placeComment(request, issueInformation, claim); } } }
CreateGithubCommentOnClosedHandler { @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void createGithubCommentOnRequestClaimed(final RequestClaimedEvent event) { if (addComment) { final RequestDto request = event.getRequestDto(); final IssueInformationDto issueInformation = request.getIssueInformation(); final ClaimDto claim = event.getClaimDto(); if (issueInformation.getPlatform() == Platform.GITHUB) { placeComment(request, issueInformation, claim); } } } }
CreateGithubCommentOnClosedHandler { @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void createGithubCommentOnRequestClaimed(final RequestClaimedEvent event) { if (addComment) { final RequestDto request = event.getRequestDto(); final IssueInformationDto issueInformation = request.getIssueInformation(); final ClaimDto claim = event.getClaimDto(); if (issueInformation.getPlatform() == Platform.GITHUB) { placeComment(request, issueInformation, claim); } } } CreateGithubCommentOnClosedHandler(final GithubGateway githubGateway,
                                              final GithubScraper githubScraper,
                                              final GithubCommentFactory githubCommentFactory,
                                              @Value("${github.add-comments:false}") final Boolean addComment,
                                              @Value("${feign.client.github.username:fundrequest-notifier}") final String githubUser); }
CreateGithubCommentOnClosedHandler { @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void createGithubCommentOnRequestClaimed(final RequestClaimedEvent event) { if (addComment) { final RequestDto request = event.getRequestDto(); final IssueInformationDto issueInformation = request.getIssueInformation(); final ClaimDto claim = event.getClaimDto(); if (issueInformation.getPlatform() == Platform.GITHUB) { placeComment(request, issueInformation, claim); } } } CreateGithubCommentOnClosedHandler(final GithubGateway githubGateway,
                                              final GithubScraper githubScraper,
                                              final GithubCommentFactory githubCommentFactory,
                                              @Value("${github.add-comments:false}") final Boolean addComment,
                                              @Value("${feign.client.github.username:fundrequest-notifier}") final String githubUser); @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) void createGithubCommentOnRequestClaimed(final RequestClaimedEvent event); }
CreateGithubCommentOnClosedHandler { @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void createGithubCommentOnRequestClaimed(final RequestClaimedEvent event) { if (addComment) { final RequestDto request = event.getRequestDto(); final IssueInformationDto issueInformation = request.getIssueInformation(); final ClaimDto claim = event.getClaimDto(); if (issueInformation.getPlatform() == Platform.GITHUB) { placeComment(request, issueInformation, claim); } } } CreateGithubCommentOnClosedHandler(final GithubGateway githubGateway,
                                              final GithubScraper githubScraper,
                                              final GithubCommentFactory githubCommentFactory,
                                              @Value("${github.add-comments:false}") final Boolean addComment,
                                              @Value("${feign.client.github.username:fundrequest-notifier}") final String githubUser); @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) void createGithubCommentOnRequestClaimed(final RequestClaimedEvent event);  }