]> source.dussan.org Git - sonarqube.git/commitdiff
Add unit tests for sorting on measures
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 20 Dec 2012 10:10:12 +0000 (11:10 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 20 Dec 2012 10:10:12 +0000 (11:10 +0100)
sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java

index 61410ca9eae38fbb6b5e3f9c5db2fd4f4e2fd619..8f2b82a96d49dc8a5ce6fe246eb67347fb9be6b0 100644 (file)
@@ -458,7 +458,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void ignore_person_measures() throws Exception {
+  public void ignore_person_measures_in_condition() throws Exception {
     setupData("ignore_person_measures");
     MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).addCondition(
       new MeasureFilterCondition(new Metric("ncloc").setId(1), MeasureFilterCondition.Operator.GREATER, 0.0)
@@ -470,7 +470,17 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void ignore_quality_model_measures() throws Exception {
+  public void ignore_person_measures_in_sort() throws Exception {
+    setupData("ignore_person_measures");
+    MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOnMetric(new Metric("ncloc").setId(1));
+    List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext().setUserId(50L));
+
+    assertThat(rows).hasSize(1);
+    assertThat(rows.get(0).getSnapshotId()).isEqualTo(101L);
+  }
+
+  @Test
+  public void ignore_quality_model_measures_in_condition() throws Exception {
     setupData("ignore_quality_model_measures");
     MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).addCondition(
       new MeasureFilterCondition(new Metric("ncloc").setId(1), MeasureFilterCondition.Operator.GREATER, 0.0)
@@ -481,6 +491,17 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase {
     assertThat(rows.get(0).getSnapshotId()).isEqualTo(101L);
   }
 
+  @Test
+  public void ignore_quality_model_measures_in_sort() throws Exception {
+    setupData("ignore_quality_model_measures");
+    MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOnMetric(new Metric("ncloc").setId(1));
+    List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext().setUserId(50L));
+
+    assertThat(rows).hasSize(1);
+    assertThat(rows.get(0).getSnapshotId()).isEqualTo(101L);
+  }
+
+
   private void verifyJavaProject(MeasureFilterRow row) {
     assertThat(row.getSnapshotId()).isEqualTo(JAVA_PROJECT_SNAPSHOT_ID);
     assertThat(row.getResourceId()).isEqualTo(JAVA_PROJECT_ID);