From 0d4c4cc245e1595e4fb9279905ecdca4ead442c1 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Thu, 14 Jan 2016 15:22:42 +0100 Subject: [PATCH] SONAR-7135 WS api/measures/component_tree sorting does not depend on metric direction --- .../sonar/server/measure/ws/ComponentTreeSort.java | 2 +- .../server/measure/ws/ComponentTreeSortTest.java | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java index 2cd5f81b1f9..f2ccb842042 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java @@ -130,7 +130,7 @@ class ComponentTreeSort { return null; } - return metric.getDirection() >= 0 ? measure.getValue() : -measure.getValue(); + return measure.getValue(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java index 1efa56e50c8..5341852e50b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java @@ -111,17 +111,6 @@ public class ComponentTreeSortTest { .containsExactly("path-1", "path-2", "path-3", "path-4", "path-5", "path-6", "path-7", "path-8", "path-9"); } - @Test - public void sort_by_metric_key_with_negative_metric_direction() { - metrics.get(0).setDirection(-1); - ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_SORT), true, METRIC_KEY); - - List result = sortComponents(wsRequest); - - assertThat(result).extracting("path") - .containsExactly("path-9", "path-8", "path-7", "path-6", "path-5", "path-4", "path-3", "path-2", "path-1"); - } - @Test public void sort_on_multiple_fields() { components = newArrayList( -- 2.39.5