aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-10-13 17:17:39 +0200
committerTeryk Bellahsene <teryk@users.noreply.github.com>2017-10-16 09:34:11 +0200
commit18af892e0df11889eb699c4e562e6bbd979b559f (patch)
tree83fa15f70ccfab966c8438004e507fb8df710c2f /server
parent8aa5edf5a81a9eff3cb92d18eb6a51272b4418e3 (diff)
downloadsonarqube-18af892e0df11889eb699c4e562e6bbd979b559f.tar.gz
sonarqube-18af892e0df11889eb699c4e562e6bbd979b559f.zip
SONAR-8392 Order components by name ascending as default ordering for equalities
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java14
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js2
3 files changed, 16 insertions, 1 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 cab59985488..af94995abd0 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
@@ -86,6 +86,7 @@ public class ComponentTreeSort {
primaryOrdering = primaryOrdering.compound(secondaryOrdering);
}
}
+ primaryOrdering = primaryOrdering.compound(componentNameOrdering(true));
return primaryOrdering.immutableSortedCopy(components);
}
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 43e47e025a1..a829d11a989 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
@@ -138,6 +138,20 @@ public class ComponentTreeSortTest {
}
@Test
+ public void sort_by_name_ascending_in_case_of_equality() {
+ components = newArrayList(
+ newComponentWithoutSnapshotId("PROJECT 12", Qualifiers.PROJECT, "PROJECT_PATH_1"),
+ newComponentWithoutSnapshotId("PROJECT 11", Qualifiers.PROJECT, "PROJECT_PATH_1"),
+ newComponentWithoutSnapshotId("PROJECT 0", Qualifiers.PROJECT, "PROJECT_PATH_2"));
+
+ ComponentTreeWsRequest wsRequest = newRequest(newArrayList(PATH_SORT), false, null);
+
+ List<ComponentDto> result = sortComponents(wsRequest);
+
+ assertThat(result).extracting("name").containsExactly("PROJECT 0", "PROJECT 11", "PROJECT 12");
+ }
+
+ @Test
public void sort_by_alert_status_ascending() {
components = newArrayList(
newComponentWithoutSnapshotId("PROJECT OK 1", Qualifiers.PROJECT, "PROJECT_OK_PATH_1"),
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js
index 16ba5d4ba82..12f3616697d 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js
@@ -133,7 +133,7 @@ export default class MeasureContent extends React.PureComponent {
opts.asc = metric.direction === 1;
opts.ps = 100;
opts.metricSort = metric.key;
- opts.s = isDiff ? 'metricPeriod,name' : 'metric,name';
+ opts.s = isDiff ? 'metricPeriod' : 'metric';
}
return { metricKeys, opts: { ...opts, ...options }, strategy };
};