use of org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_HIDE_COMMENTS in project sonarqube by SonarSource.
the class SearchActionTest method issue_with_comment_hidden.
@Test
public void issue_with_comment_hidden() {
UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
UserDto fabrice = db.users().insertUser(u -> u.setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
ComponentDto project = db.components().insertPublicProject();
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = newIssueRule().getDefinition();
IssueDto issue = db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
dbClient.issueChangeDao().insert(session, new IssueChangeDto().setUuid(Uuids.createFast()).setIssueKey(issue.getKey()).setKey("COMMENT-ABCD").setChangeData("*My comment*").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserUuid(john.getUuid()).setProjectUuid(project.projectUuid()).setCreatedAt(parseDateTime("2014-09-09T12:00:00+0000").getTime()));
dbClient.issueChangeDao().insert(session, new IssueChangeDto().setUuid(Uuids.createFast()).setIssueKey(issue.getKey()).setKey("COMMENT-ABCE").setChangeData("Another comment").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserUuid(fabrice.getUuid()).setProjectUuid(project.projectUuid()).setCreatedAt(parseDateTime("2014-09-10T19:10:03+0000").getTime()));
session.commit();
indexIssues();
userSession.logIn(john);
SearchWsResponse response = ws.newRequest().setParam(PARAM_HIDE_COMMENTS, "true").executeProtobuf(SearchWsResponse.class);
assertThat(response.getIssuesList()).extracting(Issue::getKey, i -> i.getComments().getCommentsList()).containsExactlyInAnyOrder(tuple(issue.getKey(), Collections.emptyList()));
}
Aggregations