From be43693cca01729483c8e665a8bc1561c0ff7268 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Wed, 10 May 2023 14:02:08 +0200 Subject: [PATCH] Simplify the selection of the cell icon. --- .../coverage/metrics/steps/CoverageChecksPublisher.java | 8 +------- .../metrics/steps/CoverageChecksPublisherTest.java | 5 ++++- .../coverage-publisher-details.checks-expected-result | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisher.java b/plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisher.java index b7a79c778..1d0556b29 100644 --- a/plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisher.java +++ b/plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisher.java @@ -438,13 +438,7 @@ private String getTrendIcon(final String trend) { if (!StringUtils.containsAny(trend, "123456789") || trend.startsWith("n/a")) { return StringUtils.EMPTY; } - if (trend.startsWith("+")) { - return GAP + Icon.ARROW_UP.markdown; - } - else if (trend.startsWith("-")) { - return GAP + Icon.ARROW_DOWN.markdown; - } - return GAP + Icon.ARROW_RIGHT.markdown; + return GAP + (trend.startsWith("+") ? Icon.ARROW_UP.markdown : Icon.ARROW_DOWN.markdown); } private String getBulletListItem(final int level, final String text) { diff --git a/plugin/src/test/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisherTest.java b/plugin/src/test/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisherTest.java index 0f393dc29..1f50358a1 100644 --- a/plugin/src/test/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisherTest.java +++ b/plugin/src/test/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisherTest.java @@ -216,7 +216,10 @@ private CoverageBuildAction createCoverageBuildAction(final Node result) { return new CoverageBuildAction(run, COVERAGE_ID, REPORT_NAME, StringUtils.EMPTY, result, new QualityGateResult(), null, "refId", - new TreeMap<>(Map.of(Metric.LINE, Fraction.ONE_HALF, Metric.MODULE, Fraction.ZERO)), + new TreeMap<>(Map.of( + Metric.LINE, Fraction.ONE_HALF, + Metric.MODULE, Fraction.ZERO, + Metric.PACKAGE, Fraction.ONE_HALF.negate())), List.of(testCoverage), new TreeMap<>(Map.of(Metric.LINE, Fraction.ONE_HALF)), List.of(testCoverage), new TreeMap<>(Map.of(Metric.LINE, Fraction.ONE_HALF)), List.of(testCoverage), false); } diff --git a/plugin/src/test/resources/io/jenkins/plugins/coverage/metrics/steps/coverage-publisher-details.checks-expected-result b/plugin/src/test/resources/io/jenkins/plugins/coverage/metrics/steps/coverage-publisher-details.checks-expected-result index b488080bf..56941c726 100644 --- a/plugin/src/test/resources/io/jenkins/plugins/coverage/metrics/steps/coverage-publisher-details.checks-expected-result +++ b/plugin/src/test/resources/io/jenkins/plugins/coverage/metrics/steps/coverage-publisher-details.checks-expected-result @@ -3,7 +3,7 @@ ||Module Coverage|Package Coverage|File Coverage|Class Coverage|Method Coverage|Line Coverage|Branch Coverage|Instruction Coverage |:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---: :feet: **Overall project**|100.00% (1/1)|100.00% (4/4)|70.00% (7/10)|83.33% (15/18)|95.10% (97/102)|91.02% (294/323)|93.97% (109/116)|93.33% (1260/1350) -:chart_with_upwards_trend: **Overall project (difference to reference job)**|+0.00%|n/a|n/a|n/a|n/a|+50.00% :arrow_up:|n/a|n/a +:chart_with_upwards_trend: **Overall project (difference to reference job)**|+0.00%|-50.00% :arrow_down:|n/a|n/a|n/a|+50.00% :arrow_up:|n/a|n/a :feet: **Modified files**|n/a|n/a|n/a|n/a|n/a|50.00% (1/2)|n/a|n/a :chart_with_upwards_trend: **Modified files (difference to overall project)**|n/a|n/a|n/a|n/a|n/a|+50.00% :arrow_up:|n/a|n/a :feet: **Modified code lines**|n/a|n/a|n/a|n/a|n/a|50.00% (1/2)|n/a|n/a