Search in sources :

Example 1 with PARAM_HIDE_COMMENTS

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()));
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) FACETS(org.sonar.api.server.ws.WebService.Param.FACETS) BUG(org.sonarqube.ws.Common.RuleType.BUG) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PARAM_ASSIGNEES(org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEES) IssueWorkflow(org.sonar.server.issue.workflow.IssueWorkflow) Random(java.util.Random) DbSession(org.sonar.db.DbSession) PARAM_BRANCH(org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BRANCH) GroupPermissionDto(org.sonar.db.permission.GroupPermissionDto) FunctionExecutor(org.sonar.server.issue.workflow.FunctionExecutor) Collections.singletonList(java.util.Collections.singletonList) SearchWsResponse(org.sonarqube.ws.Issues.SearchWsResponse) Languages(org.sonar.api.resources.Languages) DbIssues(org.sonar.db.protobuf.DbIssues) WebService(org.sonar.api.server.ws.WebService) IssueIndex(org.sonar.server.issue.index.IssueIndex) IssueIteratorFactory(org.sonar.server.issue.index.IssueIteratorFactory) UserSessionRule.standalone(org.sonar.server.tester.UserSessionRule.standalone) Arrays.asList(java.util.Arrays.asList) AvatarResolverImpl(org.sonar.server.issue.AvatarResolverImpl) ComponentTesting(org.sonar.db.component.ComponentTesting) DateUtils.formatDateTime(org.sonar.api.utils.DateUtils.formatDateTime) PARAM_COMPONENT_KEYS(org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS) PARAM_SINCE_LEAK_PERIOD(org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SINCE_LEAK_PERIOD) DbTester(org.sonar.db.DbTester) IssueChangeDto(org.sonar.db.issue.IssueChangeDto) PULL_REQUEST_SEPARATOR(org.sonar.db.component.ComponentDto.PULL_REQUEST_SEPARATOR) RuleTesting(org.sonar.db.rule.RuleTesting) PermissionIndexer(org.sonar.server.permission.index.PermissionIndexer) System2(org.sonar.api.utils.System2) Issue(org.sonarqube.ws.Issues.Issue) RuleMetadataDto(org.sonar.db.rule.RuleMetadataDto) DateUtils.parseDate(org.sonar.api.utils.DateUtils.parseDate) Collectors(java.util.stream.Collectors) PARAM_CREATED_AFTER(org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AFTER) Sets(com.google.common.collect.Sets) Severity(org.sonarqube.ws.Common.Severity) Common(org.sonarqube.ws.Common) PARAM_HIDE_COMMENTS(org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_HIDE_COMMENTS) DbClient(org.sonar.db.DbClient) List(java.util.List) ComponentDto(org.sonar.db.component.ComponentDto) SearchOptions(org.sonar.server.es.SearchOptions) Stream(java.util.stream.Stream) CODE_SMELL(org.sonar.api.rules.RuleType.CODE_SMELL) IntStream(java.util.stream.IntStream) ISSUE_ADMIN(org.sonar.api.web.UserRole.ISSUE_ADMIN) IssueDto(org.sonar.db.issue.IssueDto) RuleDefinitionDto(org.sonar.db.rule.RuleDefinitionDto) UserDto(org.sonar.db.user.UserDto) EsTester(org.sonar.server.es.EsTester) ComponentTesting.newFileDto(org.sonar.db.component.ComponentTesting.newFileDto) RuleStatus(org.sonar.api.rule.RuleStatus) PARAM_RULES(org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RULES) STATUS_RESOLVED(org.sonar.api.issue.Issue.STATUS_RESOLVED) JsonParser(com.google.gson.JsonParser) RuleType(org.sonar.api.rules.RuleType) JsonElement(com.google.gson.JsonElement) IssueFieldsSetter(org.sonar.server.issue.IssueFieldsSetter) PARAM_IN_NEW_CODE_PERIOD(org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD) Uuids(org.sonar.core.util.Uuids) TransitionService(org.sonar.server.issue.TransitionService) WebAuthorizationTypeSupport(org.sonar.server.permission.index.WebAuthorizationTypeSupport) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) PARAM_ADDITIONAL_FIELDS(org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ADDITIONAL_FIELDS) TextRangeResponseFormatter(org.sonar.server.issue.TextRangeResponseFormatter) IssueQueryFactory(org.sonar.server.issue.index.IssueQueryFactory) RESOLUTION_FIXED(org.sonar.api.issue.Issue.RESOLUTION_FIXED) Before(org.junit.Before) UserSessionRule(org.sonar.server.tester.UserSessionRule) BranchType(org.sonar.db.component.BranchType) PARAM_PULL_REQUEST(org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PULL_REQUEST) Durations(org.sonar.api.utils.Durations) TestRequest(org.sonar.server.ws.TestRequest) Test(org.junit.Test) WsActionTester(org.sonar.server.ws.WsActionTester) DbCommons(org.sonar.db.protobuf.DbCommons) IssueTesting.newDto(org.sonar.db.issue.IssueTesting.newDto) Consumer(java.util.function.Consumer) SECURITY_HOTSPOT_VALUE(org.sonarqube.ws.Common.RuleType.SECURITY_HOTSPOT_VALUE) Rule(org.junit.Rule) UNIT_TEST_FILE(org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE) IssueIndexSyncProgressChecker(org.sonar.server.issue.index.IssueIndexSyncProgressChecker) RuleDto(org.sonar.db.rule.RuleDto) DateUtils.parseDateTime(org.sonar.api.utils.DateUtils.parseDateTime) VULNERABILITY(org.sonarqube.ws.Common.RuleType.VULNERABILITY) Clock(java.time.Clock) Tuple.tuple(org.assertj.core.groups.Tuple.tuple) SnapshotDto(org.sonar.db.component.SnapshotDto) Collections(java.util.Collections) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) IssueQuery(org.sonar.server.issue.index.IssueQuery) TestResponse(org.sonar.server.ws.TestResponse) UserDto(org.sonar.db.user.UserDto) ComponentDto(org.sonar.db.component.ComponentDto) RuleDefinitionDto(org.sonar.db.rule.RuleDefinitionDto) IssueDto(org.sonar.db.issue.IssueDto) SearchWsResponse(org.sonarqube.ws.Issues.SearchWsResponse) Test(org.junit.Test)

Aggregations

Sets (com.google.common.collect.Sets)1 JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1 Clock (java.time.Clock)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Random (java.util.Random)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Stream (java.util.stream.Stream)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 Tuple.tuple (org.assertj.core.groups.Tuple.tuple)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1