]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7345 Rename Issue debt to effort in WS
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 8 Mar 2016 10:01:04 +0000 (11:01 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 10 Mar 2016 09:44:16 +0000 (10:44 +0100)
16 files changed:
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-search.json
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/assigned_to_me_facet_sticky.json
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_deprecated_debt_fields.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets.json
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets_debt.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets_effort.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_zero_facets.json
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/filter_by_assigned_to_me.json
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/hide_rules.json
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/response_contains_all_fields_except_additional_fields.json
sonar-ws/src/main/protobuf/ws-issues.proto

index 115ffe639fa4b7d4fa29543c606cf17f4e68c1a6..30dc75db6aa374fc34b0558050a9eee68e67e764 100644 (file)
@@ -47,7 +47,6 @@ import org.sonar.server.issue.index.IssueIndex;
 import org.sonar.server.rule.RuleKeyFunctions;
 import org.sonar.server.user.UserSession;
 import org.sonarqube.ws.Issues.SearchWsResponse;
-import org.sonarqube.ws.client.issue.IssueFilterParameters;
 import org.sonarqube.ws.client.issue.SearchWsRequest;
 
 import static com.google.common.collect.FluentIterable.from;
@@ -73,8 +72,12 @@ import static org.sonarqube.ws.client.issue.IssueFilterParameters.CREATED_AFTER;
 import static org.sonarqube.ws.client.issue.IssueFilterParameters.CREATED_AT;
 import static org.sonarqube.ws.client.issue.IssueFilterParameters.CREATED_BEFORE;
 import static org.sonarqube.ws.client.issue.IssueFilterParameters.CREATED_IN_LAST;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.DEPRECATED_FACET_MODE_DEBT;
 import static org.sonarqube.ws.client.issue.IssueFilterParameters.DIRECTORIES;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.FACET_ASSIGNED_TO_ME;
 import static org.sonarqube.ws.client.issue.IssueFilterParameters.FACET_MODE;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.FACET_MODE_COUNT;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.FACET_MODE_EFFORT;
 import static org.sonarqube.ws.client.issue.IssueFilterParameters.FILE_UUIDS;
 import static org.sonarqube.ws.client.issue.IssueFilterParameters.ISSUES;
 import static org.sonarqube.ws.client.issue.IssueFilterParameters.LANGUAGES;
@@ -119,7 +122,8 @@ public class SearchAction implements IssuesWsAction {
       .createAction(SEARCH_ACTION)
       .setHandler(this)
       .setDescription(
-        "Search for issues. Requires Browse permission on project(s)")
+        "Search for issues. Requires Browse permission on project(s).<br/>" +
+          "Since 5.5, response field 'debt' has been renamed to 'effort'")
       .setSince("3.6")
       .setResponseExample(Resources.getResource(this.getClass(), "example-search.json"));
 
@@ -127,41 +131,42 @@ public class SearchAction implements IssuesWsAction {
     action.createParam(Param.FACETS)
       .setDescription("Comma-separated list of the facets to be computed. No facet is computed by default.")
       .setPossibleValues(IssueIndex.SUPPORTED_FACETS);
-    action.createParam(IssueFilterParameters.FACET_MODE)
-      .setDefaultValue(IssueFilterParameters.FACET_MODE_COUNT)
-      .setDescription("Choose the returned value for facet items, either count of issues or sum of debt.")
-      .setPossibleValues(IssueFilterParameters.FACET_MODE_COUNT, IssueFilterParameters.DEPRECATED_FACET_MODE_DEBT);
+    action.createParam(FACET_MODE)
+      .setDefaultValue(FACET_MODE_COUNT)
+      .setDescription("Choose the returned value for facet items, either count of issues or sum of debt.<br/>" +
+        "Since 5.5, 'debt' mode is deprecated and replaced by 'effort'")
+      .setPossibleValues(FACET_MODE_COUNT, FACET_MODE_EFFORT, DEPRECATED_FACET_MODE_DEBT);
     action.addSortParams(IssueQuery.SORTS, null, true);
-    action.createParam(IssueFilterParameters.ADDITIONAL_FIELDS)
+    action.createParam(ADDITIONAL_FIELDS)
       .setSince("5.2")
       .setDescription("Comma-separated list of the optional fields to be returned in response.")
       .setPossibleValues(SearchAdditionalField.possibleValues());
     addComponentRelatedParams(action);
-    action.createParam(IssueFilterParameters.ISSUES)
+    action.createParam(ISSUES)
       .setDescription("Comma-separated list of issue keys")
       .setExampleValue("5bccd6e8-f525-43a2-8d76-fcb13dde79ef");
-    action.createParam(IssueFilterParameters.SEVERITIES)
+    action.createParam(SEVERITIES)
       .setDescription("Comma-separated list of severities")
       .setExampleValue(Severity.BLOCKER + "," + Severity.CRITICAL)
       .setPossibleValues(Severity.ALL);
-    action.createParam(IssueFilterParameters.STATUSES)
+    action.createParam(STATUSES)
       .setDescription("Comma-separated list of statuses")
       .setExampleValue(Issue.STATUS_OPEN + "," + Issue.STATUS_REOPENED)
       .setPossibleValues(Issue.STATUSES);
-    action.createParam(IssueFilterParameters.RESOLUTIONS)
+    action.createParam(RESOLUTIONS)
       .setDescription("Comma-separated list of resolutions")
       .setExampleValue(Issue.RESOLUTION_FIXED + "," + Issue.RESOLUTION_REMOVED)
       .setPossibleValues(Issue.RESOLUTIONS);
-    action.createParam(IssueFilterParameters.RESOLVED)
+    action.createParam(RESOLVED)
       .setDescription("To match resolved or unresolved issues")
       .setBooleanPossibleValues();
-    action.createParam(IssueFilterParameters.RULES)
+    action.createParam(RULES)
       .setDescription("Comma-separated list of coding rule keys. Format is <repository>:<rule>")
       .setExampleValue("squid:AvoidCycles");
-    action.createParam(IssueFilterParameters.TAGS)
+    action.createParam(TAGS)
       .setDescription("Comma-separated list of tags.")
       .setExampleValue("security,convention");
-    action.createParam(IssueFilterParameters.TYPES)
+    action.createParam(TYPES)
       .setDescription("Comma-separated list of types.")
       .setSince("5.5")
       .setPossibleValues(RuleType.values())
@@ -169,34 +174,34 @@ public class SearchAction implements IssuesWsAction {
     action.createParam(ACTION_PLANS)
       .setDescription("Comma-separated list of action plan keys (not names)")
       .setExampleValue("3f19de90-1521-4482-a737-a311758ff513");
-    action.createParam(IssueFilterParameters.PLANNED)
+    action.createParam(PLANNED)
       .setDescription("To retrieve issues associated to an action plan or not")
       .setBooleanPossibleValues();
-    action.createParam(IssueFilterParameters.REPORTERS)
+    action.createParam(REPORTERS)
       .setDescription("Comma-separated list of reporter logins")
       .setExampleValue("admin");
-    action.createParam(IssueFilterParameters.AUTHORS)
+    action.createParam(AUTHORS)
       .setDescription("Comma-separated list of SCM accounts")
       .setExampleValue("torvalds@linux-foundation.org");
-    action.createParam(IssueFilterParameters.ASSIGNEES)
+    action.createParam(ASSIGNEES)
       .setDescription("Comma-separated list of assignee logins. The value '__me__' can be used as a placeholder for user who performs the request")
       .setExampleValue("admin,usera,__me__");
-    action.createParam(IssueFilterParameters.ASSIGNED)
+    action.createParam(ASSIGNED)
       .setDescription("To retrieve assigned or unassigned issues")
       .setBooleanPossibleValues();
-    action.createParam(IssueFilterParameters.LANGUAGES)
+    action.createParam(LANGUAGES)
       .setDescription("Comma-separated list of languages. Available since 4.4")
       .setExampleValue("java,js");
-    action.createParam(IssueFilterParameters.CREATED_AT)
+    action.createParam(CREATED_AT)
       .setDescription("To retrieve issues created in a specific analysis, identified by an ISO-formatted datetime stamp.")
       .setExampleValue("2013-05-01T13:00:00+0100");
-    action.createParam(IssueFilterParameters.CREATED_AFTER)
+    action.createParam(CREATED_AFTER)
       .setDescription("To retrieve issues created after the given date (exclusive). Format: date or datetime ISO formats. If this parameter is set, createdSince must not be set")
       .setExampleValue("2013-05-01 (or 2013-05-01T13:00:00+0100)");
-    action.createParam(IssueFilterParameters.CREATED_BEFORE)
+    action.createParam(CREATED_BEFORE)
       .setDescription("To retrieve issues created before the given date (exclusive). Format: date or datetime ISO formats")
       .setExampleValue("2013-05-01 (or 2013-05-01T13:00:00+0100)");
-    action.createParam(IssueFilterParameters.CREATED_IN_LAST)
+    action.createParam(CREATED_IN_LAST)
       .setDescription("To retrieve issues created during a time span before the current time (exclusive). " +
         "Accepted units are 'y' for year, 'm' for month, 'w' for week and 'd' for day. " +
         "If this parameter is set, createdAfter must not be set")
@@ -204,7 +209,7 @@ public class SearchAction implements IssuesWsAction {
   }
 
   private static void addComponentRelatedParams(WebService.NewAction action) {
-    action.createParam(IssueFilterParameters.ON_COMPONENT_ONLY)
+    action.createParam(ON_COMPONENT_ONLY)
       .setDescription("Return only issues at a component's level, not on its descendants (modules, directories, files, etc). " +
         "This parameter is only considered when componentKeys or componentUuids is set. " +
         "Using the deprecated componentRoots or componentRootUuids parameters will set this parameter to false. " +
@@ -212,56 +217,56 @@ public class SearchAction implements IssuesWsAction {
       .setBooleanPossibleValues()
       .setDefaultValue("false");
 
-    action.createParam(IssueFilterParameters.COMPONENT_KEYS)
+    action.createParam(COMPONENT_KEYS)
       .setDescription("To retrieve issues associated to a specific list of components sub-components (comma-separated list of component keys). " +
         "A component can be a view, developer, project, module, directory or file. " +
         "If this parameter is set, componentUuids must not be set.")
       .setExampleValue(KEY_PROJECT_EXAMPLE_001);
-    action.createParam(IssueFilterParameters.COMPONENTS)
+    action.createParam(COMPONENTS)
       .setDeprecatedSince("5.1")
       .setDescription("If used, will have the same meaning as componentKeys AND onComponentOnly=true.");
-    action.createParam(IssueFilterParameters.COMPONENT_UUIDS)
+    action.createParam(COMPONENT_UUIDS)
       .setDescription("To retrieve issues associated to a specific list of components their sub-components (comma-separated list of component UUIDs). " +
         INTERNAL_PARAMETER_DISCLAIMER +
         "A component can be a project, module, directory or file. " +
         "If this parameter is set, componentKeys must not be set.")
       .setExampleValue("584a89f2-8037-4f7b-b82c-8b45d2d63fb2");
 
-    action.createParam(IssueFilterParameters.COMPONENT_ROOTS)
+    action.createParam(COMPONENT_ROOTS)
       .setDeprecatedSince("5.1")
       .setDescription("If used, will have the same meaning as componentKeys AND onComponentOnly=false.");
-    action.createParam(IssueFilterParameters.COMPONENT_ROOT_UUIDS)
+    action.createParam(COMPONENT_ROOT_UUIDS)
       .setDeprecatedSince("5.1")
       .setDescription("If used, will have the same meaning as componentUuids AND onComponentOnly=false.");
 
-    action.createParam(IssueFilterParameters.PROJECTS)
+    action.createParam(PROJECTS)
       .setDeprecatedSince("5.1")
       .setDescription("See projectKeys");
-    action.createParam(IssueFilterParameters.PROJECT_KEYS)
+    action.createParam(PROJECT_KEYS)
       .setDescription("To retrieve issues associated to a specific list of projects (comma-separated list of project keys). " +
         INTERNAL_PARAMETER_DISCLAIMER +
         "If this parameter is set, projectUuids must not be set.")
-      .setDeprecatedKey(IssueFilterParameters.PROJECTS)
+      .setDeprecatedKey(PROJECTS)
       .setExampleValue(KEY_PROJECT_EXAMPLE_001);
-    action.createParam(IssueFilterParameters.PROJECT_UUIDS)
+    action.createParam(PROJECT_UUIDS)
       .setDescription("To retrieve issues associated to a specific list of projects (comma-separated list of project UUIDs). " +
         INTERNAL_PARAMETER_DISCLAIMER +
         "Views are not supported. If this parameter is set, projectKeys must not be set.")
       .setExampleValue("7d8749e8-3070-4903-9188-bdd82933bb92");
 
-    action.createParam(IssueFilterParameters.MODULE_UUIDS)
+    action.createParam(MODULE_UUIDS)
       .setDescription("To retrieve issues associated to a specific list of modules (comma-separated list of module UUIDs). " +
         INTERNAL_PARAMETER_DISCLAIMER +
         "Views are not supported. If this parameter is set, moduleKeys must not be set.")
       .setExampleValue("7d8749e8-3070-4903-9188-bdd82933bb92");
 
-    action.createParam(IssueFilterParameters.DIRECTORIES)
+    action.createParam(DIRECTORIES)
       .setDescription("Since 5.1. To retrieve issues associated to a specific list of directories (comma-separated list of directory paths). " +
         "This parameter is only meaningful when a module is selected. " +
         INTERNAL_PARAMETER_DISCLAIMER)
       .setExampleValue("src/main/java/org/sonar/server/");
 
-    action.createParam(IssueFilterParameters.FILE_UUIDS)
+    action.createParam(FILE_UUIDS)
       .setDescription("To retrieve issues associated to a specific list of files (comma-separated list of file UUIDs). " +
         INTERNAL_PARAMETER_DISCLAIMER)
       .setExampleValue("bdd82933-3070-4903-9188-7d8749e8bb92");
@@ -328,10 +333,10 @@ public class SearchAction implements IssuesWsAction {
   }
 
   private void completeFacets(Facets facets, SearchWsRequest request, Request wsRequest) {
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.SEVERITIES, Severity.ALL);
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.STATUSES, Issue.STATUSES);
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.RESOLUTIONS, concat(singletonList(""), Issue.RESOLUTIONS));
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.PROJECT_UUIDS, request.getProjectUuids());
+    addMandatoryValuesToFacet(facets, SEVERITIES, Severity.ALL);
+    addMandatoryValuesToFacet(facets, STATUSES, Issue.STATUSES);
+    addMandatoryValuesToFacet(facets, RESOLUTIONS, concat(singletonList(""), Issue.RESOLUTIONS));
+    addMandatoryValuesToFacet(facets, PROJECT_UUIDS, request.getProjectUuids());
 
     List<String> assignees = Lists.newArrayList("");
     List<String> assigneesFromRequest = request.getAssignees();
@@ -339,24 +344,24 @@ public class SearchAction implements IssuesWsAction {
       assignees.addAll(assigneesFromRequest);
       assignees.remove(IssueQueryService.LOGIN_MYSELF);
     }
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.ASSIGNEES, assignees);
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.FACET_ASSIGNED_TO_ME, singletonList(userSession.getLogin()));
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.REPORTERS, request.getReporters());
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.RULES, request.getRules());
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.LANGUAGES, request.getLanguages());
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.TAGS, request.getTags());
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.TYPES, RuleType.ALL_NAMES);
+    addMandatoryValuesToFacet(facets, ASSIGNEES, assignees);
+    addMandatoryValuesToFacet(facets, FACET_ASSIGNED_TO_ME, singletonList(userSession.getLogin()));
+    addMandatoryValuesToFacet(facets, REPORTERS, request.getReporters());
+    addMandatoryValuesToFacet(facets, RULES, request.getRules());
+    addMandatoryValuesToFacet(facets, LANGUAGES, request.getLanguages());
+    addMandatoryValuesToFacet(facets, TAGS, request.getTags());
+    addMandatoryValuesToFacet(facets, TYPES, RuleType.ALL_NAMES);
     List<String> actionPlans = Lists.newArrayList("");
     List<String> actionPlansFromRequest = request.getActionPlans();
     if (actionPlansFromRequest != null) {
       actionPlans.addAll(actionPlansFromRequest);
     }
     addMandatoryValuesToFacet(facets, ACTION_PLANS, actionPlans);
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.COMPONENT_UUIDS, request.getComponentUuids());
+    addMandatoryValuesToFacet(facets, COMPONENT_UUIDS, request.getComponentUuids());
 
     for (String facetName : request.getFacets()) {
       LinkedHashMap<String, Long> buckets = facets.get(facetName);
-      if (!IssueFilterParameters.FACET_ASSIGNED_TO_ME.equals(facetName)) {
+      if (!FACET_ASSIGNED_TO_ME.equals(facetName)) {
         if (buckets != null) {
           List<String> requestParams = wsRequest.paramAsStrings(facetName);
           if (requestParams != null) {
@@ -390,16 +395,16 @@ public class SearchAction implements IssuesWsAction {
   }
 
   private void collectFacets(SearchResponseLoader.Collector collector, Facets facets) {
-    Set<String> facetRules = facets.getBucketKeys(IssueFilterParameters.RULES);
+    Set<String> facetRules = facets.getBucketKeys(RULES);
     if (facetRules != null) {
       collector.addAll(SearchAdditionalField.RULES, from(facetRules).transform(RuleKeyFunctions.stringToRuleKey()));
     }
-    collector.addProjectUuids(facets.getBucketKeys(IssueFilterParameters.PROJECT_UUIDS));
-    collector.addComponentUuids(facets.getBucketKeys(IssueFilterParameters.COMPONENT_UUIDS));
-    collector.addComponentUuids(facets.getBucketKeys(IssueFilterParameters.FILE_UUIDS));
-    collector.addComponentUuids(facets.getBucketKeys(IssueFilterParameters.MODULE_UUIDS));
-    collector.addAll(SearchAdditionalField.USERS, facets.getBucketKeys(IssueFilterParameters.ASSIGNEES));
-    collector.addAll(SearchAdditionalField.USERS, facets.getBucketKeys(IssueFilterParameters.REPORTERS));
+    collector.addProjectUuids(facets.getBucketKeys(PROJECT_UUIDS));
+    collector.addComponentUuids(facets.getBucketKeys(COMPONENT_UUIDS));
+    collector.addComponentUuids(facets.getBucketKeys(FILE_UUIDS));
+    collector.addComponentUuids(facets.getBucketKeys(MODULE_UUIDS));
+    collector.addAll(SearchAdditionalField.USERS, facets.getBucketKeys(ASSIGNEES));
+    collector.addAll(SearchAdditionalField.USERS, facets.getBucketKeys(REPORTERS));
     collector.addAll(SearchAdditionalField.ACTION_PLANS, facets.getBucketKeys(ACTION_PLANS));
   }
 
index a24ccaad198a95b619341f4a3d1da3b761dfc6b9..877068ded6adfc911fb2ecbb8193ac5f534f81f8 100644 (file)
@@ -29,13 +29,13 @@ import java.util.Map;
 import java.util.Set;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-import org.sonar.server.issue.workflow.Transition;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.issue.ActionPlanDto;
 import org.sonar.db.issue.IssueChangeDto;
 import org.sonar.db.issue.IssueDto;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.user.UserDto;
+import org.sonar.server.issue.workflow.Transition;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -46,7 +46,7 @@ public class SearchResponseData {
 
   private final List<IssueDto> issues;
 
-  private Long debtTotal = null;
+  private Long effortTotal = null;
   private List<UserDto> users = null;
   private List<RuleDto> rules = null;
   private List<ActionPlanDto> actionPlans = null;
@@ -157,11 +157,11 @@ public class SearchResponseData {
   }
 
   @CheckForNull
-  public Long getDebtTotal() {
-    return debtTotal;
+  public Long getEffortTotal() {
+    return effortTotal;
   }
 
-  public void setDebtTotal(@Nullable Long debtTotal) {
-    this.debtTotal = debtTotal;
+  public void setEffortTotal(@Nullable Long effortTotal) {
+    this.effortTotal = effortTotal;
   }
 }
index 25a6f08f1ef1556873bc64f886bf1eda288bf53a..b8417c74cac18f8aeb6c5e1f0767bf49a8f3a324 100644 (file)
@@ -69,7 +69,7 @@ public class SearchResponseFormat {
     Issues.SearchWsResponse.Builder response = Issues.SearchWsResponse.newBuilder();
 
     formatPaging(paging, response);
-    formatDebtTotal(data, response);
+    formatEffortTotal(data, response);
     response.addAllIssues(formatIssues(fields, data));
     response.addAllComponents(formatComponents(data));
     if (facets != null) {
@@ -109,10 +109,11 @@ public class SearchResponseFormat {
     return response.build();
   }
 
-  private void formatDebtTotal(SearchResponseData data, Issues.SearchWsResponse.Builder response) {
-    Long debt = data.getDebtTotal();
-    if (debt != null) {
-      response.setDebtTotal(debt);
+  private void formatEffortTotal(SearchResponseData data, Issues.SearchWsResponse.Builder response) {
+    Long effort = data.getEffortTotal();
+    if (effort != null) {
+      response.setDebtTotal(effort);
+      response.setEffortTotal(effort);
     }
   }
 
@@ -178,9 +179,11 @@ public class SearchResponseFormat {
     }
     issueBuilder.setMessage(nullToEmpty(dto.getMessage()));
     issueBuilder.addAllTags(dto.getTags());
-    Long debt = dto.getEffort();
-    if (debt != null) {
-      issueBuilder.setDebt(durations.encode(Duration.create(debt)));
+    Long effort = dto.getEffort();
+    if (effort != null) {
+      String effortValue = durations.encode(Duration.create(effort));
+      issueBuilder.setDebt(effortValue);
+      issueBuilder.setEffort(effortValue);
     }
     Integer line = dto.getLine();
     if (line != null) {
index 2f0afe9d863c47f61e9cd3c99be36368f8f9416e..457d804d810360450492e1b30fc3a1ffea09b5a0 100644 (file)
@@ -84,7 +84,7 @@ public class SearchResponseLoader {
       loadActionPlans(collector, dbSession, result);
       loadComponents(collector, dbSession, result);
       loadActionsAndTransitions(collector, result);
-      completeTotalDebtFromFacet(facets, result);
+      completeTotalEffortFromFacet(facets, result);
       return result;
     } finally {
       dbClient.closeSession(dbSession);
@@ -150,11 +150,11 @@ public class SearchResponseLoader {
     }
   }
 
-  private void completeTotalDebtFromFacet(@Nullable Facets facets, SearchResponseData result) {
+  private void completeTotalEffortFromFacet(@Nullable Facets facets, SearchResponseData result) {
     if (facets != null) {
-      Map<String, Long> debtFacet = facets.get(IssueFilterParameters.FACET_MODE_EFFORT);
-      if (debtFacet != null) {
-        result.setDebtTotal(debtFacet.get(Facets.TOTAL));
+      Map<String, Long> effortFacet = facets.get(IssueFilterParameters.FACET_MODE_EFFORT);
+      if (effortFacet != null) {
+        result.setEffortTotal(effortFacet.get(Facets.TOTAL));
       }
     }
   }
index 61908702dd9b859196a55f2c065c7a4a053c33d9..2bb9d5fc00813290d594cd62cc6f138317c883e6 100644 (file)
@@ -22,7 +22,7 @@
         "endOffset": 134
       },
       "author": "Developer 1",
-      "debt": "2h1min",
+      "effort": "2h1min",
       "creationDate": "2013-05-13T17:55:39+0200",
       "updateDate": "2013-05-13T17:55:39+0200",
       "tags": ["bug"],
index 41030157085b67bce87cb259c613f2c03a35b853..8b3ae1755e0e4f6cac37c15f953e502621b56586 100644 (file)
@@ -54,10 +54,16 @@ import org.sonar.server.search.QueryContext;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.WsTester;
-import org.sonarqube.ws.client.issue.IssueFilterParameters;
 
 import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.ADDITIONAL_FIELDS;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.COMPONENTS;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.DEPRECATED_FACET_MODE_DEBT;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.FACET_MODE_EFFORT;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.HIDE_COMMENTS;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.PAGE_INDEX;
+import static org.sonarqube.ws.client.issue.IssueFilterParameters.PAGE_SIZE;
 
 public class SearchActionMediumTest {
 
@@ -203,7 +209,7 @@ public class SearchActionMediumTest {
     tester.get(IssueIndexer.class).indexAll();
 
     userSessionRule.login("john");
-    WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(IssueFilterParameters.HIDE_COMMENTS, "true").execute();
+    WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(HIDE_COMMENTS, "true").execute();
     result.assertJson(this.getClass(), "issue_with_comment_hidden.json");
     assertThat(result.outputAsString()).doesNotContain("fabrice");
   }
@@ -320,7 +326,7 @@ public class SearchActionMediumTest {
     session.commit();
     tester.get(IssueIndexer.class).indexAll();
 
-    WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(IssueFilterParameters.COMPONENTS, file.getKey()).execute();
+    WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(COMPONENTS, file.getKey()).execute();
     result.assertJson(this.getClass(), "apply_paging_with_one_component.json");
   }
 
@@ -335,7 +341,7 @@ public class SearchActionMediumTest {
     session.commit();
     tester.get(IssueIndexer.class).indexAll();
 
-    WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(IssueFilterParameters.ADDITIONAL_FIELDS, "_all").execute();
+    WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(ADDITIONAL_FIELDS, "_all").execute();
     result.assertJson(this.getClass(), "components_contains_sub_projects.json");
   }
 
@@ -364,7 +370,7 @@ public class SearchActionMediumTest {
   }
 
   @Test
-  public void display_facets_in_debt_mode() throws Exception {
+  public void display_facets_in_effort_mode() throws Exception {
     ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
@@ -383,9 +389,9 @@ public class SearchActionMediumTest {
     WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
       .setParam("resolved", "false")
       .setParam(WebService.Param.FACETS, "statuses,severities,resolutions,projectUuids,rules,fileUuids,assignees,languages,actionPlans")
-      .setParam("facetMode", "debt")
+      .setParam("facetMode", FACET_MODE_EFFORT)
       .execute();
-    result.assertJson(this.getClass(), "display_facets_debt.json");
+    result.assertJson(this.getClass(), "display_facets_effort.json");
   }
 
   @Test
@@ -613,8 +619,8 @@ public class SearchActionMediumTest {
     tester.get(IssueIndexer.class).indexAll();
 
     WsTester.TestRequest request = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION);
-    request.setParam(IssueFilterParameters.PAGE_INDEX, "2");
-    request.setParam(IssueFilterParameters.PAGE_SIZE, "9");
+    request.setParam(PAGE_INDEX, "2");
+    request.setParam(PAGE_SIZE, "9");
 
     WsTester.Result result = request.execute();
     result.assertJson(this.getClass(), "deprecated_paging.json");
@@ -628,6 +634,31 @@ public class SearchActionMediumTest {
     result.assertJson(this.getClass(), "default_page_size_is_100.json");
   }
 
+  @Test
+  public void display_deprecated_debt_fields() throws Exception {
+    ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
+    setDefaultProjectPermission(project);
+    ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+    IssueDto issue = IssueTesting.newDto(newRule(), file, project)
+      .setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
+      .setIssueUpdateDate(DateUtils.parseDate("2017-12-04"))
+      .setEffort(10L)
+      .setStatus("OPEN")
+      .setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
+      .setSeverity("MAJOR");
+    db.issueDao().insert(session, issue);
+    session.commit();
+    tester.get(IssueIndexer.class).indexAll();
+
+    userSessionRule.login("john");
+    WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
+      .setParam("resolved", "false")
+      .setParam(WebService.Param.FACETS, "severities")
+      .setParam("facetMode", DEPRECATED_FACET_MODE_DEBT)
+      .execute();
+    result.assertJson(this.getClass(), "display_deprecated_debt_fields.json");
+  }
+
   private RuleDto newRule() {
     RuleDto rule = RuleTesting.newXooX1()
       .setName("Rule name")
index 00e9e9f0c8208bc02140bea0b7e1103083a88338..294b82ab004da313a90dcf245d47524c8674d406 100644 (file)
@@ -6,7 +6,7 @@
       "rule": "xoo:x1",
       "status": "OPEN",
       "severity": "MAJOR",
-      "debt": "10min",
+      "effort": "10min",
       "assignee": "alice"
     }
   ],
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_deprecated_debt_fields.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_deprecated_debt_fields.json
new file mode 100644 (file)
index 0000000..d3f9507
--- /dev/null
@@ -0,0 +1,16 @@
+{
+  "debtTotal": 10,
+  "effortTotal": 10,
+  "issues": [
+    {
+      "key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
+      "component": "FILE_KEY",
+      "project": "PROJECT_KEY",
+      "rule": "xoo:x1",
+      "status": "OPEN",
+      "severity": "MAJOR",
+      "effort": "10min",
+      "debt": "10min"
+    }
+  ]
+}
index 4a9a5fb36de6e16826b318e730c7fc6bfa82dace..8cec05d39804cee15491e10a2ed6e6b9ab07fc0c 100644 (file)
@@ -6,7 +6,7 @@
       "rule": "xoo:x1",
       "status": "OPEN",
       "severity": "MAJOR",
-      "debt": "10min"
+      "effort": "10min"
     }
   ],
   "facets": [
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets_debt.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets_debt.json
deleted file mode 100644 (file)
index 2ce68b0..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-{
-  "debtTotal": 10,
-  "issues": [
-    {
-      "key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
-      "component": "FILE_KEY",
-      "project": "PROJECT_KEY",
-      "rule": "xoo:x1",
-      "status": "OPEN",
-      "severity": "MAJOR",
-      "debt": "10min"
-    }
-  ],
-  "facets": [
-    {
-      "property": "statuses",
-      "values": [
-        {
-          "val": "OPEN",
-          "count": 10
-        },
-        {
-          "val": "CONFIRMED",
-          "count": 0
-        },
-        {
-          "val": "REOPENED",
-          "count": 0
-        },
-        {
-          "val": "RESOLVED",
-          "count": 0
-        },
-        {
-          "val": "CLOSED",
-          "count": 0
-        }
-      ]
-    },
-    {
-      "property": "severities",
-      "values": [
-        {
-          "val": "MAJOR",
-          "count": 10
-        },
-        {
-          "val": "INFO",
-          "count": 0
-        },
-        {
-          "val": "MINOR",
-          "count": 0
-        },
-        {
-          "val": "CRITICAL",
-          "count": 0
-        },
-        {
-          "val": "BLOCKER",
-          "count": 0
-        }
-      ]
-    },
-    {
-      "property": "resolutions",
-      "values": [
-        {
-          "val": "",
-          "count": 10
-        },
-        {
-          "val": "FALSE-POSITIVE",
-          "count": 0
-        },
-        {
-          "val": "FIXED",
-          "count": 0
-        },
-        {
-          "val": "REMOVED",
-          "count": 0
-        },
-        {
-          "val": "WONTFIX",
-          "count": 0
-        }
-      ]
-    },
-    {
-      "property": "projectUuids",
-      "values": [
-        {
-          "val": "PROJECT_ID",
-          "count": 10
-        }
-      ]
-    },
-    {
-      "property": "rules",
-      "values": [
-        {
-          "val": "xoo:x1",
-          "count": 10
-        }
-      ]
-    },
-    {
-      "property": "fileUuids",
-      "values": [
-        {
-          "val": "FILE_ID",
-          "count": 10
-        }
-      ]
-    },
-    {
-      "property": "assignees",
-      "values": [
-        {
-          "val": "",
-          "count": 10
-        }
-      ]
-    },
-    {
-      "property": "languages",
-      "values": [
-        {
-          "val": "xoo",
-          "count": 10
-        }
-      ]
-    },
-    {
-      "property": "actionPlans",
-      "values": [
-        {
-          "val": "",
-          "count": 10
-        }
-      ]
-    }
-  ]}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets_effort.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets_effort.json
new file mode 100644 (file)
index 0000000..c71a31e
--- /dev/null
@@ -0,0 +1,144 @@
+{
+  "effortTotal": 10,
+  "issues": [
+    {
+      "key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
+      "component": "FILE_KEY",
+      "project": "PROJECT_KEY",
+      "rule": "xoo:x1",
+      "status": "OPEN",
+      "severity": "MAJOR",
+      "effort": "10min"
+    }
+  ],
+  "facets": [
+    {
+      "property": "statuses",
+      "values": [
+        {
+          "val": "OPEN",
+          "count": 10
+        },
+        {
+          "val": "CONFIRMED",
+          "count": 0
+        },
+        {
+          "val": "REOPENED",
+          "count": 0
+        },
+        {
+          "val": "RESOLVED",
+          "count": 0
+        },
+        {
+          "val": "CLOSED",
+          "count": 0
+        }
+      ]
+    },
+    {
+      "property": "severities",
+      "values": [
+        {
+          "val": "MAJOR",
+          "count": 10
+        },
+        {
+          "val": "INFO",
+          "count": 0
+        },
+        {
+          "val": "MINOR",
+          "count": 0
+        },
+        {
+          "val": "CRITICAL",
+          "count": 0
+        },
+        {
+          "val": "BLOCKER",
+          "count": 0
+        }
+      ]
+    },
+    {
+      "property": "resolutions",
+      "values": [
+        {
+          "val": "",
+          "count": 10
+        },
+        {
+          "val": "FALSE-POSITIVE",
+          "count": 0
+        },
+        {
+          "val": "FIXED",
+          "count": 0
+        },
+        {
+          "val": "REMOVED",
+          "count": 0
+        },
+        {
+          "val": "WONTFIX",
+          "count": 0
+        }
+      ]
+    },
+    {
+      "property": "projectUuids",
+      "values": [
+        {
+          "val": "PROJECT_ID",
+          "count": 10
+        }
+      ]
+    },
+    {
+      "property": "rules",
+      "values": [
+        {
+          "val": "xoo:x1",
+          "count": 10
+        }
+      ]
+    },
+    {
+      "property": "fileUuids",
+      "values": [
+        {
+          "val": "FILE_ID",
+          "count": 10
+        }
+      ]
+    },
+    {
+      "property": "assignees",
+      "values": [
+        {
+          "val": "",
+          "count": 10
+        }
+      ]
+    },
+    {
+      "property": "languages",
+      "values": [
+        {
+          "val": "xoo",
+          "count": 10
+        }
+      ]
+    },
+    {
+      "property": "actionPlans",
+      "values": [
+        {
+          "val": "",
+          "count": 10
+        }
+      ]
+    }
+  ]}
index bdc015b144d7d683ea9aea49e613a7929e149e4c..7b6d10d0f1181d7b59166354cb0372ab92ed8c59 100644 (file)
@@ -7,7 +7,7 @@
       "rule": "xoo:x1",
       "status": "OPEN",
       "severity": "MAJOR",
-      "debt": "10min"
+      "effort": "10min"
     }
   ],
   "facets": [
index f65f89b49747fef6c7c2318fa8270fc3c100f25e..4a0382aa7c18e7c9fcd184965efa5def68794909 100644 (file)
@@ -7,7 +7,7 @@
       "rule": "xoo:x1",
       "status": "OPEN",
       "severity": "MAJOR",
-      "debt": "10min",
+      "effort": "10min",
       "assignee": "john"
     }
   ],
index 2c319af0b5a6cea4bab812787103670e1a769883..e3c5691917fc0f992531c0552fe84d62c8c15b73 100644 (file)
@@ -7,7 +7,7 @@
       "rule": "xoo:x1",
       "status": "OPEN",
       "severity": "MAJOR",
-      "debt": "10min"
+      "effort": "10min"
     }
   ],
   "rules": []
index e88f578902182c339ce82b29285c04b58092cf4b..a4abf93e3f67609fba12cf0a89974d3b0ae62d5e 100644 (file)
@@ -8,7 +8,7 @@
       "resolution": "FIXED",
       "status": "RESOLVED",
       "message": "the message",
-      "debt": "10min",
+      "effort": "10min",
       "assignee": "simon",
       "reporter": "fabrice",
       "author": "John",
index 5459f84b6842d111471668a6992d9acf92676140..ad073765c8c48e34389c85b828c091084ec93fac 100644 (file)
@@ -33,7 +33,9 @@ message SearchWsResponse {
   optional int32 ps = 3;
   optional sonarqube.ws.commons.Paging paging = 4;
 
-  // Total amount of debt, only when the facet "total" is enabled
+  // Total amount of effort, only when the facet "total" is enabled
+  optional int64 effortTotal = 13;
+  // Deprecated since 5.5, replaced by effortTotal
   optional int64 debtTotal = 5;
 
   repeated Issue issues = 6;
@@ -68,7 +70,11 @@ message Issue {
   optional string resolution = 11;
   optional string status = 12;
   optional string message = 13;
+
+  optional string effort = 28;
+  // Deprecated since 5.5, replaced by effort
   optional string debt = 14;
+
   optional string assignee = 15;
   optional string reporter = 16;