diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-08 11:07:01 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-10 10:44:16 +0100 |
commit | d9d6031a949822c16cbb601975397588bf36cf07 (patch) | |
tree | 6af4c1c2fa9deccf5028fbea235380f54ae0afa6 | |
parent | 79de4ddfda36dd889c6001a1cd509bd48962dbc0 (diff) | |
download | sonarqube-d9d6031a949822c16cbb601975397588bf36cf07.tar.gz sonarqube-d9d6031a949822c16cbb601975397588bf36cf07.zip |
SONAR-7345 Rename Issue debt to effort in ES
14 files changed, 178 insertions, 124 deletions
diff --git a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java index fc041abff65..537fe822429 100644 --- a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java +++ b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java @@ -189,7 +189,7 @@ public class IssueIndexBenchmarkTest { issue.setFuncCreationDate(new Date()); issue.setFuncCloseDate(null); issue.setAttributes(null); - issue.setDebt(1000L); + issue.setEffort(1000L); issue.setGap(3.14); issue.setLanguage("php"); issue.setReporter(users.next()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/Facets.java b/server/sonar-server/src/main/java/org/sonar/server/es/Facets.java index 32149fb7dfb..c96248e65a5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/Facets.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/Facets.java @@ -35,6 +35,8 @@ import org.elasticsearch.search.aggregations.bucket.missing.Missing; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.metrics.sum.Sum; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.FACET_MODE_EFFORT; + public class Facets { public static final String TOTAL = "total"; @@ -75,8 +77,8 @@ public class Facets { long docCount = aggregation.getDocCount(); if (docCount > 0L) { LinkedHashMap<String, Long> facet = getOrCreateFacet(aggregation.getName().replace("_missing", "")); - if (aggregation.getAggregations().getAsMap().containsKey("debt")) { - facet.put("", Math.round(((Sum) aggregation.getAggregations().get("debt")).getValue())); + if (aggregation.getAggregations().getAsMap().containsKey(FACET_MODE_EFFORT)) { + facet.put("", Math.round(((Sum) aggregation.getAggregations().get(FACET_MODE_EFFORT)).getValue())); } else { facet.put("", docCount); } @@ -92,8 +94,8 @@ public class Facets { facetName = facetName.replace("_selected", ""); LinkedHashMap<String, Long> facet = getOrCreateFacet(facetName); for (Terms.Bucket value : aggregation.getBuckets()) { - if (value.getAggregations().getAsMap().containsKey("debt")) { - facet.put(value.getKey(), Math.round(((Sum) value.getAggregations().get("debt")).getValue())); + if (value.getAggregations().getAsMap().containsKey(FACET_MODE_EFFORT)) { + facet.put(value.getKey(), Math.round(((Sum) value.getAggregations().get(FACET_MODE_EFFORT)).getValue())); } else { facet.put(value.getKey(), value.getDocCount()); } @@ -109,8 +111,8 @@ public class Facets { private void processDateHistogram(DateHistogram aggregation) { LinkedHashMap<String, Long> facet = getOrCreateFacet(aggregation.getName()); for (DateHistogram.Bucket value : aggregation.getBuckets()) { - if (value.getAggregations().getAsMap().containsKey("debt")) { - facet.put(value.getKey(), Math.round(((Sum) value.getAggregations().get("debt")).getValue())); + if (value.getAggregations().getAsMap().containsKey(FACET_MODE_EFFORT)) { + facet.put(value.getKey(), Math.round(((Sum) value.getAggregations().get(FACET_MODE_EFFORT)).getValue())); } else { facet.put(value.getKey(), value.getDocCount()); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java index 1fa468e3704..9b37841d993 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java @@ -117,6 +117,9 @@ public class IssueDoc extends BaseDoc implements Issue { return getNullableField(IssueIndexDefinition.FIELD_ISSUE_LINE); } + /** + * @deprecated since 5.5, replaced by {@link #gap()} + */ @Deprecated @Override @CheckForNull @@ -127,7 +130,7 @@ public class IssueDoc extends BaseDoc implements Issue { @Override @CheckForNull public Double gap() { - return getNullableField(IssueIndexDefinition.FIELD_ISSUE_EFFORT); + return getNullableField(IssueIndexDefinition.FIELD_ISSUE_GAP); } @Override @@ -222,8 +225,12 @@ public class IssueDoc extends BaseDoc implements Issue { throw new IllegalStateException("isNew is only available for batch"); } + /** + * @deprecated since 5.5, replaced by {@link #effort()} + */ @Override @CheckForNull + @Deprecated public Duration debt() { throw new UnsupportedOperationException("debt is replaced by effort"); } @@ -231,8 +238,8 @@ public class IssueDoc extends BaseDoc implements Issue { @Override @CheckForNull public Duration effort() { - Number debt = getNullableField(IssueIndexDefinition.FIELD_ISSUE_DEBT); - return (debt != null) ? Duration.create(debt.longValue()) : null; + Number effort = getNullableField(IssueIndexDefinition.FIELD_ISSUE_EFFORT); + return (effort != null) ? Duration.create(effort.longValue()) : null; } @CheckForNull @@ -302,7 +309,7 @@ public class IssueDoc extends BaseDoc implements Issue { } public IssueDoc setGap(@Nullable Double d) { - setField(IssueIndexDefinition.FIELD_ISSUE_EFFORT, d); + setField(IssueIndexDefinition.FIELD_ISSUE_GAP, d); return this; } @@ -365,8 +372,8 @@ public class IssueDoc extends BaseDoc implements Issue { return this; } - public IssueDoc setDebt(@Nullable Long l) { - setField(IssueIndexDefinition.FIELD_ISSUE_DEBT, l); + public IssueDoc setEffort(@Nullable Long l) { + setField(IssueIndexDefinition.FIELD_ISSUE_EFFORT, l); return this; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java index a64a1465242..ae7d8934a49 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java @@ -80,9 +80,27 @@ import org.sonar.server.rule.index.RuleIndexDefinition; import org.sonar.server.search.StickyFacetBuilder; import org.sonar.server.user.UserSession; import org.sonar.server.view.index.ViewIndexDefinition; -import org.sonarqube.ws.client.issue.IssueFilterParameters; import static com.google.common.collect.Lists.newArrayList; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.ACTION_PLANS; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.ASSIGNEES; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.AUTHORS; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.CREATED_AT; +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_EFFORT; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.FILE_UUIDS; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.LANGUAGES; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.MODULE_UUIDS; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.PROJECT_UUIDS; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.REPORTERS; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.RESOLUTIONS; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.RULES; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.SEVERITIES; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.STATUSES; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.TAGS; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.TYPES; /** * The unique entry-point to interact with Elasticsearch index "issues". @@ -93,23 +111,23 @@ public class IssueIndex extends BaseIndex { private static final String SUBSTRING_MATCH_REGEXP = ".*%s.*"; public static final List<String> SUPPORTED_FACETS = ImmutableList.of( - IssueFilterParameters.SEVERITIES, - IssueFilterParameters.STATUSES, - IssueFilterParameters.RESOLUTIONS, - IssueFilterParameters.ACTION_PLANS, - IssueFilterParameters.PROJECT_UUIDS, - IssueFilterParameters.RULES, - IssueFilterParameters.ASSIGNEES, - IssueFilterParameters.FACET_ASSIGNED_TO_ME, - IssueFilterParameters.REPORTERS, - IssueFilterParameters.AUTHORS, - IssueFilterParameters.MODULE_UUIDS, - IssueFilterParameters.FILE_UUIDS, - IssueFilterParameters.DIRECTORIES, - IssueFilterParameters.LANGUAGES, - IssueFilterParameters.TAGS, - IssueFilterParameters.TYPES, - IssueFilterParameters.CREATED_AT); + SEVERITIES, + STATUSES, + RESOLUTIONS, + ACTION_PLANS, + PROJECT_UUIDS, + RULES, + ASSIGNEES, + FACET_ASSIGNED_TO_ME, + REPORTERS, + AUTHORS, + MODULE_UUIDS, + FILE_UUIDS, + DIRECTORIES, + LANGUAGES, + TAGS, + TYPES, + CREATED_AT); // TODO to be documented // TODO move to Facets ? @@ -117,9 +135,8 @@ public class IssueIndex extends BaseIndex { private static final String IS_ASSIGNED_FILTER = "__isAssigned"; - public static final String DEBT_AGGREGATION_NAME = "debt"; - private static final SumBuilder DEBT_AGGREGATION = AggregationBuilders.sum(DEBT_AGGREGATION_NAME).field(IssueIndexDefinition.FIELD_ISSUE_DEBT); - private static final Order DEBT_AGGREGATION_ORDER = Order.aggregation(DEBT_AGGREGATION_NAME, false); + private static final SumBuilder EFFORT_AGGREGATION = AggregationBuilders.sum(FACET_MODE_EFFORT).field(IssueIndexDefinition.FIELD_ISSUE_EFFORT); + private static final Order EFFORT_AGGREGATION_ORDER = Order.aggregation(FACET_MODE_EFFORT, false); private static final int DEFAULT_FACET_SIZE = 15; private static final Duration TWENTY_DAYS = Duration.standardDays(20L); @@ -381,77 +398,78 @@ public class IssueIndex extends BaseIndex { StickyFacetBuilder stickyFacetBuilder = newStickyFacetBuilder(query, filters, esQuery); // Execute Term aggregations addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.SEVERITIES, IssueIndexDefinition.FIELD_ISSUE_SEVERITY); + SEVERITIES, IssueIndexDefinition.FIELD_ISSUE_SEVERITY); addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.STATUSES, IssueIndexDefinition.FIELD_ISSUE_STATUS); + STATUSES, IssueIndexDefinition.FIELD_ISSUE_STATUS); addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.PROJECT_UUIDS, IssueIndexDefinition.FIELD_ISSUE_PROJECT_UUID, query.projectUuids().toArray()); + PROJECT_UUIDS, IssueIndexDefinition.FIELD_ISSUE_PROJECT_UUID, query.projectUuids().toArray()); addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.MODULE_UUIDS, IssueIndexDefinition.FIELD_ISSUE_MODULE_UUID, query.moduleUuids().toArray()); + MODULE_UUIDS, IssueIndexDefinition.FIELD_ISSUE_MODULE_UUID, query.moduleUuids().toArray()); addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.DIRECTORIES, IssueIndexDefinition.FIELD_ISSUE_DIRECTORY_PATH, query.directories().toArray()); + DIRECTORIES, IssueIndexDefinition.FIELD_ISSUE_DIRECTORY_PATH, query.directories().toArray()); addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.FILE_UUIDS, IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, query.fileUuids().toArray()); + FILE_UUIDS, IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, query.fileUuids().toArray()); addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.LANGUAGES, IssueIndexDefinition.FIELD_ISSUE_LANGUAGE, query.languages().toArray()); + LANGUAGES, IssueIndexDefinition.FIELD_ISSUE_LANGUAGE, query.languages().toArray()); addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.RULES, IssueIndexDefinition.FIELD_ISSUE_RULE_KEY, query.rules().toArray()); + RULES, IssueIndexDefinition.FIELD_ISSUE_RULE_KEY, query.rules().toArray()); addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.REPORTERS, IssueIndexDefinition.FIELD_ISSUE_REPORTER); + REPORTERS, IssueIndexDefinition.FIELD_ISSUE_REPORTER); addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, - IssueFilterParameters.AUTHORS, IssueIndexDefinition.FIELD_ISSUE_AUTHOR_LOGIN, query.authors().toArray()); + AUTHORS, IssueIndexDefinition.FIELD_ISSUE_AUTHOR_LOGIN, query.authors().toArray()); - if (options.getFacets().contains(IssueFilterParameters.TAGS)) { - esSearch.addAggregation(stickyFacetBuilder.buildStickyFacet(IssueIndexDefinition.FIELD_ISSUE_TAGS, IssueFilterParameters.TAGS, query.tags().toArray())); + if (options.getFacets().contains(TAGS)) { + esSearch.addAggregation(stickyFacetBuilder.buildStickyFacet(IssueIndexDefinition.FIELD_ISSUE_TAGS, TAGS, query.tags().toArray())); } - if (options.getFacets().contains(IssueFilterParameters.TYPES)) { - esSearch.addAggregation(stickyFacetBuilder.buildStickyFacet(IssueIndexDefinition.FIELD_ISSUE_TYPE, IssueFilterParameters.TYPES, query.types().toArray())); + if (options.getFacets().contains(TYPES)) { + esSearch.addAggregation(stickyFacetBuilder.buildStickyFacet(IssueIndexDefinition.FIELD_ISSUE_TYPE, TYPES, query.types().toArray())); } - if (options.getFacets().contains(IssueFilterParameters.RESOLUTIONS)) { + if (options.getFacets().contains(RESOLUTIONS)) { esSearch.addAggregation(createResolutionFacet(query, filters, esQuery)); } - if (options.getFacets().contains(IssueFilterParameters.ASSIGNEES)) { + if (options.getFacets().contains(ASSIGNEES)) { esSearch.addAggregation(createAssigneesFacet(query, filters, esQuery)); } addAssignedToMeFacetIfNeeded(esSearch, options, query, filters, esQuery); - if (options.getFacets().contains(IssueFilterParameters.ACTION_PLANS)) { + if (options.getFacets().contains(ACTION_PLANS)) { esSearch.addAggregation(createActionPlansFacet(query, filters, esQuery)); } - if (options.getFacets().contains(IssueFilterParameters.CREATED_AT)) { + if (options.getFacets().contains(CREATED_AT)) { esSearch.addAggregation(getCreatedAtFacet(query, filters, esQuery)); } } - if (IssueFilterParameters.FACET_MODE_DEBT.equals(query.facetMode())) { - esSearch.addAggregation(DEBT_AGGREGATION); + if (hasQueryEffortFacet(query)) { + esSearch.addAggregation(EFFORT_AGGREGATION); } } - private StickyFacetBuilder newStickyFacetBuilder(IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder esQuery) { - StickyFacetBuilder stickyFacetBuilder; - if (IssueFilterParameters.FACET_MODE_DEBT.equals(query.facetMode())) { - stickyFacetBuilder = new StickyFacetBuilder(esQuery, filters, DEBT_AGGREGATION, DEBT_AGGREGATION_ORDER); - } else { - stickyFacetBuilder = new StickyFacetBuilder(esQuery, filters); + private static StickyFacetBuilder newStickyFacetBuilder(IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder esQuery) { + if (hasQueryEffortFacet(query)) { + return new StickyFacetBuilder(esQuery, filters, EFFORT_AGGREGATION, EFFORT_AGGREGATION_ORDER); } - return stickyFacetBuilder; + return new StickyFacetBuilder(esQuery, filters); } - private void addSimpleStickyFacetIfNeeded(SearchOptions options, StickyFacetBuilder stickyFacetBuilder, SearchRequestBuilder esSearch, + private static void addSimpleStickyFacetIfNeeded(SearchOptions options, StickyFacetBuilder stickyFacetBuilder, SearchRequestBuilder esSearch, String facetName, String fieldName, Object... selectedValues) { if (options.getFacets().contains(facetName)) { esSearch.addAggregation(stickyFacetBuilder.buildStickyFacet(fieldName, facetName, DEFAULT_FACET_SIZE, selectedValues)); } } - private AggregationBuilder addDebtAggregationIfNeeded(IssueQuery query, AggregationBuilder aggregation) { - if (IssueFilterParameters.FACET_MODE_DEBT.equals(query.facetMode())) { - aggregation.subAggregation(DEBT_AGGREGATION); + private static AggregationBuilder addEffortAggregationIfNeeded(IssueQuery query, AggregationBuilder aggregation) { + if (hasQueryEffortFacet(query)) { + aggregation.subAggregation(EFFORT_AGGREGATION); } return aggregation; } + private static boolean hasQueryEffortFacet(IssueQuery query) { + return FACET_MODE_EFFORT.equals(query.facetMode()) || DEPRECATED_FACET_MODE_DEBT.equals(query.facetMode()); + } + private AggregationBuilder getCreatedAtFacet(IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder esQuery) { long now = system.now(); @@ -473,7 +491,7 @@ public class IssueIndex extends BaseIndex { bucketSize = DateHistogram.Interval.MONTH; } - AggregationBuilder dateHistogram = AggregationBuilders.dateHistogram(IssueFilterParameters.CREATED_AT) + AggregationBuilder dateHistogram = AggregationBuilders.dateHistogram(CREATED_AT) .field(IssueIndexDefinition.FIELD_ISSUE_FUNC_CREATED_AT) .interval(bucketSize) .minDocCount(0L) @@ -481,7 +499,7 @@ public class IssueIndex extends BaseIndex { .timeZone(timeZoneString) .postZone(timeZoneString) .extendedBounds(startTime, endTime); - dateHistogram = addDebtAggregationIfNeeded(query, dateHistogram); + dateHistogram = addEffortAggregationIfNeeded(query, dateHistogram); return dateHistogram; } @@ -514,7 +532,7 @@ public class IssueIndex extends BaseIndex { private AggregationBuilder createAssigneesFacet(IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder queryBuilder) { String fieldName = IssueIndexDefinition.FIELD_ISSUE_ASSIGNEE; - String facetName = IssueFilterParameters.ASSIGNEES; + String facetName = ASSIGNEES; // Same as in super.stickyFacetBuilder Map<String, FilterBuilder> assigneeFilters = Maps.newHashMap(filters); @@ -531,7 +549,7 @@ public class IssueIndex extends BaseIndex { // Add missing facet for unassigned issues facetTopAggregation.subAggregation( - addDebtAggregationIfNeeded(query, AggregationBuilders + addEffortAggregationIfNeeded(query, AggregationBuilders .missing(facetName + FACET_SUFFIX_MISSING) .field(fieldName))); @@ -552,12 +570,12 @@ public class IssueIndex extends BaseIndex { private void addAssignedToMeFacetIfNeeded(SearchRequestBuilder builder, SearchOptions options, IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder queryBuilder) { String login = userSession.getLogin(); - if (!options.getFacets().contains(IssueFilterParameters.FACET_ASSIGNED_TO_ME) || StringUtils.isEmpty(login)) { + if (!options.getFacets().contains(FACET_ASSIGNED_TO_ME) || StringUtils.isEmpty(login)) { return; } String fieldName = IssueIndexDefinition.FIELD_ISSUE_ASSIGNEE; - String facetName = IssueFilterParameters.FACET_ASSIGNED_TO_ME; + String facetName = FACET_ASSIGNED_TO_ME; // Same as in super.stickyFacetBuilder StickyFacetBuilder assignedToMeFacetBuilder = newStickyFacetBuilder(query, filters, queryBuilder); @@ -566,16 +584,16 @@ public class IssueIndex extends BaseIndex { FilterAggregationBuilder facetTopAggregation = AggregationBuilders .filter(facetName + "__filter") .filter(facetFilter) - .subAggregation(addDebtAggregationIfNeeded(query, AggregationBuilders.terms(facetName + "__terms").field(fieldName).include(login))); + .subAggregation(addEffortAggregationIfNeeded(query, AggregationBuilders.terms(facetName + "__terms").field(fieldName).include(login))); builder.addAggregation( AggregationBuilders.global(facetName) .subAggregation(facetTopAggregation)); } - private AggregationBuilder createResolutionFacet(IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder esQuery) { + private static AggregationBuilder createResolutionFacet(IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder esQuery) { String fieldName = IssueIndexDefinition.FIELD_ISSUE_RESOLUTION; - String facetName = IssueFilterParameters.RESOLUTIONS; + String facetName = RESOLUTIONS; // Same as in super.stickyFacetBuilder Map<String, FilterBuilder> resolutionFilters = Maps.newHashMap(filters); @@ -588,7 +606,7 @@ public class IssueIndex extends BaseIndex { // Add missing facet for unresolved issues facetTopAggregation.subAggregation( - addDebtAggregationIfNeeded(query, AggregationBuilders + addEffortAggregationIfNeeded(query, AggregationBuilders .missing(facetName + FACET_SUFFIX_MISSING) .field(fieldName))); @@ -597,9 +615,9 @@ public class IssueIndex extends BaseIndex { .subAggregation(facetTopAggregation); } - private AggregationBuilder createActionPlansFacet(IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder esQuery) { + private static AggregationBuilder createActionPlansFacet(IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder esQuery) { String fieldName = IssueIndexDefinition.FIELD_ISSUE_ACTION_PLAN; - String facetName = IssueFilterParameters.ACTION_PLANS; + String facetName = ACTION_PLANS; // Same as in super.stickyFacetBuilder Map<String, FilterBuilder> actionPlanFilters = Maps.newHashMap(filters); @@ -612,7 +630,7 @@ public class IssueIndex extends BaseIndex { // Add missing facet for unresolved issues facetTopAggregation.subAggregation( - addDebtAggregationIfNeeded(query, AggregationBuilders + addEffortAggregationIfNeeded(query, AggregationBuilders .missing(facetName + FACET_SUFFIX_MISSING) .field(fieldName))); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java index 1e019ce9a92..74116231c46 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java @@ -44,8 +44,8 @@ public class IssueIndexDefinition implements IndexDefinition { public static final String FIELD_ISSUE_ATTRIBUTES = "attributes"; public static final String FIELD_ISSUE_AUTHOR_LOGIN = "authorLogin"; public static final String FIELD_ISSUE_COMPONENT_UUID = "component"; - public static final String FIELD_ISSUE_DEBT = "debt"; public static final String FIELD_ISSUE_EFFORT = "effort"; + public static final String FIELD_ISSUE_GAP = "gap"; public static final String FIELD_ISSUE_FILE_PATH = "filePath"; /** * Functional date @@ -113,8 +113,8 @@ public class IssueIndexDefinition implements IndexDefinition { issueMapping.stringFieldBuilder(FIELD_ISSUE_ATTRIBUTES).docValues().disableSearch().build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_AUTHOR_LOGIN).docValues().build(); issueMapping.stringFieldBuilder(FIELD_ISSUE_COMPONENT_UUID).docValues().build(); - issueMapping.createLongField(FIELD_ISSUE_DEBT); - issueMapping.createDoubleField(FIELD_ISSUE_EFFORT); + issueMapping.createLongField(FIELD_ISSUE_EFFORT); + issueMapping.createDoubleField(FIELD_ISSUE_GAP); issueMapping.stringFieldBuilder(FIELD_ISSUE_FILE_PATH).enableSorting().build(); issueMapping.createDateTimeField(FIELD_ISSUE_FUNC_CREATED_AT); issueMapping.createDateTimeField(FIELD_ISSUE_FUNC_UPDATED_AT); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java index c9b569afb99..fa8e3c4009a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java @@ -173,7 +173,7 @@ class IssueResultSetIterator extends ResultSetIterator<IssueDoc> { doc.setManualSeverity(rs.getBoolean(12)); doc.setChecksum(rs.getString(13)); doc.setStatus(rs.getString(14)); - doc.setDebt(getLong(rs, 15)); + doc.setEffort(getLong(rs, 15)); doc.setReporter(rs.getString(16)); doc.setAuthorLogin(rs.getString(17)); doc.setFuncCloseDate(longToDate(getLong(rs, 18))); 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 6f1e87e29a9..115ffe639fa 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 @@ -130,7 +130,7 @@ public class SearchAction implements IssuesWsAction { 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.FACET_MODE_DEBT); + .setPossibleValues(IssueFilterParameters.FACET_MODE_COUNT, IssueFilterParameters.DEPRECATED_FACET_MODE_DEBT); action.addSortParams(IssueQuery.SORTS, null, true); action.createParam(IssueFilterParameters.ADDITIONAL_FIELDS) .setSince("5.2") 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 4bfcbd62410..2f0afe9d863 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 @@ -40,7 +40,7 @@ import org.sonar.server.es.Facets; import org.sonar.server.issue.ActionService; import org.sonar.server.issue.IssueCommentService; import org.sonar.server.issue.IssueService; -import org.sonar.server.issue.index.IssueIndex; +import org.sonarqube.ws.client.issue.IssueFilterParameters; import static com.google.common.collect.Lists.newArrayList; import static org.sonar.server.issue.ws.SearchAdditionalField.ACTIONS; @@ -152,7 +152,7 @@ public class SearchResponseLoader { private void completeTotalDebtFromFacet(@Nullable Facets facets, SearchResponseData result) { if (facets != null) { - Map<String, Long> debtFacet = facets.get(IssueIndex.DEBT_AGGREGATION_NAME); + Map<String, Long> debtFacet = facets.get(IssueFilterParameters.FACET_MODE_EFFORT); if (debtFacet != null) { result.setDebtTotal(debtFacet.get(Facets.TOTAL)); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java index 862284fbfad..40acd958b67 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java @@ -341,7 +341,7 @@ public class IssueServiceMediumTest { assertThat(manualIssue.message()).isEqualTo("Fix it"); assertThat(manualIssue.line()).isEqualTo(1); assertThat(manualIssue.severity()).isEqualTo(Severity.MINOR); - assertThat(manualIssue.effortToFix()).isNull(); + assertThat(manualIssue.gap()).isNull(); assertThat(manualIssue.reporter()).isEqualTo("john"); assertThat(manualIssue.assignee()).isEqualTo("arthur"); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java index 0dc4759ed23..b2a5252f2c4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java @@ -83,7 +83,7 @@ public class IssueTesting { doc.setResolution(null); doc.setSeverity(Severity.MAJOR); doc.setManualSeverity(true); - doc.setDebt(10L); + doc.setEffort(10L); doc.setChecksum("12345"); doc.setFuncCreationDate(DateUtils.parseDate("2014-09-04")); doc.setFuncUpdateDate(DateUtils.parseDate("2014-12-04")); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java index cd72beb5efc..28f01d7342e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java @@ -42,7 +42,6 @@ import org.sonar.server.es.SearchResult; import org.sonar.server.issue.IssueQuery; import org.sonar.server.issue.IssueQuery.Builder; import org.sonar.server.issue.IssueTesting; -import org.sonarqube.ws.client.issue.IssueFilterParameters; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.view.index.ViewIndexDefinition; import org.sonar.server.view.index.ViewIndexer; @@ -52,6 +51,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.DEPRECATED_FACET_MODE_DEBT; +import static org.sonarqube.ws.client.issue.IssueFilterParameters.FACET_MODE_EFFORT; public class IssueIndexDebtTest { @@ -77,7 +78,6 @@ public class IssueIndexDebtTest { when(system.now()).thenReturn(System.currentTimeMillis()); index = new IssueIndex(tester.client(), system, userSessionRule); - } @Test @@ -86,14 +86,15 @@ public class IssueIndexDebtTest { ComponentDto project2 = ComponentTesting.newProjectDto("EFGH"); indexIssues( - IssueTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project)), - IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project)), - IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2))); + IssueTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project)).setEffort(10L), + IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project)).setEffort(10L), + IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2)).setEffort(10L)); - SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("projectUuids"))); - assertThat(result.getFacets().getNames()).containsOnly("projectUuids", "debt"); + SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), + new SearchOptions().addFacets(newArrayList("projectUuids"))); + assertThat(result.getFacets().getNames()).containsOnly("projectUuids", FACET_MODE_EFFORT); assertThat(result.getFacets().get("projectUuids")).containsOnly(entry("ABCD", 20L), entry("EFGH", 10L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 30L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 30L)); } @Test @@ -111,10 +112,10 @@ public class IssueIndexDebtTest { IssueTesting.newDoc("ISSUE5", file3)); SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("fileUuids"))); - assertThat(result.getFacets().getNames()).containsOnly("fileUuids", "debt"); + assertThat(result.getFacets().getNames()).containsOnly("fileUuids", FACET_MODE_EFFORT); assertThat(result.getFacets().get("fileUuids")) .containsOnly(entry("A", 10L), entry("ABCD", 10L), entry("BCDE", 20L), entry("CDEF", 10L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 50L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 50L)); } @Test @@ -128,9 +129,9 @@ public class IssueIndexDebtTest { IssueTesting.newDoc("ISSUE2", file2).setDirectoryPath("/")); SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("directories"))); - assertThat(result.getFacets().getNames()).containsOnly("directories", "debt"); + assertThat(result.getFacets().getNames()).containsOnly("directories", FACET_MODE_EFFORT); assertThat(result.getFacets().get("directories")).containsOnly(entry("/src/main/xoo", 10L), entry("/", 10L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 20L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 20L)); } @Test @@ -144,9 +145,9 @@ public class IssueIndexDebtTest { IssueTesting.newDoc("ISSUE3", file).setSeverity(Severity.MAJOR)); SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("severities"))); - assertThat(result.getFacets().getNames()).containsOnly("severities", "debt"); + assertThat(result.getFacets().getNames()).containsOnly("severities", FACET_MODE_EFFORT); assertThat(result.getFacets().get("severities")).containsOnly(entry("INFO", 20L), entry("MAJOR", 10L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 30L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 30L)); } @Test @@ -160,9 +161,9 @@ public class IssueIndexDebtTest { IssueTesting.newDoc("ISSUE3", file).setStatus(Issue.STATUS_OPEN)); SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("statuses"))); - assertThat(result.getFacets().getNames()).containsOnly("statuses", "debt"); + assertThat(result.getFacets().getNames()).containsOnly("statuses", FACET_MODE_EFFORT); assertThat(result.getFacets().get("statuses")).containsOnly(entry("CLOSED", 20L), entry("OPEN", 10L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 30L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 30L)); } @Test @@ -176,9 +177,9 @@ public class IssueIndexDebtTest { IssueTesting.newDoc("ISSUE3", file).setResolution(Issue.RESOLUTION_FIXED)); SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("resolutions"))); - assertThat(result.getFacets().getNames()).containsOnly("resolutions", "debt"); + assertThat(result.getFacets().getNames()).containsOnly("resolutions", FACET_MODE_EFFORT); assertThat(result.getFacets().get("resolutions")).containsOnly(entry("FALSE-POSITIVE", 20L), entry("FIXED", 10L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 30L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 30L)); } @Test @@ -191,9 +192,9 @@ public class IssueIndexDebtTest { IssueTesting.newDoc("ISSUE2", file).setActionPlanKey("plan2")); SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("actionPlans"))); - assertThat(result.getFacets().getNames()).containsOnly("actionPlans", "debt"); + assertThat(result.getFacets().getNames()).containsOnly("actionPlans", FACET_MODE_EFFORT); assertThat(result.getFacets().get("actionPlans")).containsOnly(entry("plan1", 10L), entry("plan2", 10L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 20L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 20L)); } @Test @@ -202,12 +203,12 @@ public class IssueIndexDebtTest { ComponentDto file = ComponentTesting.newFileDto(project); RuleKey ruleKey = RuleKey.of("repo", "X1"); - indexIssues(IssueTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo")); + indexIssues(IssueTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo").setEffort(10L)); SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("languages"))); - assertThat(result.getFacets().getNames()).containsOnly("languages", "debt"); + assertThat(result.getFacets().getNames()).containsOnly("languages", FACET_MODE_EFFORT); assertThat(result.getFacets().get("languages")).containsOnly(entry("xoo", 10L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 10L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 10L)); } @Test @@ -222,9 +223,9 @@ public class IssueIndexDebtTest { IssueTesting.newDoc("ISSUE4", file).setAssignee(null)); SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("assignees"))); - assertThat(result.getFacets().getNames()).containsOnly("assignees", "debt"); + assertThat(result.getFacets().getNames()).containsOnly("assignees", FACET_MODE_EFFORT); assertThat(result.getFacets().get("assignees")).containsOnly(entry("steph", 10L), entry("simon", 20L), entry("", 10L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 40L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 40L)); } @Test @@ -239,9 +240,9 @@ public class IssueIndexDebtTest { IssueTesting.newDoc("ISSUE4", file).setAuthorLogin(null)); SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("authors"))); - assertThat(result.getFacets().getNames()).containsOnly("authors", "debt"); + assertThat(result.getFacets().getNames()).containsOnly("authors", FACET_MODE_EFFORT); assertThat(result.getFacets().get("authors")).containsOnly(entry("steph", 10L), entry("simon", 20L)); - assertThat(result.getFacets().get("debt")).containsOnly(entry("total", 40L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 40L)); } @Test @@ -259,6 +260,23 @@ public class IssueIndexDebtTest { entry("2015-01-01T00:00:00+0000", 10L)); } + @Test + public void deprecated_debt_facets() { + ComponentDto project = ComponentTesting.newProjectDto("ABCD"); + ComponentDto project2 = ComponentTesting.newProjectDto("EFGH"); + + indexIssues( + IssueTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project)).setEffort(10L), + IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project)).setEffort(10L), + IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2)).setEffort(10L)); + + SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).facetMode(DEPRECATED_FACET_MODE_DEBT).build(), + new SearchOptions().addFacets(newArrayList("projectUuids"))); + assertThat(result.getFacets().getNames()).containsOnly("projectUuids", FACET_MODE_EFFORT); + assertThat(result.getFacets().get("projectUuids")).containsOnly(entry("ABCD", 20L), entry("EFGH", 10L)); + assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 30L)); + } + protected SearchOptions fixtureForCreatedAtFacet() { ComponentDto project = ComponentTesting.newProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project); @@ -288,6 +306,6 @@ public class IssueIndexDebtTest { } private Builder newQueryBuilder() { - return IssueQuery.builder(userSessionRule).facetMode(IssueFilterParameters.FACET_MODE_DEBT); + return IssueQuery.builder(userSessionRule).facetMode(FACET_MODE_EFFORT); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java index b4409b48f81..b6d18f17851 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java @@ -40,6 +40,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.Severity; import org.sonar.api.security.DefaultGroups; import org.sonar.api.utils.DateUtils; +import org.sonar.api.utils.Duration; import org.sonar.api.utils.KeyValueFormat; import org.sonar.api.utils.System2; import org.sonar.db.component.ComponentDto; @@ -86,18 +87,21 @@ public class IssueIndexTest { when(system.now()).thenReturn(System.currentTimeMillis()); index = new IssueIndex(tester.client(), system, userSessionRule); - } @Test public void get_by_key() { ComponentDto project = ComponentTesting.newProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project); - IssueDoc issue = IssueTesting.newDoc("ISSUE1", file); + IssueDoc issue = IssueTesting.newDoc("ISSUE1", file) + .setEffort(100L); indexIssues(issue); Issue loaded = index.getByKey(issue.key()); assertThat(loaded).isNotNull(); + + assertThat(loaded.key()).isEqualTo("ISSUE1"); + assertThat(loaded.effort()).isEqualTo(Duration.create(100L)); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueResultSetIteratorTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueResultSetIteratorTest.java index 50768cd4c0a..b86450a500a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueResultSetIteratorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueResultSetIteratorTest.java @@ -80,8 +80,8 @@ public class IssueResultSetIteratorTest { assertThat(issue.directoryPath()).isEqualTo("src/main/java"); assertThat(issue.filePath()).isEqualTo("src/main/java/Action.java"); assertThat(issue.tags()).containsOnly("tag1", "tag2", "tag3"); - assertThat(issue.debt().toMinutes()).isGreaterThan(0L); - assertThat(issue.effortToFix()).isEqualTo(2d); + assertThat(issue.effort().toMinutes()).isGreaterThan(0L); + assertThat(issue.gap()).isEqualTo(2d); assertThat(issue.actionPlanKey()).isEqualTo("PLAN1"); assertThat(issue.attribute("JIRA")).isEqualTo("http://jira.com"); assertThat(issue.type().getDbConstant()).isEqualTo(2); @@ -106,7 +106,7 @@ public class IssueResultSetIteratorTest { assertThat(issue.directoryPath()).isEqualTo("src/main/java"); assertThat(issue.filePath()).isEqualTo("src/main/java/Action.java"); assertThat(issue.tags()).containsOnly("tag1", "tag2", "tag3"); - assertThat(issue.debt().toMinutes()).isGreaterThan(0L); + assertThat(issue.effort().toMinutes()).isGreaterThan(0L); assertThat(issue.type().getDbConstant()).isEqualTo(1); issue = issuesByKey.get("BCD"); @@ -119,7 +119,7 @@ public class IssueResultSetIteratorTest { assertThat(issue.directoryPath()).isNull(); assertThat(issue.filePath()).isNull(); assertThat(issue.tags()).containsOnly("tag1", "tag2", "tag3"); - assertThat(issue.debt().toMinutes()).isGreaterThan(0L); + assertThat(issue.effort().toMinutes()).isGreaterThan(0L); assertThat(issue.type().getDbConstant()).isEqualTo(2); issue = issuesByKey.get("DEF"); @@ -132,7 +132,7 @@ public class IssueResultSetIteratorTest { assertThat(issue.directoryPath()).isEqualTo("src/main/java"); assertThat(issue.filePath()).isEqualTo("src/main/java/Action.java"); assertThat(issue.tags()).isEmpty(); - assertThat(issue.debt().toMinutes()).isGreaterThan(0L); + assertThat(issue.effort().toMinutes()).isGreaterThan(0L); assertThat(issue.type().getDbConstant()).isEqualTo(1); issue = issuesByKey.get("EFG"); @@ -145,7 +145,7 @@ public class IssueResultSetIteratorTest { assertThat(issue.directoryPath()).isEqualTo("src/main/java"); assertThat(issue.filePath()).isEqualTo("src/main/java"); assertThat(issue.tags()).isEmpty(); - assertThat(issue.debt().toMinutes()).isGreaterThan(0L); + assertThat(issue.effort().toMinutes()).isGreaterThan(0L); assertThat(issue.type().getDbConstant()).isEqualTo(1); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java index 5dd58351754..4d32a2de799 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java @@ -71,7 +71,12 @@ public class IssueFilterParameters { public static final String FACET_MODE = "facetMode"; public static final String FACET_MODE_COUNT = "count"; - public static final String FACET_MODE_DEBT = "debt"; + /** + * @deprecated since 5.5, replaced by {@link #FACET_MODE_EFFORT} + */ + @Deprecated + public static final String DEPRECATED_FACET_MODE_DEBT = "debt"; + public static final String FACET_MODE_EFFORT = "effort"; public static final String FACET_ASSIGNED_TO_ME = "assigned_to_me"; |