From 380129ba6e1e1d366207952648f1cd89b218c806 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 20 Dec 2012 11:10:12 +0100 Subject: [PATCH] Add unit tests for sorting on measures --- .../measure/MeasureFilterExecutorTest.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java b/sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java index 61410ca9eae..8f2b82a96d4 100644 --- a/sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java +++ b/sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java @@ -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 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 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); -- 2.39.5