diff options
author | Léo Geoffroy <leo.geoffroy@sonarsource.com> | 2023-10-26 11:38:55 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-11-08 20:02:52 +0000 |
commit | 01a084c37da6150434a250334d933ea0443c06a2 (patch) | |
tree | 5c6dc02b83fde8ed3cf5bbf93c9ed77f4bb99359 | |
parent | a2d67088ee25e41e82836b41b5813c5f17f9567a (diff) | |
download | sonarqube-01a084c37da6150434a250334d933ea0443c06a2.tar.gz sonarqube-01a084c37da6150434a250334d933ea0443c06a2.zip |
SONAR-20877 Add new status field to api response
20 files changed, 47 insertions, 4 deletions
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionFacetsIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionFacetsIT.java index 8e59599e085..c4314e0d3e1 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionFacetsIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionFacetsIT.java @@ -265,7 +265,8 @@ public class SearchActionFacetsIT { RuleDto rule = db.rules().insertIssueRule(); db.issues().insertIssue(rule, project, file, i -> i.setAssigneeUuid(user.getUuid()) - .setStatus(ISSUE_STATUSES[random.nextInt(ISSUE_STATUSES.length)]) + .setStatus(Issue.STATUS_RESOLVED) + .setResolution(Issue.RESOLUTION_FIXED) .setType(rule.getType())); }); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AddCommentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AddCommentAction.java index 3be770a150f..3fffcc9d28d 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AddCommentAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AddCommentAction.java @@ -72,6 +72,8 @@ public class AddCommentAction implements IssuesWsAction { "Requires authentication and the following permission: 'Browse' on the project of the specified issue.") .setSince("3.6") .setChangelog( + new Change("10.4", "The response fields 'status' and 'resolution' are deprecated. Please use 'simpleStatus' instead."), + new Change("10.4", "Add 'simpleStatus' field to the response."), new Change("10.2", "Add 'impacts', 'cleanCodeAttribute', 'cleanCodeAttributeCategory' fields to the response"), new Change("9.6", "Response field 'ruleDescriptionContextKey' added"), new Change("8.8", "The response field components.uuid is removed"), diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AssignAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AssignAction.java index 4b10e0c3344..ba1816f1303 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AssignAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AssignAction.java @@ -75,6 +75,8 @@ public class AssignAction implements IssuesWsAction { .setDescription("Assign/Unassign an issue. Requires authentication and Browse permission on project") .setSince("3.6") .setChangelog( + new Change("10.4", "The response fields 'status' and 'resolution' are deprecated. Please use 'simpleStatus' instead."), + new Change("10.4", "Add 'simpleStatus' field to the response."), new Change("10.2", "Add 'impacts', 'cleanCodeAttribute', 'cleanCodeAttributeCategory' fields to the response"), new Change("9.6", "Response field 'ruleDescriptionContextKey' added"), new Change("8.8", "The response field components.uuid is removed"), diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DeleteCommentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DeleteCommentAction.java index 14d2ac2af14..160d3cf3961 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DeleteCommentAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DeleteCommentAction.java @@ -60,6 +60,8 @@ public class DeleteCommentAction implements IssuesWsAction { "Requires authentication and the following permission: 'Browse' on the project of the specified issue.") .setSince("3.6") .setChangelog( + new Change("10.4", "The response fields 'status' and 'resolution' are deprecated. Please use 'simpleStatus' instead."), + new Change("10.4", "Add 'simpleStatus' field to the response."), new Change("10.2", "Add 'impacts', 'cleanCodeAttribute', 'cleanCodeAttributeCategory' fields to the response"), new Change("9.6", "Response field 'ruleDescriptionContextKey' added"), new Change("8.8", "The response field components.uuid is removed"), diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DoTransitionAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DoTransitionAction.java index c9280230499..5ca72bd80c2 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DoTransitionAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DoTransitionAction.java @@ -82,6 +82,8 @@ public class DoTransitionAction implements IssuesWsAction { "The transitions involving security hotspots require the permission 'Administer Security Hotspot'.") .setSince("3.6") .setChangelog( + new Change("10.4", "The response fields 'status' and 'resolution' are deprecated. Please use 'simpleStatus' instead."), + new Change("10.4", "Add 'simpleStatus' field to the response."), new Change("10.2", "Add 'impacts', 'cleanCodeAttribute', 'cleanCodeAttributeCategory' fields to the response"), new Change("9.6", "Response field 'ruleDescriptionContextKey' added"), new Change("8.8", "The response field components.uuid is removed"), diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/EditCommentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/EditCommentAction.java index 603f8914777..62631c84cee 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/EditCommentAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/EditCommentAction.java @@ -66,6 +66,8 @@ public class EditCommentAction implements IssuesWsAction { "Requires authentication and the following permission: 'Browse' on the project of the specified issue.") .setSince("3.6") .setChangelog( + new Change("10.4", "The response fields 'status' and 'resolution' are deprecated. Please use 'simpleStatus' instead."), + new Change("10.4", "Add 'simpleStatus' field to the response."), new Change("10.2", "Add 'impacts', 'cleanCodeAttribute', 'cleanCodeAttributeCategory' fields to the response"), new Change("9.6", "Response field 'ruleDescriptionContextKey' added"), new Change("8.8", "The response field components.uuid is removed"), diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ListAction.java index 229c5b1bf75..bc58ec4cf61 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ListAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ListAction.java @@ -24,6 +24,7 @@ import java.util.EnumSet; import java.util.List; import javax.annotation.Nullable; 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; @@ -90,10 +91,14 @@ public class ListAction implements IssuesWsAction { .setHandler(this) .setInternal(true) .setDescription("List issues. This endpoint is used in degraded mode, when issue indexation is running." + - "<br>Either 'project' or 'component' parameter is required." + - "<br>Total number of issues will be always equal to a page size, as this counting all issues is not supported. " + - "<br>Requires the 'Browse' permission on the specified project. ") + "<br>Either 'project' or 'component' parameter is required." + + "<br>Total number of issues will be always equal to a page size, as this counting all issues is not supported. " + + "<br>Requires the 'Browse' permission on the specified project. ") .setSince("10.2") + .setChangelog( + new Change("10.4", "The response fields 'status' and 'resolution' are deprecated. Please use 'simpleStatus' instead."), + new Change("10.4", "Add 'simpleStatus' field to the response.") + ) .setResponseExample(getClass().getResource("list-example.json")); action.addPagingParams(100, MAX_PAGE_SIZE); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java index be54e0acf3b..0761d1a56fe 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java @@ -37,6 +37,7 @@ import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.Duration; import org.sonar.api.utils.Durations; import org.sonar.api.utils.Paging; +import org.sonar.core.issue.status.SimpleStatus; import org.sonar.db.component.BranchDto; import org.sonar.db.component.BranchType; import org.sonar.db.component.ComponentDto; @@ -204,6 +205,7 @@ public class SearchResponseFormat { ofNullable(data.getUserByUuid(dto.getAssigneeUuid())).ifPresent(assignee -> issueBuilder.setAssignee(assignee.getLogin())); ofNullable(emptyToNull(dto.getResolution())).ifPresent(issueBuilder::setResolution); issueBuilder.setStatus(dto.getStatus()); + issueBuilder.setSimpleStatus(SimpleStatus.of(dto.getStatus(), dto.getResolution()).name()); issueBuilder.setMessage(nullToEmpty(dto.getMessage())); issueBuilder.addAllMessageFormattings(MessageFormattingUtils.dbMessageFormattingToWs(dto.parseMessageFormattings())); issueBuilder.addAllTags(dto.getTags()); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetSeverityAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetSeverityAction.java index f5d81fd87c1..23f6df11188 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetSeverityAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetSeverityAction.java @@ -79,6 +79,8 @@ public class SetSeverityAction implements IssuesWsAction { "</ul>") .setSince("3.6") .setChangelog( + new Change("10.4", "The response fields 'status' and 'resolution' are deprecated. Please use 'simpleStatus' instead."), + new Change("10.4", "Add 'simpleStatus' field to the response."), new Change("10.2", "This endpoint is now deprecated."), new Change("10.2", "Add 'impacts', 'cleanCodeAttribute', 'cleanCodeAttributeCategory' fields to the response"), new Change("9.6", "Response field 'ruleDescriptionContextKey' added"), diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java index d3e8fa064fe..67bd201f9e3 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java @@ -74,6 +74,8 @@ public class SetTagsAction implements IssuesWsAction { .setDescription("Set tags on an issue. <br/>" + "Requires authentication and Browse permission on project") .setChangelog( + new Change("10.4", "The response fields 'status' and 'resolution' are deprecated. Please use 'simpleStatus' instead."), + new Change("10.4", "Add 'simpleStatus' field to the response."), new Change("10.2", "Add 'impacts', 'cleanCodeAttribute', 'cleanCodeAttributeCategory' fields to the response"), new Change("9.6", "Response field 'ruleDescriptionContextKey' added"), new Change("8.8", "The response field components.uuid is removed"), diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java index ea22f193d3b..25382224780 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java @@ -83,6 +83,8 @@ public class SetTypeAction implements IssuesWsAction { "</ul>") .setSince("5.5") .setChangelog( + new Change("10.4", "The response fields 'status' and 'resolution' are deprecated. Please use 'simpleStatus' instead."), + new Change("10.4", "Add 'simpleStatus' field to the response."), new Change("10.2", "Add 'impacts', 'cleanCodeAttribute', 'cleanCodeAttributeCategory' fields to the response"), new Change("10.2", "This endpoint is now deprecated."), new Change("9.6", "Response field 'ruleDescriptionContextKey' added"), diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/add_comment-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/add_comment-example.json index f4fa2b2f815..3b4ab87755f 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/add_comment-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/add_comment-example.json @@ -22,6 +22,7 @@ }, "flows": [], "status": "CONFIRMED", + "simpleStatus": "CONFIRMED", "message": "Provide multiple methods instead of using \"modal\" to determine which action to take.", "effort": "15min", "debt": "15min", diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/assign-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/assign-example.json index 79b0025dadf..99a4ccce242 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/assign-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/assign-example.json @@ -22,6 +22,7 @@ }, "flows": [], "status": "CONFIRMED", + "simpleStatus": "CONFIRMED", "message": "Provide multiple methods instead of using \"modal\" to determine which action to take.", "effort": "15min", "debt": "15min", diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/delete_comment-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/delete_comment-example.json index f6322816f86..3add8c45c36 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/delete_comment-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/delete_comment-example.json @@ -22,6 +22,7 @@ }, "flows": [], "status": "CONFIRMED", + "simpleStatus": "CONFIRMED", "message": "Provide multiple methods instead of using \"modal\" to determine which action to take.", "effort": "15min", "debt": "15min", diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/do_transition-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/do_transition-example.json index f6322816f86..3add8c45c36 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/do_transition-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/do_transition-example.json @@ -22,6 +22,7 @@ }, "flows": [], "status": "CONFIRMED", + "simpleStatus": "CONFIRMED", "message": "Provide multiple methods instead of using \"modal\" to determine which action to take.", "effort": "15min", "debt": "15min", diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/edit_comment-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/edit_comment-example.json index 79b0025dadf..99a4ccce242 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/edit_comment-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/edit_comment-example.json @@ -22,6 +22,7 @@ }, "flows": [], "status": "CONFIRMED", + "simpleStatus": "CONFIRMED", "message": "Provide multiple methods instead of using \"modal\" to determine which action to take.", "effort": "15min", "debt": "15min", diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_severity-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_severity-example.json index 79b0025dadf..99a4ccce242 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_severity-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_severity-example.json @@ -22,6 +22,7 @@ }, "flows": [], "status": "CONFIRMED", + "simpleStatus": "CONFIRMED", "message": "Provide multiple methods instead of using \"modal\" to determine which action to take.", "effort": "15min", "debt": "15min", diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_type-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_type-example.json index 79b0025dadf..99a4ccce242 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_type-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_type-example.json @@ -22,6 +22,7 @@ }, "flows": [], "status": "CONFIRMED", + "simpleStatus": "CONFIRMED", "message": "Provide multiple methods instead of using \"modal\" to determine which action to take.", "effort": "15min", "debt": "15min", diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java index b33f55b275a..19ef64e2768 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java @@ -33,6 +33,7 @@ import org.sonar.api.resources.Languages; import org.sonar.api.rules.CleanCodeAttribute; import org.sonar.api.utils.Duration; import org.sonar.api.utils.Durations; +import org.sonar.core.issue.status.SimpleStatus; import org.sonar.db.DbTester; import org.sonar.db.component.BranchDto; import org.sonar.db.component.BranchType; @@ -280,6 +281,16 @@ public class SearchResponseFormatFormatOperationTest { assertThat(result.getIssue().hasSeverity()).isFalse(); } + @Test + public void formatOperation_shouldReturnExpectedSimpleStatus() { + issueDto.setStatus(org.sonar.api.issue.Issue.STATUS_RESOLVED); + issueDto.setResolution(org.sonar.api.issue.Issue.RESOLUTION_WONT_FIX); + + Operation result = searchResponseFormat.formatOperation(searchResponseData); + + assertThat(result.getIssue().getSimpleStatus()).isEqualTo(SimpleStatus.ACCEPTED.name()); + } + private SearchResponseData newSearchResponseDataMainBranch() { ComponentDto projectDto = db.components().insertPublicProject().getMainBranchComponent(); BranchDto branchDto = db.getDbClient().branchDao().selectByUuid(db.getSession(), projectDto.uuid()).get(); diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto index 950853c8156..26454b936e0 100644 --- a/sonar-ws/src/main/protobuf/ws-issues.proto +++ b/sonar-ws/src/main/protobuf/ws-issues.proto @@ -166,6 +166,7 @@ message Issue { optional sonarqube.ws.commons.CleanCodeAttribute cleanCodeAttribute = 40; optional sonarqube.ws.commons.CleanCodeAttributeCategory cleanCodeAttributeCategory = 41; repeated sonarqube.ws.commons.Impact impacts = 42; + optional string simpleStatus = 43; } message Transitions { |