aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/test/java/org
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-01-24 14:55:29 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-01-24 17:37:23 +0100
commitf55c90fa06e82cd70639eda3c2a6f686a13fbee7 (patch)
tree6dbcb0d7462aec99c2412e77aebafb0210d24ac1 /sonar-db/src/test/java/org
parenta9c56c11f9889888311e1be3a1a100321c3f1ac0 (diff)
downloadsonarqube-f55c90fa06e82cd70639eda3c2a6f686a13fbee7.tar.gz
sonarqube-f55c90fa06e82cd70639eda3c2a6f686a13fbee7.zip
SONAR-7305 Create WS api/measures/search_history
Diffstat (limited to 'sonar-db/src/test/java/org')
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
index 4fb8fb3b8d3..0ac06eccd8f 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
@@ -35,6 +35,7 @@ import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.SnapshotTesting;
import org.sonar.db.organization.OrganizationDto;
+import static com.google.common.collect.Lists.newArrayList;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
@@ -449,6 +450,24 @@ public class MeasureDaoTest {
verifyMeasures(file1, MeasureTreeQuery.builder().setStrategy(LEAVES), "M2", "M3");
}
+ @Test
+ public void select_past_measures_with_several_analyses() {
+ ComponentDto project = db.components().insertProject();
+ insertAnalysis(LAST_ANALYSIS_UUID, project.uuid(), true);
+ insertAnalysis(OTHER_ANALYSIS_UUID, project.uuid(), false);
+ db.components().indexAllComponents();
+
+ // project
+ insertMeasure("PROJECT_M1", LAST_ANALYSIS_UUID, project.uuid(), NCLOC_METRIC_ID);
+ insertMeasure("PROJECT_M2", OTHER_ANALYSIS_UUID, project.uuid(), NCLOC_METRIC_ID);
+ db.commit();
+
+ // Children measures of project
+ List<MeasureDto> result = underTest.selectPastMeasures(db.getSession(), project.uuid(), newArrayList(LAST_ANALYSIS_UUID, OTHER_ANALYSIS_UUID), singletonList(NCLOC_METRIC_ID));
+
+ assertThat(result).hasSize(2).extracting(MeasureDto::getData).containsOnly("PROJECT_M1", "PROJECT_M2");
+ }
+
private Optional<MeasureDto> selectSingle(MeasureQuery.Builder query) {
return underTest.selectSingle(db.getSession(), query.build());
}