diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-08 11:01:04 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-10 10:44:16 +0100 |
commit | b551bd6ef3f878f7b68acdf759b995e227e1baaa (patch) | |
tree | 43cbf72aade73e15fe41fa185a392d595ee01dc2 | |
parent | d9d6031a949822c16cbb601975397588bf36cf07 (diff) | |
download | sonarqube-b551bd6ef3f878f7b68acdf759b995e227e1baaa.tar.gz sonarqube-b551bd6ef3f878f7b68acdf759b995e227e1baaa.zip |
SONAR-7345 Rename Issue debt to effort in WS
15 files changed, 157 insertions, 96 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java index 115ffe639fa..30dc75db6aa 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java @@ -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)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java index a24ccaad198..877068ded6a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java @@ -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; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java index 25a6f08f1ef..b8417c74cac 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java @@ -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) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java index 2f0afe9d863..457d804d810 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java @@ -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)); } } } diff --git a/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-search.json b/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-search.json index 61908702dd9..2bb9d5fc008 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-search.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-search.json @@ -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"], diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java index 41030157085..8b3ae1755e0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java @@ -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") diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/assigned_to_me_facet_sticky.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/assigned_to_me_facet_sticky.json index 00e9e9f0c82..294b82ab004 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/assigned_to_me_facet_sticky.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/assigned_to_me_facet_sticky.json @@ -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 index 00000000000..d3f950724f5 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_deprecated_debt_fields.json @@ -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" + } + ] +} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets.json index 4a9a5fb36de..8cec05d3980 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets.json @@ -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_effort.json index 2ce68b0381d..c71a31ef12f 100644 --- 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_effort.json @@ -1,5 +1,5 @@ { - "debtTotal": 10, + "effortTotal": 10, "issues": [ { "key": "82fd47d4-b650-4037-80bc-7b112bd4eac2", @@ -8,7 +8,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_zero_facets.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_zero_facets.json index bdc015b144d..7b6d10d0f11 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_zero_facets.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_zero_facets.json @@ -7,7 +7,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/filter_by_assigned_to_me.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/filter_by_assigned_to_me.json index f65f89b4974..4a0382aa7c1 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/filter_by_assigned_to_me.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/filter_by_assigned_to_me.json @@ -7,7 +7,7 @@ "rule": "xoo:x1", "status": "OPEN", "severity": "MAJOR", - "debt": "10min", + "effort": "10min", "assignee": "john" } ], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/hide_rules.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/hide_rules.json index 2c319af0b5a..e3c5691917f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/hide_rules.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/hide_rules.json @@ -7,7 +7,7 @@ "rule": "xoo:x1", "status": "OPEN", "severity": "MAJOR", - "debt": "10min" + "effort": "10min" } ], "rules": [] diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/response_contains_all_fields_except_additional_fields.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/response_contains_all_fields_except_additional_fields.json index e88f5789021..a4abf93e3f6 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/response_contains_all_fields_except_additional_fields.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/response_contains_all_fields_except_additional_fields.json @@ -8,7 +8,7 @@ "resolution": "FIXED", "status": "RESOLVED", "message": "the message", - "debt": "10min", + "effort": "10min", "assignee": "simon", "reporter": "fabrice", "author": "John", diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto index 5459f84b684..ad073765c8c 100644 --- a/sonar-ws/src/main/protobuf/ws-issues.proto +++ b/sonar-ws/src/main/protobuf/ws-issues.proto @@ -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; |