@SuppressWarnings("ConstantConditions")
    private Queue<Comment> getComments() {
        LOG.debug("Start: Jira NewCommentsConsumer: retrieving issue comments. Last comment id: {}", lastCommentId);
        IssueRestClient client = getEndpoint().getClient().getIssueClient();

        LinkedList<Comment> newComments = getIssues().stream()
                .map(issue -> client.getIssue(issue.getKey()).claim())
                .flatMap(issue -> StreamSupport.stream(issue.getComments().spliterator(), false))
                .filter(comment -> comment.getId() > lastCommentId)
                .collect(Collectors.toCollection(LinkedList::new));

        Collections.reverse(newComments);

        lastCommentId = newComments.stream().mapToLong(Comment::getId).max().orElse(lastCommentId);
        LOG.debug("End: Jira NewCommentsConsumer: retrieving issue comments. {} new comments since last run.",
                newComments.size());
        return newComments;
    }
@Test
    public void singleIssueCommentsTest() throws Exception {
        Issue issueWithComments = createIssueWithComments(11L, 3000);
        Issue issueWithNoComments = createIssue(51L);
        List<Issue> newIssues = List.of(issueWithComments, issueWithNoComments);

        SearchResult result = new SearchResult(0, 50, 2, newIssues);
        when(searchRestClient.searchJql(any(), any(), any(), any())).thenReturn(Promises.promise(result));
        newIssues.forEach(issue -> when(issueRestClient.getIssue(eq(issue.getKey())))
                .then(inv -> Promises.promise(issue)));

        //clearInvocations(issueRestClient);
        List<Comment> comments = new ArrayList<>();
        newIssues.forEach(issue -> issue.getComments().forEach(comments::add));
        // reverse the order, from oldest comment to recent
        Collections.reverse(comments);
        // expect 3000 comments
        mockResult.expectedBodiesReceived(comments);
        mockResult.assertIsSatisfied();
    }