List<IdUuidPair> selectAnalysisIdsAndUuids(PurgeSnapshotQuery query);
/**
- * Returns the list of modules/subviews and the view/project for the specified project_uuid.
+ * Returns the list of modules/subviews and the application/view/project for the specified project_uuid.
*/
List<IdUuidPair> selectRootAndModulesOrSubviewsByProjectUuid(@Param("rootUuid") String rootUuid);
from projects p
where
p.scope='PRJ'
- and (p.qualifier='TRK' or p.qualifier='VW')
+ and (p.qualifier='TRK' or p.qualifier='VW' or p.qualifier='APP')
and p.organization_uuid = #{organizationUuid,jdbcType=VARCHAR}
</select>
)
or (
uuid=#{rootUuid,jdbcType=VARCHAR}
- and p.scope = 'PRJ' and p.qualifier in ('VW','TRK')
+ and p.scope = 'PRJ' and p.qualifier in ('APP', 'VW','TRK')
)
</select>
}
@Test
- public void select_views_and_sub_views() {
- db.prepareDbUnit(getClass(), "shared_views.xml");
-
- assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting("uuid").containsOnly("ABCD", "EFGH", "FGHI", "IJKL");
- assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting("projectUuid").containsOnly("ABCD", "EFGH", "IJKL");
+ public void select_views_and_sub_views_and_applications() {
+ OrganizationDto organization = db.organizations().insert();
+ db.components().insertView(organization, "ABCD");
+ db.components().insertView(organization, "IJKL");
+ ComponentDto view = db.components().insertView(organization, "EFGH");
+ db.components().insertSubView(view, dto -> dto.setUuid("FGHI"));
+ ComponentDto application = db.components().insertApplication(organization);
+
+ assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithProjectUuidDto::getUuid)
+ .containsExactlyInAnyOrder("ABCD", "EFGH", "FGHI", "IJKL")
+ .doesNotContain(application.uuid());
+ assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithProjectUuidDto::getProjectUuid)
+ .containsOnly("ABCD", "EFGH", "IJKL")
+ .doesNotContain(application.projectUuid());
}
@Test
import static org.sonar.db.component.ComponentTesting.newApplication;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
import static org.sonar.db.component.ComponentTesting.newPublicProjectDto;
+import static org.sonar.db.component.ComponentTesting.newSubView;
import static org.sonar.db.component.ComponentTesting.newView;
import static org.sonar.db.component.SnapshotTesting.newAnalysis;
return insertComponentImpl(newApplication(organizationDto), false, noExtraConfiguration());
}
- public ComponentDto insertApplication(OrganizationDto organizationDto, Consumer<ComponentDto> dtoPopulator) {
- return insertComponentImpl(newApplication(organizationDto), false, dtoPopulator);
+ public ComponentDto insertApplication(OrganizationDto organizationDto, Consumer<ComponentDto>... dtoPopulators) {
+ return insertComponentImpl(newApplication(organizationDto), false, dtoPopulators);
+ }
+
+ public ComponentDto insertSubView(ComponentDto view, Consumer<ComponentDto> dtoPopulator) {
+ return insertComponentImpl(newSubView(view), false, dtoPopulator);
}
private static <T> Consumer<T> noExtraConfiguration() {
.containsOnly(view.uuid());
}
+ @Test
+ public void selectRootAndModulesOrSubviewsByProjectUuid_returns_application_with_specified_uuid() {
+ ComponentDto view = db.components().insertApplication(db.getDefaultOrganization());
+
+ assertThat(purgeMapper.selectRootAndModulesOrSubviewsByProjectUuid(view.uuid()))
+ .extracting(IdUuidPair::getUuid)
+ .containsOnly(view.uuid());
+ }
+
@Test
public void selectRootAndModulesOrSubviewsByProjectUuid_returns_subviews_with_specified_project_uuid_and_view() {
ComponentDto view = db.components().insertView();