diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClient.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClient.java index 4b40d700..2f321896 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClient.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClient.java @@ -133,11 +133,12 @@ private void postSummaryComment(String graphqlUrl, Map headers, GetRepository.PullRequest pullRequest = getPullRequest(graphqlUrl, headers, pullRequestKey); String pullRequestId = pullRequest.getId(); + String projectCommentMarker = String.format("**Project ID:** %s%n", projectId); getComments(pullRequest, graphqlUrl, headers, pullRequestKey).stream() .filter(c -> "Bot".equalsIgnoreCase(c.getAuthor().getType()) && login.equalsIgnoreCase(c.getAuthor().getLogin())) .filter(c -> !c.isMinimized()) - .filter(c -> c.getBody().contains(String.format("**Project ID:** %s\r\n", projectId))) + .filter(c -> c.getBody().contains(projectCommentMarker)) .map(Comments.CommentNode::getId) .forEach(commentId -> this.minimizeComment(graphqlUrl, headers, commentId)); diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClientTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClientTest.java index 5699ccaa..99e5d422 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClientTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClientTest.java @@ -148,6 +148,7 @@ void verifyCheckRunSubmitsCorrectAnnotations() throws IOException { ArgumentCaptor getViewer = ArgumentCaptor.forClass(GraphQLRequestEntity.class); when(graphQLTemplate.query(getViewer.capture(), eq(Viewer.class))).thenReturn(viewerResponseEntity); + String bodyString = objectMapper.writeValueAsString("**Project ID:** project-key-test" + System.lineSeparator()); GraphQLResponseEntity getPullRequestResponseEntity = objectMapper.readValue("{" + "\"response\": " + @@ -159,7 +160,7 @@ void verifyCheckRunSubmitsCorrectAnnotations() throws IOException { " {" + " \"id\": \"MDEyOklzc3VlQ29tbWVudDE1MDE3\"," + " \"isMinimized\": false," + - " \"body\": \"**Project ID:** project-key-test\\r\\n\"," + + " \"body\": " + bodyString + "," + " \"author\": {" + " \"__typename\": \"Bot\"," + " \"login\": \"test-sonar\"" +