import java.io.IOException;
import java.text.SimpleDateFormat;
-import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang.time.DateUtils;
import org.junit.Test;
import org.sonar.wsclient.base.HttpException;
import org.sonar.wsclient.base.Paging;
-import org.sonar.wsclient.component.Component;
import org.sonar.wsclient.issue.Issue;
import org.sonar.wsclient.issue.IssueQuery;
import org.sonar.wsclient.issue.Issues;
assertThat(search(IssueQuery.create().createdAt(toDate("2010-01-01"))).size()).isEqualTo(0);
}
- @Test
- public void components_contain_sub_project_id_and_project_id_informations() {
- String fileKey = "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo";
-
- Issues issues = issueClient().find(IssueQuery.create().components(fileKey));
- assertThat(issues.list()).isNotEmpty();
-
- Collection<Component> components = issues.components();
-
- Component project = findComponent(components, "com.sonarsource.it.samples:multi-modules-sample");
- assertThat(project.subProjectId()).isNull();
- assertThat(project.projectId()).isNull();
-
- Component subModuleA1 = findComponent(components, "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1");
- assertThat(subModuleA1.subProjectId()).isEqualTo(project.id());
- assertThat(subModuleA1.projectId()).isEqualTo(project.id());
-
- Component file = findComponent(components, fileKey);
- assertThat(file.subProjectId()).isNotNull();
- assertThat(file.projectId()).isNotNull();
-
- Issue issue = issues.list().get(0);
- assertThat(issues.component(issue)).isNotNull();
- assertThat(issues.component(issue).subProjectId()).isEqualTo(subModuleA1.id());
- assertThat(issues.component(issue).projectId()).isEqualTo(project.id());
- }
-
@Test
public void return_issue_type() throws Exception {
List<org.sonarqube.ws.Issues.Issue> issues = searchByRuleKey("xoo:OneBugIssuePerLine");
return newAdminWsClient(ORCHESTRATOR).issues().search(request);
}
- private static Component findComponent(Collection<Component> components, String key) {
- return components.stream()
- .filter(input -> key.equals(input.key()))
- .findFirst()
- .orElseThrow(() -> new IllegalStateException("Component key not found: " + key));
- }
-
}
private final OperationResponseWriter responseWriter;
public AddCommentAction(System2 system2, UserSession userSession, DbClient dbClient, IssueFinder issueFinder, IssueUpdater issueUpdater, IssueFieldsSetter issueFieldsSetter,
- OperationResponseWriter responseWriter) {
+ OperationResponseWriter responseWriter) {
this.system2 = system2;
this.userSession = userSession;
this.dbClient = dbClient;
.setDescription("Add a comment.<br/>" +
"Requires authentication and the following permission: 'Browse' on the project of the specified issue.")
.setSince("3.6")
- .setChangelog(new Change("6.3", "the response returns the issue with all its details"))
+ .setChangelog(
+ new Change("6.3", "the response returns the issue with all its details"),
+ new Change("6.5", "the database ids of the components are removed from the response"))
.setHandler(this)
.setResponseExample(Resources.getResource(this.getClass(), "add_comment-example.json"))
.setPost(true);
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.BooleanUtils;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
WebService.NewAction action = controller.createAction(ACTION_ASSIGN)
.setDescription("Assign/Unassign an issue. Requires authentication and Browse permission on project")
.setSince("3.6")
+ .setChangelog(
+ new Change("6.5", "the database ids of the components are removed from the response"),
+ new Change("6.5", "the response field components.uuid is deprecated. Use components.key instead."))
.setHandler(this)
.setResponseExample(Resources.getResource(this.getClass(), "assign-example.json"))
.setPost(true);
import com.google.common.io.Resources;
import java.util.Date;
import org.sonar.api.issue.DefaultTransitions;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
.setDescription("Do workflow transition on an issue. Requires authentication and Browse permission on project.<br/>" +
"The transitions '" + DefaultTransitions.WONT_FIX + "' and '" + DefaultTransitions.FALSE_POSITIVE + "' require the permission 'Administer Issues'.")
.setSince("3.6")
+ .setChangelog(
+ new Change("6.5", "the database ids of the components are removed from the response"),
+ new Change("6.5", "the response field components.uuid is deprecated. Use components.key instead."))
.setHandler(this)
.setResponseExample(Resources.getResource(this.getClass(), "do_transition-example.json"))
.setPost(true);
ComponentDto component = data.getComponentByUuid(dto.getComponentUuid());
issueBuilder.setOrganization(data.getOrganizationKey(component.getOrganizationUuid()));
issueBuilder.setComponent(component.key());
- // Only used for the compatibility with the Java WS Client <= 4.4 used by Eclipse
- issueBuilder.setComponentId(component.getId());
ComponentDto project = data.getComponentByUuid(dto.getProjectUuid());
if (project != null) {
issueBuilder.setProject(project.getKey());
setNullable(dto.getIssueCloseDate(), issueBuilder::setCloseDate, DateUtils::formatDateTime);
}
- private void completeIssueLocations(IssueDto dto, Issue.Builder issueBuilder) {
+ private static void completeIssueLocations(IssueDto dto, Issue.Builder issueBuilder) {
DbIssues.Locations locations = dto.parseLocations();
if (locations == null) {
return;
String uuid = dto.uuid();
Component.Builder builder = Component.newBuilder()
.setOrganization(data.getOrganizationKey(dto.getOrganizationUuid()))
- .setId(dto.getId())
.setKey(dto.key())
.setUuid(uuid)
.setQualifier(dto.qualifier())
builder.setPath(path);
}
- // On a root project, parentProjectId is null but projectId is equal to itself, which make no sense.
- if (!uuid.equals(dto.getRootUuid())) {
- ComponentDto project = data.getComponentByUuid(dto.projectUuid());
- setNullable(project, builder::setProjectId, ComponentDto::getId);
-
- ComponentDto subProject = data.getComponentByUuid(dto.getRootUuid());
- setNullable(subProject, builder::setSubProjectId, ComponentDto::getId);
- }
result.add(builder.build());
}
return result;
import com.google.common.io.Resources;
import java.util.Date;
import org.sonar.api.rule.Severity;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
" <li>'Administer Issues' rights on project of the specified issue</li>" +
"</ul>")
.setSince("3.6")
+ .setChangelog(
+ new Change("6.5", "the database ids of the components are removed from the response"),
+ new Change("6.5", "the response field components.uuid is deprecated. Use components.key instead."))
.setHandler(this)
.setResponseExample(Resources.getResource(this.getClass(), "set_severity-example.json"))
.setPost(true);
.setSince("5.1")
.setDescription("Set tags on an issue. <br/>" +
"Requires authentication and Browse permission on project")
- .setChangelog(new Change("6.4", "response contains issue information instead of list of tags"))
+ .setChangelog(
+ new Change("6.5", "the database ids of the components are removed from the response"),
+ new Change("6.5", "the response field components.uuid is deprecated. Use components.key instead."),
+ new Change("6.4", "response contains issue information instead of list of tags"))
.setResponseExample(Resources.getResource(this.getClass(), "set_tags-example.json"))
.setHandler(this);
action.createParam(PARAM_ISSUE)
import com.google.common.io.Resources;
import java.util.Date;
import org.sonar.api.rules.RuleType;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
" <li>'Administer Issues' rights on project of the specified issue</li>" +
"</ul>")
.setSince("5.5")
+ .setChangelog(
+ new Change("6.5", "the database ids of the components are removed from the response"),
+ new Change("6.5", "the response field components.uuid is deprecated. Use components.key instead."))
.setHandler(this)
.setResponseExample(Resources.getResource(this.getClass(), "set_type-example.json"))
.setPost(true);
"rule": "squid:S2301",
"severity": "MAJOR",
"component": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "componentId": 87163,
"project": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"line": 78,
"textRange": {
},
"components": [
{
- "id": 87163,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
"uuid": "AVfTIlxMwczdZ2UaLhnt",
"enabled": true,
"qualifier": "FIL",
"name": "ServerIssueUpdater.java",
"longName": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "projectId": 23498,
- "subProjectId": 23498
+ "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java"
},
{
"id": 23498,
"rule": "squid:S2301",
"severity": "MAJOR",
"component": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "componentId": 87163,
"project": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"line": 78,
"textRange": {
},
"components": [
{
- "id": 87163,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
"uuid": "AVfTIlxMwczdZ2UaLhnt",
"enabled": true,
"qualifier": "FIL",
"name": "ServerIssueUpdater.java",
"longName": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "projectId": 23498,
- "subProjectId": 23498
+ "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java"
},
{
- "id": 23498,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"uuid": "8b745480-b598-4e34-af4a-cb2de1808e50",
"enabled": true,
},
"components": [
{
- "id": 87163,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
"uuid": "AVfTIlxMwczdZ2UaLhnt",
"enabled": true,
"qualifier": "FIL",
"name": "ServerIssueUpdater.java",
"longName": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "projectId": 23498,
- "subProjectId": 23498
+ "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java"
},
{
- "id": 23498,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"uuid": "8b745480-b598-4e34-af4a-cb2de1808e50",
"enabled": true,
"rule": "squid:S2301",
"severity": "MAJOR",
"component": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "componentId": 87163,
"project": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"line": 78,
"textRange": {
},
"components": [
{
- "id": 87163,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
"uuid": "AVfTIlxMwczdZ2UaLhnt",
"enabled": true,
"qualifier": "FIL",
"name": "ServerIssueUpdater.java",
"longName": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "projectId": 23498,
- "subProjectId": 23498
+ "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java"
},
{
- "id": 23498,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"uuid": "8b745480-b598-4e34-af4a-cb2de1808e50",
"enabled": true,
},
"components": [
{
- "id": 87163,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
"uuid": "AVfTIlxMwczdZ2UaLhnt",
"enabled": true,
"qualifier": "FIL",
"name": "ServerIssueUpdater.java",
"longName": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "projectId": 23498,
- "subProjectId": 23498
+ "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java"
},
{
- "id": 23498,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"uuid": "8b745480-b598-4e34-af4a-cb2de1808e50",
"enabled": true,
"rule": "squid:S2301",
"severity": "MAJOR",
"component": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "componentId": 87163,
"project": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"line": 78,
"textRange": {
},
"components": [
{
- "id": 87163,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
"uuid": "AVfTIlxMwczdZ2UaLhnt",
"enabled": true,
"qualifier": "FIL",
"name": "ServerIssueUpdater.java",
"longName": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "projectId": 23498,
- "subProjectId": 23498
+ "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java"
},
{
- "id": 23498,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"uuid": "8b745480-b598-4e34-af4a-cb2de1808e50",
"enabled": true,
"rule": "squid:S2301",
"severity": "MAJOR",
"component": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "componentId": 87163,
"project": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"line": 78,
"textRange": {
},
"components": [
{
- "id": 87163,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
"uuid": "AVfTIlxMwczdZ2UaLhnt",
"enabled": true,
"subProjectId": 23498
},
{
- "id": 23498,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"uuid": "8b745480-b598-4e34-af4a-cb2de1808e50",
"enabled": true,
"rule": "squid:S2301",
"severity": "MAJOR",
"component": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "componentId": 87163,
"project": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"line": 78,
"textRange": {
},
"components": [
{
- "id": 87163,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij:src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
"uuid": "AVfTIlxMwczdZ2UaLhnt",
"enabled": true,
"qualifier": "FIL",
"name": "ServerIssueUpdater.java",
"longName": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java",
- "projectId": 23498,
- "subProjectId": 23498
+ "path": "src/main/java/org/sonarlint/intellij/core/ServerIssueUpdater.java"
},
{
- "id": 23498,
"key": "org.sonarsource.sonarlint.intellij:sonarlint-intellij",
"uuid": "8b745480-b598-4e34-af4a-cb2de1808e50",
"enabled": true,
result.assertJson(this.getClass(), "issue_on_removed_file.json");
}
- @Test
- public void issue_contains_component_id_for_eclipse() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
- indexPermissionsOf(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
- IssueDto issue = IssueTesting.newDto(newRule(), file, project);
- db.issueDao().insert(session, issue);
- session.commit();
- IssueIndexer r = tester.get(IssueIndexer.class);
- r.indexOnStartup(r.getIndexTypes());
-
- WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).execute();
- assertThat(result.outputAsString()).contains("\"componentId\":" + file.getId() + ",");
- }
-
@Test
public void apply_paging_with_one_component() throws Exception {
RuleDto rule = newRule();
repeated sonarqube.ws.commons.Rule rules = 3;
repeated Users.User users = 4;
// Deprecated since 5.5, action plan has been removed
- repeated ActionPlan actiunusedActionPlansonPlans = 5;
+ repeated ActionPlan unusedActionPlans = 5;
}
message Issue {
optional string rule = 2;
optional sonarqube.ws.commons.Severity severity = 3;
optional string component = 4;
- optional int64 componentId = 5;
+ optional int64 unusedComponentId = 5;
optional string project = 6;
optional string subProject = 7;
optional int32 line = 8;
message Component {
optional string organization = 11;
- optional int64 id = 1;
+ optional int64 deprecatedId = 1;
optional string key = 2;
optional string uuid = 3;
optional bool enabled = 4;
optional string name = 6;
optional string longName = 7;
optional string path = 8;
- optional int64 projectId = 9;
- optional int64 subProjectId = 10;
+ optional int64 unusedProjectId = 9;
+ optional int64 unusedSubProjectId = 10;
}
// Response of GET api/issues/changelog