From: Teryk Bellahsene Date: Thu, 14 Jan 2016 14:22:42 +0000 (+0100) Subject: SONAR-7135 WS api/measures/component_tree sorting does not depend on metric direction X-Git-Tag: 5.4-M6~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0d4c4cc245e1595e4fb9279905ecdca4ead442c1;p=sonarqube.git SONAR-7135 WS api/measures/component_tree sorting does not depend on metric direction --- 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(