@@ -30,7 +30,8 @@ | |||
close=")">#{metricUuid, jdbcType=VARCHAR}</foreach> | |||
and component_uuid in (SELECT | |||
p.uuid as uuid | |||
FROM projects p) | |||
FROM projects p | |||
where p.qualifier = 'TRK') | |||
</select> | |||
<select id="selectByComponentUuidsAndMetricKeys" parameterType="map" resultType="org.sonar.db.measure.LiveMeasureDto"> |
@@ -18,6 +18,7 @@ | |||
SELECT | |||
p.uuid as uuid | |||
FROM projects p | |||
where p.qualifier = 'TRK' | |||
</select> | |||
<select id="selectByUuid" parameterType="String" resultType="Project"> |
@@ -168,6 +168,24 @@ public class LiveMeasureDaoTest { | |||
assertThat(selected).isEmpty(); | |||
} | |||
@Test | |||
public void selectForProjectsByMetricUuids_shouldReturnProjectWithTRKQualifierOnly() { | |||
MetricDto metric = db.measures().insertMetric(); | |||
ComponentDto application = db.components().insertPrivateApplication(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto project2 = db.components().insertPrivateProject(); | |||
db.components().addApplicationProject(application, project, project2); | |||
underTest.insert(db.getSession(), newLiveMeasure(application, metric).setValue(3.14).setData((String) null)); | |||
underTest.insert(db.getSession(), newLiveMeasure(project, metric).setValue(4.54).setData((String) null)); | |||
underTest.insert(db.getSession(), newLiveMeasure(project2, metric).setValue(5.56).setData((String) null)); | |||
List<LiveMeasureDto> selected = underTest.selectForProjectsByMetricUuids(db.getSession(), List.of(metric.getUuid())); | |||
assertThat(selected) | |||
.extracting(LiveMeasureDto::getProjectUuid) | |||
.containsExactlyInAnyOrder(project.uuid(), project2.uuid()); | |||
} | |||
@Test | |||
public void selectByComponentUuidAndMetricKey() { | |||
LiveMeasureDto measure = newLiveMeasure().setMetricUuid(metric.getUuid()); |
@@ -279,6 +279,18 @@ public class ProjectDaoTest { | |||
.containsExactlyInAnyOrderElementsOf(extractComponentUuids(projects)); | |||
} | |||
@Test | |||
public void selectAllProjectUuids_shouldOnlyReturnProjectWithTRKQualifier() { | |||
ComponentDto application = db.components().insertPrivateApplication(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto project2 = db.components().insertPrivateProject(); | |||
db.components().addApplicationProject(application, project, project2); | |||
List<String> projectUuids = projectDao.selectAllProjectUuids(db.getSession()); | |||
assertThat(projectUuids).containsExactlyInAnyOrder(project.uuid(), project2.uuid()); | |||
} | |||
private void insertDefaultQualityProfile(String language) { | |||
QProfileDto profile = db.qualityProfiles().insert(qp -> qp.setIsBuiltIn(true).setLanguage(language)); | |||
db.qualityProfiles().setAsDefault(profile); |