ソースを参照

SONAR-20877 Add new status field to api response

tags/10.4.0.87286
Léo Geoffroy 7ヶ月前
コミット
01a084c37d
20個のファイルの変更47行の追加4行の削除
  1. 2
    1
      server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionFacetsIT.java
  2. 2
    0
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AddCommentAction.java
  3. 2
    0
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AssignAction.java
  4. 2
    0
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DeleteCommentAction.java
  5. 2
    0
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/DoTransitionAction.java
  6. 2
    0
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/EditCommentAction.java
  7. 8
    3
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ListAction.java
  8. 2
    0
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
  9. 2
    0
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetSeverityAction.java
  10. 2
    0
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java
  11. 2
    0
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java
  12. 1
    0
      server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/add_comment-example.json
  13. 1
    0
      server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/assign-example.json
  14. 1
    0
      server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/delete_comment-example.json
  15. 1
    0
      server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/do_transition-example.json
  16. 1
    0
      server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/edit_comment-example.json
  17. 1
    0
      server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_severity-example.json
  18. 1
    0
      server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/set_type-example.json
  19. 11
    0
      server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java
  20. 1
    0
      sonar-ws/src/main/protobuf/ws-issues.proto

+ 2
- 1
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()));
});


+ 2
- 0
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"),

+ 2
- 0
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"),

+ 2
- 0
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"),

+ 2
- 0
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"),

+ 2
- 0
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"),

+ 8
- 3
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);

+ 2
- 0
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());

+ 2
- 0
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"),

+ 2
- 0
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"),

+ 2
- 0
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"),

+ 1
- 0
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",

+ 1
- 0
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",

+ 1
- 0
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",

+ 1
- 0
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",

+ 1
- 0
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",

+ 1
- 0
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",

+ 1
- 0
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",

+ 11
- 0
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();

+ 1
- 0
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 {

読み込み中…
キャンセル
保存