### Question:
CreateGithubCommentOnFundHandler { @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void createGithubCommentOnRequestFunded(final RequestFundedEvent event) { if (addComment) { final IssueInformationDto issueInformation = requestService.findRequest(event.getRequestId()).getIssueInformation(); if (issueInformation.getPlatform() == Platform.GITHUB && !isCommentAlreadyPresent(issueInformation.getNumber(), issueInformation.getOwner(), issueInformation.getRepo())) { placeComment(event.getRequestId(), issueInformation.getNumber(), issueInformation.getOwner(), issueInformation.getRepo()); } } } CreateGithubCommentOnFundHandler(final GithubGateway githubGateway,
                                            final GithubCommentFactory githubCommentFactory,
                                            final RequestService requestService,
                                            @Value("${github.add-comments:false}") final Boolean addComment,
                                            @Value("${feign.client.github.username:fundrequest-notifier}") final String githubUser); @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) void createGithubCommentOnRequestFunded(final RequestFundedEvent event);  }### Answer:
@Test public void ignoresGithubComment() { handler = new CreateGithubCommentOnFundHandler(githubGateway, githubCommentFactory, requestService, false, "fundrequest-notifier"); handler.createGithubCommentOnRequestFunded(createEvent(65478L)); verifyZeroInteractions(githubGateway); }
@Test public void postsGithubComment() { final long requestId = 65478L; final RequestFundedEvent event = createEvent(requestId); final String expectedMessage = "sgdhfjgkh"; final RequestDto requestDto = RequestDtoMother.fundRequestArea51(); final IssueInformationDto issueInformation = requestDto.getIssueInformation(); final ArgumentCaptor<CreateGithubComment> createGithubCommentArgumentCaptor = ArgumentCaptor.forClass(CreateGithubComment.class); when(githubCommentFactory.createFundedComment(requestId, issueInformation.getNumber())).thenReturn(expectedMessage); when(requestService.findRequest(requestId)).thenReturn(requestDto); handler.createGithubCommentOnRequestFunded(event); verify(githubGateway).createCommentOnIssue(eq(issueInformation.getOwner()), eq(issueInformation.getRepo()), eq(issueInformation.getNumber()), createGithubCommentArgumentCaptor.capture()); final CreateGithubComment githubComment = createGithubCommentArgumentCaptor.getValue(); assertThat(githubComment.getBody()).isEqualTo(expectedMessage); }