aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-12-20 11:10:12 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-12-20 11:10:12 +0100
commit380129ba6e1e1d366207952648f1cd89b218c806 (patch)
treec18929da74a7dfeefffbdaeaa3c6af90ed8efe5d /sonar-core
parent4f82d9f2799b1aa639411b923d20cb2e03328c2c (diff)
downloadsonarqube-380129ba6e1e1d366207952648f1cd89b218c806.tar.gz
sonarqube-380129ba6e1e1d366207952648f1cd89b218c806.zip
Add unit tests for sorting on measures
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java25
1 files 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<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);