diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-02-17 14:35:56 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-02-22 10:30:38 +0100 |
commit | d9d8c89a09535439ecd95bb8e3b3301bdcdcd437 (patch) | |
tree | bc890691d2a970de42d8b39bf31bb20e3e9a6138 | |
parent | 3187af03e7fb252ce14f3a4179287a49ceac7956 (diff) | |
download | sonarqube-d9d8c89a09535439ecd95bb8e3b3301bdcdcd437.tar.gz sonarqube-d9d8c89a09535439ecd95bb8e3b3301bdcdcd437.zip |
SONAR-8803 Rename qualityGate to qualityGateStatus in project measures index
6 files changed, 44 insertions, 45 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java index 82f8ccd86dc..f70c580096f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java @@ -39,7 +39,6 @@ import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIEL import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_MEASURES_VALUE; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_NAME; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_ORGANIZATION_UUID; -import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_QUALITY_GATE; public class ProjectMeasuresDoc extends BaseDoc { @@ -134,12 +133,12 @@ public class ProjectMeasuresDoc extends BaseDoc { } @CheckForNull - public String getQualityGate() { - return getField(FIELD_QUALITY_GATE); + public String getQualityGateStatus() { + return getField(ProjectMeasuresIndexDefinition.FIELD_QUALITY_GATE_STATUS); } - public ProjectMeasuresDoc setQualityGate(@Nullable String s) { - setField(FIELD_QUALITY_GATE, s); + public ProjectMeasuresDoc setQualityGateStatus(@Nullable String s) { + setField(ProjectMeasuresIndexDefinition.FIELD_QUALITY_GATE_STATUS, s); return this; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java index 73f43121cac..7acdc720493 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java @@ -65,7 +65,7 @@ import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIEL import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_MEASURES; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_NAME; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_ORGANIZATION_UUID; -import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_QUALITY_GATE; +import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_QUALITY_GATE_STATUS; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.INDEX_PROJECT_MEASURES; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.TYPE_PROJECT_MEASURE; import static org.sonar.server.measure.index.ProjectMeasuresQuery.SORT_BY_NAME; @@ -210,9 +210,9 @@ public class ProjectMeasuresIndex extends BaseIndex { private static AbstractAggregationBuilder createQualityGateFacet() { return AggregationBuilders.filters(ALERT_STATUS_KEY) - .filter(Metric.Level.ERROR.name(), termQuery(FIELD_QUALITY_GATE, Metric.Level.ERROR.name())) - .filter(Metric.Level.WARN.name(), termQuery(FIELD_QUALITY_GATE, Metric.Level.WARN.name())) - .filter(Metric.Level.OK.name(), termQuery(FIELD_QUALITY_GATE, Metric.Level.OK.name())); + .filter(Metric.Level.ERROR.name(), termQuery(FIELD_QUALITY_GATE_STATUS, Metric.Level.ERROR.name())) + .filter(Metric.Level.WARN.name(), termQuery(FIELD_QUALITY_GATE_STATUS, Metric.Level.WARN.name())) + .filter(Metric.Level.OK.name(), termQuery(FIELD_QUALITY_GATE_STATUS, Metric.Level.OK.name())); } private static AbstractAggregationBuilder createLanguagesFacet() { @@ -243,7 +243,7 @@ public class ProjectMeasuresIndex extends BaseIndex { }); query.getQualityGateStatus() - .ifPresent(qualityGateStatus -> filters.put(ALERT_STATUS_KEY, termQuery(FIELD_QUALITY_GATE, qualityGateStatus.name()))); + .ifPresent(qualityGateStatus -> filters.put(ALERT_STATUS_KEY, termQuery(FIELD_QUALITY_GATE_STATUS, qualityGateStatus.name()))); query.getProjectUuids() .ifPresent(projectUuids -> filters.put("ids", termsQuery("_id", projectUuids))); diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexDefinition.java index 8ed669531cb..5a3558b127a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexDefinition.java @@ -34,7 +34,7 @@ public class ProjectMeasuresIndexDefinition implements IndexDefinition { public static final String FIELD_KEY = "key"; public static final String FIELD_NAME = "name"; public static final String FIELD_ANALYSED_AT = "analysedAt"; - public static final String FIELD_QUALITY_GATE = "qualityGate"; + public static final String FIELD_QUALITY_GATE_STATUS = "qualityGateStatus"; public static final String FIELD_MEASURES = "measures"; public static final String FIELD_MEASURES_KEY = "key"; public static final String FIELD_MEASURES_VALUE = "value"; @@ -60,7 +60,7 @@ public class ProjectMeasuresIndexDefinition implements IndexDefinition { mapping.stringFieldBuilder(FIELD_ORGANIZATION_UUID).build(); mapping.stringFieldBuilder(FIELD_KEY).disableNorms().build(); mapping.stringFieldBuilder(FIELD_NAME).addSubFields(SORTABLE_ANALYZER).build(); - mapping.stringFieldBuilder(FIELD_QUALITY_GATE).build(); + mapping.stringFieldBuilder(FIELD_QUALITY_GATE_STATUS).build(); mapping.createDateTimeField(FIELD_ANALYSED_AT); mapping.nestedFieldBuilder(FIELD_MEASURES) .addStringField(FIELD_MEASURES_KEY) diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java index 383bebbf460..6bcce25f79b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java @@ -130,7 +130,7 @@ public class ProjectMeasuresIndexer extends BaseIndexer implements ProjectIndexe .setOrganizationUuid(project.getOrganizationUuid()) .setKey(project.getKey()) .setName(project.getName()) - .setQualityGate(projectMeasures.getMeasures().getQualityGateStatus()) + .setQualityGateStatus(projectMeasures.getMeasures().getQualityGateStatus()) .setAnalysedAt(analysisDate == null ? null : new Date(analysisDate)) .setMeasuresFromMap(projectMeasures.getMeasures().getNumericMeasures()) .setLanguages(projectMeasures.getMeasures().getLanguageDistribution()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java index 4d0c9638567..86d782657f5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java @@ -540,7 +540,7 @@ public class SearchProjectsActionTest { .setKey(project.key()) .setName(project.name()) .setMeasures(measures) - .setQualityGate(qualityGateStatus) + .setQualityGateStatus(qualityGateStatus) .setLanguages(languagesDistribution)); authorizationIndexerTester.allowOnlyAnyone(project); } catch (Exception e) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java index d3d0b460894..03e5d6a92a0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java @@ -239,9 +239,9 @@ public class ProjectMeasuresIndexTest { @Test public void filter_on_quality_gate_status() { index( - newDoc(PROJECT1).setQualityGate("OK"), - newDoc(PROJECT2).setQualityGate("OK"), - newDoc(PROJECT3).setQualityGate("WARN")); + newDoc(PROJECT1).setQualityGateStatus("OK"), + newDoc(PROJECT2).setQualityGateStatus("OK"), + newDoc(PROJECT3).setQualityGateStatus("WARN")); ProjectMeasuresQuery query = new ProjectMeasuresQuery().setQualityGateStatus(OK); assertResults(query, PROJECT1, PROJECT2); @@ -339,7 +339,7 @@ public class ProjectMeasuresIndexTest { public void does_not_return_facet_when_no_facets_in_options() throws Exception { index( newDoc(PROJECT1, NCLOC, 10d, COVERAGE_KEY, 30d, MAINTAINABILITY_RATING, 3d) - .setQualityGate(OK.name())); + .setQualityGateStatus(OK.name())); Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions()).getFacets(); @@ -846,17 +846,17 @@ public class ProjectMeasuresIndexTest { public void facet_quality_gate() { index( // 2 docs with QG OK - newDoc().setQualityGate(OK.name()), - newDoc().setQualityGate(OK.name()), + newDoc().setQualityGateStatus(OK.name()), + newDoc().setQualityGateStatus(OK.name()), // 3 docs with QG WARN - newDoc().setQualityGate(WARN.name()), - newDoc().setQualityGate(WARN.name()), - newDoc().setQualityGate(WARN.name()), + newDoc().setQualityGateStatus(WARN.name()), + newDoc().setQualityGateStatus(WARN.name()), + newDoc().setQualityGateStatus(WARN.name()), // 4 docs with QG ERROR - newDoc().setQualityGate(ERROR.name()), - newDoc().setQualityGate(ERROR.name()), - newDoc().setQualityGate(ERROR.name()), - newDoc().setQualityGate(ERROR.name())); + newDoc().setQualityGateStatus(ERROR.name()), + newDoc().setQualityGateStatus(ERROR.name()), + newDoc().setQualityGateStatus(ERROR.name()), + newDoc().setQualityGateStatus(ERROR.name())); LinkedHashMap<String, Long> result = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(ALERT_STATUS_KEY)).getFacets().get(ALERT_STATUS_KEY); @@ -870,17 +870,17 @@ public class ProjectMeasuresIndexTest { public void facet_quality_gate_is_sticky() { index( // 2 docs with QG OK - newDoc(NCLOC, 10d, COVERAGE, 0d).setQualityGate(OK.name()), - newDoc(NCLOC, 10d, COVERAGE, 0d).setQualityGate(OK.name()), + newDoc(NCLOC, 10d, COVERAGE, 0d).setQualityGateStatus(OK.name()), + newDoc(NCLOC, 10d, COVERAGE, 0d).setQualityGateStatus(OK.name()), // 3 docs with QG WARN - newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGate(WARN.name()), - newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGate(WARN.name()), - newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGate(WARN.name()), + newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGateStatus(WARN.name()), + newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGateStatus(WARN.name()), + newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGateStatus(WARN.name()), // 4 docs with QG ERROR - newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGate(ERROR.name()), - newDoc(NCLOC, 5000d, COVERAGE, 40d).setQualityGate(ERROR.name()), - newDoc(NCLOC, 12000d, COVERAGE, 50d).setQualityGate(ERROR.name()), - newDoc(NCLOC, 13000d, COVERAGE, 60d).setQualityGate(ERROR.name())); + newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGateStatus(ERROR.name()), + newDoc(NCLOC, 5000d, COVERAGE, 40d).setQualityGateStatus(ERROR.name()), + newDoc(NCLOC, 12000d, COVERAGE, 50d).setQualityGateStatus(ERROR.name()), + newDoc(NCLOC, 13000d, COVERAGE, 60d).setQualityGateStatus(ERROR.name())); Facets facets = underTest.search(new ProjectMeasuresQuery() .setQualityGateStatus(ERROR) @@ -906,20 +906,20 @@ public class ProjectMeasuresIndexTest { // User can see these projects indexForUser(USER1, // 2 docs with QG OK - newDoc().setQualityGate(OK.name()), - newDoc().setQualityGate(OK.name()), + newDoc().setQualityGateStatus(OK.name()), + newDoc().setQualityGateStatus(OK.name()), // 3 docs with QG WARN - newDoc().setQualityGate(WARN.name()), - newDoc().setQualityGate(WARN.name()), - newDoc().setQualityGate(WARN.name())); + newDoc().setQualityGateStatus(WARN.name()), + newDoc().setQualityGateStatus(WARN.name()), + newDoc().setQualityGateStatus(WARN.name())); // User cannot see these projects indexForUser(USER2, // 4 docs with QG ERROR - newDoc().setQualityGate(ERROR.name()), - newDoc().setQualityGate(ERROR.name()), - newDoc().setQualityGate(ERROR.name()), - newDoc().setQualityGate(ERROR.name())); + newDoc().setQualityGateStatus(ERROR.name()), + newDoc().setQualityGateStatus(ERROR.name()), + newDoc().setQualityGateStatus(ERROR.name()), + newDoc().setQualityGateStatus(ERROR.name())); userSession.logIn(USER1); LinkedHashMap<String, Long> result = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(ALERT_STATUS_KEY)).getFacets().get(ALERT_STATUS_KEY); |