diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-11-01 15:59:15 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-11-01 15:59:15 +0100 |
commit | 72f25528086e0578f34c857cc7d675c952bb355e (patch) | |
tree | 6cc77e35edaed13bd8f47233d76bf1d92f66f807 /plugins | |
parent | 8b2339eb3b353d8cece0a8851f35ab8844a1985a (diff) | |
download | sonarqube-72f25528086e0578f34c857cc7d675c952bb355e.tar.gz sonarqube-72f25528086e0578f34c857cc7d675c952bb355e.zip |
SONAR-2952 Make the coverage tab support integration test measures
Diffstat (limited to 'plugins')
16 files changed, 103 insertions, 571 deletions
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java index 811efa13f8a..18be4847537 100644 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java +++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java @@ -19,14 +19,13 @@ */ package org.sonar.plugins.jacoco; -import java.util.Arrays; -import java.util.List; - -import org.sonar.api.Plugin; import org.sonar.api.Properties; import org.sonar.api.Property; +import org.sonar.api.SonarPlugin; import org.sonar.plugins.jacoco.itcoverage.*; -import org.sonar.plugins.jacoco.itcoverage.viewer.CoverageViewerDefinition; + +import java.util.Arrays; +import java.util.List; @Properties({ @Property( @@ -87,20 +86,7 @@ import org.sonar.plugins.jacoco.itcoverage.viewer.CoverageViewerDefinition; module = true, project = true ) }) -public class JaCoCoPlugin implements Plugin { - - public String getKey() { - return "jacoco"; - } - - public String getName() { - return "JaCoCo"; - } - - public String getDescription() { - return "<a href='http://www.eclemma.org/jacoco/'>JaCoCo</a> calculates coverage of unit tests." + - " Set the parameter 'Code coverage plugin' to <code>jacoco</code> in the General plugin."; - } +public class JaCoCoPlugin extends SonarPlugin { public List getExtensions() { return Arrays.asList( @@ -115,18 +101,10 @@ public class JaCoCoPlugin implements Plugin { JaCoCoSensor.class, // Integration tests - JaCoCoItMetrics.class, JaCoCoItSensor.class, ItCoverageWidget.class, ItCoverageDecorator.class, ItLineCoverageDecorator.class, - ItBranchCoverageDecorator.class, - CoverageViewerDefinition.class); + ItBranchCoverageDecorator.class); } - - @Override - public String toString() { - return getKey(); - } - } diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItBranchCoverageDecorator.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItBranchCoverageDecorator.java index d3a4147806a..6c7da52a085 100644 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItBranchCoverageDecorator.java +++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItBranchCoverageDecorator.java @@ -21,6 +21,7 @@ package org.sonar.plugins.jacoco.itcoverage; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.DependsUpon; +import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.MeasureUtils; import org.sonar.api.measures.Metric; @@ -33,23 +34,23 @@ import java.util.List; public final class ItBranchCoverageDecorator extends AbstractCoverageDecorator { @Override protected Metric getTargetMetric() { - return JaCoCoItMetrics.IT_BRANCH_COVERAGE; + return CoreMetrics.IT_BRANCH_COVERAGE; } @DependsUpon public List<Metric> dependsUponMetrics() { - return Arrays.asList(JaCoCoItMetrics.IT_UNCOVERED_CONDITIONS, JaCoCoItMetrics.IT_CONDITIONS_TO_COVER); + return Arrays.asList(CoreMetrics.IT_UNCOVERED_CONDITIONS, CoreMetrics.IT_CONDITIONS_TO_COVER); } @Override protected Double countCoveredElements(DecoratorContext context) { - double uncoveredConditions = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_UNCOVERED_CONDITIONS), 0.0); - double conditions = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_CONDITIONS_TO_COVER), 0.0); + double uncoveredConditions = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS), 0.0); + double conditions = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER), 0.0); return conditions - uncoveredConditions; } @Override protected Double countElements(DecoratorContext context) { - return MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_CONDITIONS_TO_COVER), 0.0); + return MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER), 0.0); } } diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageDecorator.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageDecorator.java index 49e02905895..f1bb7c63f4d 100644 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageDecorator.java +++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageDecorator.java @@ -21,6 +21,7 @@ package org.sonar.plugins.jacoco.itcoverage; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.DependsUpon; +import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.MeasureUtils; import org.sonar.api.measures.Metric; @@ -34,27 +35,27 @@ public class ItCoverageDecorator extends AbstractCoverageDecorator { @Override protected Metric getTargetMetric() { - return JaCoCoItMetrics.IT_COVERAGE; + return CoreMetrics.IT_COVERAGE; } @DependsUpon public List<Metric> dependsUponMetrics() { - return Arrays.asList(JaCoCoItMetrics.IT_LINES_TO_COVER, JaCoCoItMetrics.IT_UNCOVERED_LINES, JaCoCoItMetrics.IT_CONDITIONS_TO_COVER, JaCoCoItMetrics.IT_UNCOVERED_CONDITIONS); + return Arrays.asList(CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.IT_CONDITIONS_TO_COVER, CoreMetrics.IT_UNCOVERED_CONDITIONS); } @Override protected Double countCoveredElements(DecoratorContext context) { - double uncoveredLines = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_UNCOVERED_LINES), 0.0); - double lines = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_LINES_TO_COVER), 0.0); - double uncoveredConditions = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_UNCOVERED_CONDITIONS), 0.0); - double conditions = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_CONDITIONS_TO_COVER), 0.0); + double uncoveredLines = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_UNCOVERED_LINES), 0.0); + double lines = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER), 0.0); + double uncoveredConditions = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS), 0.0); + double conditions = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER), 0.0); return lines + conditions - uncoveredConditions - uncoveredLines; } @Override protected Double countElements(DecoratorContext context) { - double lines = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_LINES_TO_COVER), 0.0); - double conditions = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_CONDITIONS_TO_COVER), 0.0); + double lines = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER), 0.0); + double conditions = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER), 0.0); return lines + conditions; } diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItLineCoverageDecorator.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItLineCoverageDecorator.java index 797c3f36bd7..c5e8e3bde33 100644 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItLineCoverageDecorator.java +++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItLineCoverageDecorator.java @@ -21,6 +21,7 @@ package org.sonar.plugins.jacoco.itcoverage; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.DependsUpon; +import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.MeasureUtils; import org.sonar.api.measures.Metric; @@ -33,23 +34,23 @@ import java.util.List; public class ItLineCoverageDecorator extends AbstractCoverageDecorator { @Override protected Metric getTargetMetric() { - return JaCoCoItMetrics.IT_LINE_COVERAGE; + return CoreMetrics.IT_LINE_COVERAGE; } @DependsUpon public List<Metric> dependsUponMetrics() { - return Arrays.asList(JaCoCoItMetrics.IT_UNCOVERED_LINES, JaCoCoItMetrics.IT_LINES_TO_COVER); + return Arrays.asList(CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.IT_LINES_TO_COVER); } @Override protected Double countCoveredElements(DecoratorContext context) { - double uncoveredLines = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_UNCOVERED_LINES), 0.0); - double lines = MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_LINES_TO_COVER), 0.0); + double uncoveredLines = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_UNCOVERED_LINES), 0.0); + double lines = MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER), 0.0); return lines - uncoveredLines; } @Override protected Double countElements(DecoratorContext context) { - return MeasureUtils.getValue(context.getMeasure(JaCoCoItMetrics.IT_LINES_TO_COVER), 0.0); + return MeasureUtils.getValue(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER), 0.0); } } diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItMetrics.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItMetrics.java deleted file mode 100644 index 591d737ff81..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItMetrics.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.jacoco.itcoverage; - -import org.sonar.api.measures.Metric; -import org.sonar.api.measures.Metrics; -import org.sonar.api.measures.SumChildValuesFormula; - -import java.util.Arrays; -import java.util.List; - -/** - * Should be in {@link org.sonar.api.measures.CoreMetrics} - * - * @author Evgeny Mandrikov - */ -public final class JaCoCoItMetrics implements Metrics { - - public static final String DOMAIN_IT_TESTS = "Integration Tests"; - - public static final String IT_COVERAGE_KEY = "it_coverage"; - public static final Metric IT_COVERAGE = new Metric.Builder(IT_COVERAGE_KEY, "IT Coverage", Metric.ValueType.PERCENT) - .setDescription("Coverage by integration tests") - .setDirection(Metric.DIRECTION_BETTER) - .setQualitative(true) - .setDomain(DOMAIN_IT_TESTS) - .setWorstValue(0.0) - .setBestValue(100.0) - .create(); - - public static final String IT_LINES_TO_COVER_KEY = "it_lines_to_cover"; - public static final Metric IT_LINES_TO_COVER = new Metric.Builder(IT_LINES_TO_COVER_KEY, "IT lines to cover", Metric.ValueType.INT) - .setDescription("IT lines to cover") - .setDirection(Metric.DIRECTION_BETTER) - .setDomain(DOMAIN_IT_TESTS) - .setQualitative(false) - .setFormula(new SumChildValuesFormula(false)) - .setHidden(true) - .create(); - - public static final String IT_UNCOVERED_LINES_KEY = "it_uncovered_lines"; - public static final Metric IT_UNCOVERED_LINES = new Metric.Builder(IT_UNCOVERED_LINES_KEY, "IT uncovered lines", Metric.ValueType.INT) - .setDescription("IT uncovered lines") - .setDirection(Metric.DIRECTION_WORST) - .setQualitative(false) - .setDomain(DOMAIN_IT_TESTS) - .setFormula(new SumChildValuesFormula(false)) - .create(); - - public static final String IT_LINE_COVERAGE_KEY = "it_line_coverage"; - public static final Metric IT_LINE_COVERAGE = new Metric.Builder(IT_LINE_COVERAGE_KEY, "IT line coverage", Metric.ValueType.PERCENT) - .setDescription("IT line coverage") - .setDirection(Metric.DIRECTION_BETTER) - .setQualitative(true) - .setDomain(DOMAIN_IT_TESTS) - .create(); - - public static final String IT_COVERAGE_LINE_HITS_DATA_KEY = "it_coverage_line_hits_data"; - public static final Metric IT_COVERAGE_LINE_HITS_DATA = new Metric.Builder(IT_COVERAGE_LINE_HITS_DATA_KEY, "IT Coverage hits data", Metric.ValueType.DATA) - .setDescription("IT Code coverage line hits data") - .setDirection(Metric.DIRECTION_NONE) - .setQualitative(false) - .setDomain(DOMAIN_IT_TESTS) - .create(); - - public static final String IT_CONDITIONS_TO_COVER_KEY = "it_conditions_to_cover"; - public static final Metric IT_CONDITIONS_TO_COVER = new Metric.Builder(IT_CONDITIONS_TO_COVER_KEY, "IT Conditions to cover", Metric.ValueType.INT) - .setDescription("IT Conditions to cover") - .setDirection(Metric.DIRECTION_BETTER) - .setQualitative(false) - .setDomain(DOMAIN_IT_TESTS) - .setFormula(new SumChildValuesFormula(false)) - .setHidden(true) - .create(); - - public static final String IT_UNCOVERED_CONDITIONS_KEY = "it_uncovered_conditions"; - public static final Metric IT_UNCOVERED_CONDITIONS = new Metric.Builder(IT_UNCOVERED_CONDITIONS_KEY, "IT Uncovered conditions", Metric.ValueType.INT) - .setDescription("IT Uncovered conditions") - .setDirection(Metric.DIRECTION_WORST) - .setDomain(DOMAIN_IT_TESTS) - .setFormula(new SumChildValuesFormula(false)) - .create(); - - public static final String IT_BRANCH_COVERAGE_KEY = "it_branch_coverage"; - public static final Metric IT_BRANCH_COVERAGE = new Metric.Builder(IT_BRANCH_COVERAGE_KEY, "IT Branch coverage", Metric.ValueType.PERCENT) - .setDescription("IT Branch coverage") - .setDirection(Metric.DIRECTION_BETTER) - .setQualitative(true) - .setDomain(DOMAIN_IT_TESTS) - .setWorstValue(0.0) - .setBestValue(100.0) - .create(); - - public static final String IT_CONDITIONS_BY_LINE_KEY = "it_conditions_by_line"; - - public static final Metric IT_CONDITIONS_BY_LINE = new Metric.Builder(IT_CONDITIONS_BY_LINE_KEY, "IT Conditions by line", Metric.ValueType.DATA) - .setDomain(DOMAIN_IT_TESTS) - .create(); - - public static final String IT_COVERED_CONDITIONS_BY_LINE_KEY = "it_covered_conditions_by_line"; - - public static final Metric IT_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(IT_COVERED_CONDITIONS_BY_LINE_KEY, "IT Covered conditions by line", Metric.ValueType.DATA) - .setDomain(DOMAIN_IT_TESTS) - .create(); - - - public List<Metric> getMetrics() { - return Arrays.asList(IT_COVERAGE, IT_LINES_TO_COVER, IT_UNCOVERED_LINES, IT_LINE_COVERAGE, IT_COVERAGE_LINE_HITS_DATA, - IT_CONDITIONS_TO_COVER, IT_UNCOVERED_CONDITIONS, IT_BRANCH_COVERAGE, - IT_CONDITIONS_BY_LINE, IT_COVERED_CONDITIONS_BY_LINE); - } - -} diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensor.java index f043d16dddf..8d1d54604bd 100644 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensor.java +++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensor.java @@ -72,25 +72,25 @@ public class JaCoCoItSensor implements Sensor { private Measure convertForIT(Measure measure) { Measure itMeasure = null; if (CoreMetrics.LINES_TO_COVER.equals(measure.getMetric())) { - itMeasure = new Measure(JaCoCoItMetrics.IT_LINES_TO_COVER, measure.getValue()); + itMeasure = new Measure(CoreMetrics.IT_LINES_TO_COVER, measure.getValue()); } else if (CoreMetrics.UNCOVERED_LINES.equals(measure.getMetric())) { - itMeasure = new Measure(JaCoCoItMetrics.IT_UNCOVERED_LINES, measure.getValue()); + itMeasure = new Measure(CoreMetrics.IT_UNCOVERED_LINES, measure.getValue()); } else if (CoreMetrics.COVERAGE_LINE_HITS_DATA.equals(measure.getMetric())) { - itMeasure = new Measure(JaCoCoItMetrics.IT_COVERAGE_LINE_HITS_DATA, measure.getData()); + itMeasure = new Measure(CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, measure.getData()); } else if (CoreMetrics.CONDITIONS_TO_COVER.equals(measure.getMetric())) { - itMeasure = new Measure(JaCoCoItMetrics.IT_CONDITIONS_TO_COVER, measure.getValue()); + itMeasure = new Measure(CoreMetrics.IT_CONDITIONS_TO_COVER, measure.getValue()); } else if (CoreMetrics.UNCOVERED_CONDITIONS.equals(measure.getMetric())) { - itMeasure = new Measure(JaCoCoItMetrics.IT_UNCOVERED_CONDITIONS, measure.getValue()); + itMeasure = new Measure(CoreMetrics.IT_UNCOVERED_CONDITIONS, measure.getValue()); } else if (CoreMetrics.COVERED_CONDITIONS_BY_LINE.equals(measure.getMetric())) { - itMeasure = new Measure(JaCoCoItMetrics.IT_COVERED_CONDITIONS_BY_LINE, measure.getData()); + itMeasure = new Measure(CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE, measure.getData()); } else if (CoreMetrics.CONDITIONS_BY_LINE.equals(measure.getMetric())) { - itMeasure = new Measure(JaCoCoItMetrics.IT_CONDITIONS_BY_LINE, measure.getData()); + itMeasure = new Measure(CoreMetrics.IT_CONDITIONS_BY_LINE, measure.getData()); } return itMeasure; } diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/CoverageViewerDefinition.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/CoverageViewerDefinition.java deleted file mode 100644 index 995353ca3c7..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/CoverageViewerDefinition.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.jacoco.itcoverage.viewer; - -import org.sonar.api.resources.Resource; -import org.sonar.api.web.*; -import org.sonar.plugins.jacoco.itcoverage.JaCoCoItMetrics; - -@ResourceQualifier(Resource.QUALIFIER_CLASS) -@NavigationSection(NavigationSection.RESOURCE_TAB) -@DefaultTab(metrics = { JaCoCoItMetrics.IT_COVERAGE_KEY, JaCoCoItMetrics.IT_LINES_TO_COVER_KEY, JaCoCoItMetrics.IT_UNCOVERED_LINES_KEY, JaCoCoItMetrics.IT_LINE_COVERAGE_KEY, JaCoCoItMetrics.IT_CONDITIONS_TO_COVER_KEY, JaCoCoItMetrics.IT_UNCOVERED_CONDITIONS_KEY, JaCoCoItMetrics.IT_BRANCH_COVERAGE_KEY }) -@UserRole(UserRole.CODEVIEWER) -public class CoverageViewerDefinition extends GwtPage { - - public String getTitle() { - return "IT Coverage"; - } - - public String getGwtId() { - return "org.sonar.plugins.jacoco.itcoverage.viewer.CoverageViewer"; - } -} diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/client/CoveragePanel.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/client/CoveragePanel.java deleted file mode 100644 index 80651a99c61..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/client/CoveragePanel.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.jacoco.itcoverage.viewer.client; - -import org.sonar.gwt.ui.SourcePanel; -import org.sonar.wsclient.gwt.AbstractCallback; -import org.sonar.wsclient.gwt.Sonar; -import org.sonar.wsclient.services.Resource; -import org.sonar.wsclient.services.ResourceQuery; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Copied from org.sonar.plugins.core.coverageviewer.client.CoveragePanel - */ -public class CoveragePanel extends SourcePanel { - - private Map<Integer, Integer> hitsByLine = new HashMap<Integer, Integer>(); - private Map<Integer, Integer> conditionsByLine = new HashMap<Integer, Integer>(); - private Map<Integer, Integer> coveredConditionsByLine = new HashMap<Integer, Integer>(); - private Map<Integer, String> branchCoverageByLine = new HashMap<Integer, String>(); - - public CoveragePanel(Resource resource) { - super(resource); - loadCoverageHits(resource); - } - - private void loadCoverageHits(Resource resource) { - ResourceQuery query = ResourceQuery.createForResource(resource, Metrics.IT_COVERAGE_LINE_HITS_DATA, Metrics.IT_BRANCH_COVERAGE_HITS_DATA, Metrics.IT_CONDITIONS_BY_LINE, Metrics.IT_COVERED_CONDITIONS_BY_LINE); - Sonar.getInstance().find(query, new AbstractCallback<Resource>() { - - @Override - protected void doOnResponse(Resource resource) { - handleLineHits(resource); - handleLineConditions(resource); - handleDeprecatedBranchCoverage(resource); - setStarted(); - } - }); - } - - private void handleLineHits(Resource resource) { - parseDataMap(resource, Metrics.IT_COVERAGE_LINE_HITS_DATA, hitsByLine); - } - - private void handleLineConditions(Resource resource) { - parseDataMap(resource, Metrics.IT_CONDITIONS_BY_LINE, conditionsByLine); - parseDataMap(resource, Metrics.IT_COVERED_CONDITIONS_BY_LINE, coveredConditionsByLine); - } - - private void parseDataMap(Resource resource, String metric, Map<Integer, Integer> map) { - if (resource == null || resource.getMeasure(metric) == null) { - return; - } - - map.clear(); - String data = resource.getMeasure(metric).getData(); - for (String lineWithValue : data.split(";")) { - String[] elt = lineWithValue.split("="); - if (elt != null && elt.length == 2) { - map.put(Integer.parseInt(elt[0]), Integer.parseInt(elt[1])); - } - } - } - - private void handleDeprecatedBranchCoverage(Resource resource) { - if (resource == null || resource.getMeasure(Metrics.IT_BRANCH_COVERAGE_HITS_DATA) == null) { - return; - } - - branchCoverageByLine.clear(); - String data = resource.getMeasure(Metrics.IT_BRANCH_COVERAGE_HITS_DATA).getData(); - for (String lineWithValue : data.split(";")) { - String[] elt = lineWithValue.split("="); - if (elt != null && elt.length == 2) { - branchCoverageByLine.put(Integer.parseInt(elt[0]), elt[1]); - } - } - } - - @Override - protected boolean shouldDecorateLine(int index) { - return index > 0; - } - - @Override - protected List<Row> decorateLine(int index, String source) { - Row row = new Row().setLineIndex(index, ""); - - Integer hits = hitsByLine.get(index); - Integer conditions = conditionsByLine.get(index); - Integer coveredConditions = coveredConditionsByLine.get(index); - String branchCoverage = branchCoverageByLine.get(index); - if (branchCoverage == null && conditions != null && coveredConditions != null) { - branchCoverage = String.valueOf(conditions - coveredConditions) + "/" + String.valueOf(conditions); - } - - boolean hasLineCoverage = (hits != null); - boolean hasBranchCoverage = (branchCoverage != null); - boolean lineIsCovered = (hasLineCoverage && hits > 0); - boolean branchIsCovered = ("100%".equals(branchCoverage) || (conditions != null && coveredConditions != null && coveredConditions == conditions)); - - row.setSource(source, ""); - row.setValue(" ", ""); - row.setValue2(" ", ""); - - if (lineIsCovered) { - if (branchIsCovered) { - row.setValue(String.valueOf(hits), "green"); - row.setValue2(branchCoverage, "green"); - - } else if (hasBranchCoverage) { - row.setValue(String.valueOf(hits), "orange"); - row.setValue2(branchCoverage, "orange"); - row.setSource(source, "orange"); - } else { - row.setValue(String.valueOf(hits), "green"); - } - } else if (hasLineCoverage) { - row.setValue(String.valueOf(hits), "red"); - row.setSource(source, "red"); - if (hasBranchCoverage) { - row.setValue2(branchCoverage, "red"); - } else { - row.setValue2(" ", "red"); - } - } - return Arrays.asList(row); - } -} diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/client/CoverageViewer.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/client/CoverageViewer.java deleted file mode 100644 index 1d9b3ae8c6b..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/client/CoverageViewer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.jacoco.itcoverage.viewer.client; - -import org.sonar.gwt.ui.Page; -import org.sonar.gwt.ui.ViewerHeader; -import org.sonar.wsclient.services.Measure; -import org.sonar.wsclient.services.Resource; - -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Widget; - -/** - * Copied from org.sonar.plugins.core.coverageviewer.client.CoverageViewer - */ -public class CoverageViewer extends Page { - @Override - protected Widget doOnResourceLoad(Resource resource) { - FlowPanel panel = new FlowPanel(); - panel.setWidth("100%"); - panel.add(new CoverageHeader(resource)); - panel.add(new CoveragePanel(resource)); - return panel; - } - - private static class CoverageHeader extends ViewerHeader { - public CoverageHeader(Resource resource) { - super(resource, new String[] { Metrics.IT_COVERAGE, Metrics.IT_LINE_COVERAGE, Metrics.IT_UNCOVERED_LINES, Metrics.IT_BRANCH_COVERAGE, Metrics.IT_UNCOVERED_CONDITIONS }); - } - - @Override - protected void display(FlowPanel header, Resource resource) { - HorizontalPanel panel = new HorizontalPanel(); - header.add(panel); - - Measure measure = resource.getMeasure(Metrics.IT_COVERAGE); - if (measure == null) { - addBigCell(panel, "-"); - } else { - addBigCell(panel, measure.getFormattedValue()); - } - - addCell(panel, resource.getMeasure(Metrics.IT_LINE_COVERAGE)); - addCell(panel, resource.getMeasure(Metrics.IT_UNCOVERED_LINES)); - addCell(panel, resource.getMeasure(Metrics.IT_LINES_TO_COVER)); - addCell(panel, resource.getMeasure(Metrics.IT_BRANCH_COVERAGE)); - addCell(panel, resource.getMeasure(Metrics.IT_UNCOVERED_CONDITIONS)); - addCell(panel, resource.getMeasure(Metrics.IT_CONDITIONS_TO_COVER)); - } - } -} diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/client/Metrics.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/client/Metrics.java deleted file mode 100644 index 3e3190f6418..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/viewer/client/Metrics.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.jacoco.itcoverage.viewer.client; - -/** - * Should be in {@link org.sonar.gwt.Metrics} - */ -public interface Metrics { - String IT_COVERAGE = "it_coverage"; - String IT_LINES_TO_COVER = "it_lines_to_cover"; - String IT_UNCOVERED_LINES = "it_uncovered_lines"; - String IT_LINE_COVERAGE = "it_line_coverage"; - String IT_COVERAGE_LINE_HITS_DATA = "it_coverage_line_hits_data"; - String IT_CONDITIONS_TO_COVER = "it_conditions_to_cover"; - String IT_UNCOVERED_CONDITIONS = "it_uncovered_conditions"; - String IT_BRANCH_COVERAGE = "it_branch_coverage"; - String IT_CONDITIONS_BY_LINE = "it_conditions_by_line"; - String IT_COVERED_CONDITIONS_BY_LINE = "it_covered_conditions_by_line"; - - /** - * @deprecated use IT_CONDITIONS_BY_LINE and IT_COVERED_CONDITIONS_BY_LINE - */ - @Deprecated - String IT_BRANCH_COVERAGE_HITS_DATA = "it_branch_coverage_hits_data"; -} diff --git a/plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/viewer/CoverageViewer.gwt.xml b/plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/viewer/CoverageViewer.gwt.xml deleted file mode 100644 index 5ab8fc9aff4..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/viewer/CoverageViewer.gwt.xml +++ /dev/null @@ -1,9 +0,0 @@ -<module> - <inherits name="com.google.gwt.user.User"/> - <inherits name="com.google.gwt.json.JSON"/> - <inherits name="com.google.gwt.http.HTTP"/> - <inherits name="org.sonar.Sonar"/> - <inherits name="com.google.gwt.gen2.table.Table"/> - - <entry-point class="org.sonar.plugins.jacoco.itcoverage.viewer.client.CoverageViewer"/> -</module> diff --git a/plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/viewer/CoverageViewerDev.gwt.xml b/plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/viewer/CoverageViewerDev.gwt.xml deleted file mode 100644 index c5a49a81f61..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/viewer/CoverageViewerDev.gwt.xml +++ /dev/null @@ -1,6 +0,0 @@ -<module rename-to="org.sonar.plugins.jacoco.itcoverage.viewer.CoverageViewer"> - <inherits name="org.sonar.plugins.jacoco.itcoverage.viewer.CoverageViewer"/> - <inherits name="org.sonar.SonarDev"/> - - <entry-point class="org.sonar.plugins.jacoco.itcoverage.viewer.client.CoverageViewer"/> -</module> diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoPluginTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoPluginTest.java index 33a989813b2..dd902247968 100644 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoPluginTest.java +++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoPluginTest.java @@ -19,35 +19,15 @@ */ package org.sonar.plugins.jacoco; +import org.junit.Test; + import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Evgeny Mandrikov - */ public class JaCoCoPluginTest { - private JaCoCoPlugin plugin = new JaCoCoPlugin(); - - @Before - public void setUp() { - plugin = new JaCoCoPlugin(); - } - - @Test - public void testPluginDefition() { - assertThat(plugin.getKey(), is("jacoco")); - assertThat(plugin.getName(), notNullValue()); - assertThat(plugin.getDescription(), notNullValue()); - assertThat(plugin.toString(), is("jacoco")); - } @Test public void testExtensions() { - assertThat(plugin.getExtensions().size(), greaterThan(0)); + assertThat(new JaCoCoPlugin().getExtensions().size(), greaterThan(0)); } } diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItMetricsTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItMetricsTest.java deleted file mode 100644 index b931fb12268..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItMetricsTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.jacoco.itcoverage; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class JaCoCoItMetricsTest { - - @Test - public void metricsDefinition() { - assertThat(new JaCoCoItMetrics().getMetrics().size(), is(10)); - } - -} diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensorTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensorTest.java index aca9c9bfd9b..524e9070908 100644 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensorTest.java +++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensorTest.java @@ -19,25 +19,29 @@ */ package org.sonar.plugins.jacoco.itcoverage; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; - import org.junit.Before; import org.junit.Test; import org.sonar.api.batch.SensorContext; +import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Measure; -import org.sonar.api.resources.*; +import org.sonar.api.resources.JavaFile; +import org.sonar.api.resources.Project; import org.sonar.api.resources.Project.AnalysisType; +import org.sonar.api.resources.ProjectFileSystem; +import org.sonar.api.resources.Resource; import org.sonar.api.test.IsMeasure; import org.sonar.plugins.jacoco.JacocoConfiguration; import java.io.File; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.argThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.*; + public class JaCoCoItSensorTest { private JacocoConfiguration configuration; private JaCoCoItSensor sensor; @@ -88,14 +92,14 @@ public class JaCoCoItSensorTest { sensor.analyse(project, context); verify(context).getResource(eq(resource)); - verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(JaCoCoItMetrics.IT_LINES_TO_COVER, 7.0))); - verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(JaCoCoItMetrics.IT_UNCOVERED_LINES, 3.0))); + verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_LINES_TO_COVER, 7.0))); + verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_UNCOVERED_LINES, 3.0))); verify(context).saveMeasure(eq(resource), - argThat(new IsMeasure(JaCoCoItMetrics.IT_COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0"))); - verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(JaCoCoItMetrics.IT_CONDITIONS_TO_COVER, 2.0))); - verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(JaCoCoItMetrics.IT_UNCOVERED_CONDITIONS, 2.0))); - verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(JaCoCoItMetrics.IT_CONDITIONS_BY_LINE, "15=2"))); - verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(JaCoCoItMetrics.IT_COVERED_CONDITIONS_BY_LINE, "15=0"))); + argThat(new IsMeasure(CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0"))); + verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER, 2.0))); + verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS, 2.0))); + verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_CONDITIONS_BY_LINE, "15=2"))); + verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE, "15=0"))); verifyNoMoreInteractions(context); } diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index b4d3af09832..283b3cd524b 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -609,6 +609,14 @@ duplications.collapse=Collapse #------------------------------------------------------------------------------ # +# COVERAGE TAB +# +#------------------------------------------------------------------------------ +coverage_tab.unit_tests=Unit Tests +coverage_tab.integration_tests=Integration Tests + +#------------------------------------------------------------------------------ +# # MANUAL MEASURES # #------------------------------------------------------------------------------ @@ -917,6 +925,7 @@ severity.INFO=Info metric_domain.Size=Size metric_domain.Tests=Tests +metric_domain.Integration Tests=L10n Integration Tests metric_domain.Complexity=Complexity metric_domain.Documentation=Documentation metric_domain.Rules=Rules @@ -1103,6 +1112,43 @@ metric.conditions_by_line.description=Branches by line metric.covered_conditions_by_line.name=Covered branches by line metric.covered_conditions_by_line.description=Covered branches by line + +#-------------------------------------------------------------------------------------------------------------------- +# +# INTEGRATION TESTS +# +#-------------------------------------------------------------------------------------------------------------------- + +metric.it_coverage.name=Coverage +metric.it_coverage.description=Coverage by unit tests + +metric.it_lines_to_cover.name=Lines to cover +metric.it_lines_to_cover.description=Lines to cover + +metric.it_uncovered_lines.name=Uncovered lines +metric.it_uncovered_lines.description=Uncovered lines + +metric.it_line_coverage.name=Line coverage +metric.it_line_coverage.description=Line coverage + +metric.it_coverage_line_hits_data.name=Coverage hits by line +metric.it_coverage_line_hits_data.description=Coverage hits by line + +metric.it_conditions_to_cover.name=Branches to cover +metric.it_conditions_to_cover.description=Branches to cover + +metric.it_uncovered_conditions.name=Uncovered branches +metric.it_uncovered_conditions.description=Uncovered branches + +metric.it_branch_coverage.name=Branch coverage +metric.it_branch_coverage.description=Branch coverage + +metric.it_conditions_by_line.name=Branches by line +metric.it_conditions_by_line.description=Branches by line + +metric.it_covered_conditions_by_line.name=Covered branches by line +metric.it_covered_conditions_by_line.description=Covered branches by line + #-------------------------------------------------------------------------------------------------------------------- # # DUPLICATIONS |