</select>
<select id="selectComponentsByProjectUuid" resultType="org.sonar.db.purge.IdUuidPair" parameterType="String">
- select id, uuid from projects where project_uuid=#{uuid}
+ select id, uuid from projects where project_uuid=#{uuid} or uuid=#{uuid}
</select>
<delete id="deleteSnapshotMeasures" parameterType="map">
assertThat(dbTester.countRowsOfTable("file_sources")).isZero();
}
+ @Test
+ public void delete_view_and_child() {
+ dbTester.prepareDbUnit(getClass(), "view_sub_view_and_tech_project.xml");
+
+ underTest.deleteProject(dbSession, "A");
+ dbSession.commit();
+ assertThat(dbTester.countSql("select count(id) from projects where uuid='A'")).isZero();
+ assertThat(dbTester.countRowsOfTable("projects")).isZero();
+ }
+
+ @Test
+ public void delete_view_sub_view_and_tech_project() {
+ dbTester.prepareDbUnit(getClass(), "view_sub_view_and_tech_project.xml");
+
+ // technical project
+ underTest.deleteProject(dbSession, "D");
+ dbSession.commit();
+ assertThat(dbTester.countSql("select count(id) from projects where uuid='D'")).isZero();
+
+ // sub view
+ underTest.deleteProject(dbSession, "B");
+ dbSession.commit();
+ assertThat(dbTester.countSql("select count(id) from projects where uuid='B'")).isZero();
+
+ // view
+ underTest.deleteProject(dbSession, "A");
+ dbSession.commit();
+ assertThat(dbTester.countSql("select count(id) from projects where uuid='A'")).isZero();
+ }
+
@Test
public void should_delete_old_closed_issues() {
dbTester.prepareDbUnit(getClass(), "should_delete_old_closed_issues.xml");
<!-- root -->
<projects id="1" enabled="[true]" root_id="[null]"
- uuid="A" project_uuid="A" module_uuid="[null]" module_uuid_path="."
+ uuid="A" project_uuid="A" module_uuid="[null]" module_uuid_path=".A."
long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
description="[null]" language="java" copy_resource_id="[null]" person_id="[null]"
authorization_updated_at="[null]"/>
<!-- modules -->
<projects id="2" enabled="[true]" root_id="1"
- uuid="B" project_uuid="A" module_uuid="A" module_uuid_path=".A."
+ uuid="B" project_uuid="A" module_uuid="A" module_uuid_path=".A.B."
long_name="[null]" scope="PRJ" qualifier="BRC" kee="module1" name="module1"
description="[null]" language="java" copy_resource_id="[null]" person_id="[null]"
authorization_updated_at="[null]"/>
<projects id="3" enabled="[false]" root_id="1"
- uuid="C" project_uuid="A" module_uuid="A" module_uuid_path=".A."
+ uuid="C" project_uuid="A" module_uuid="A" module_uuid_path=".A.C."
long_name="[null]" scope="PRJ" qualifier="BRC" kee="module2" name="module2"
description="[null]" language="java" copy_resource_id="[null]" person_id="[null]"
authorization_updated_at="[null]"/>
--- /dev/null
+<dataset>
+
+ <!-- view -->
+ <projects id="1" enabled="[true]" root_id="[null]"
+ uuid="A" project_uuid="A" module_uuid="[null]" module_uuid_path=".A."
+ long_name="[null]" scope="PRJ" qualifier="VW" kee="view" name="view"
+ description="[null]" language="[null]" copy_resource_id="[null]" person_id="[null]"
+ authorization_updated_at="[null]"/>
+
+ <!-- sub views -->
+ <projects id="2" enabled="[true]" root_id="1"
+ uuid="B" project_uuid="A" module_uuid="A" module_uuid_path=".A.B."
+ long_name="[null]" scope="PRJ" qualifier="SVW" kee="subview1" name="subview2"
+ description="[null]" language="[null]" copy_resource_id="[null]" person_id="[null]"
+ authorization_updated_at="[null]"/>
+
+ <projects id="3" enabled="[false]" root_id="1"
+ uuid="C" project_uuid="A" module_uuid="A" module_uuid_path=".A.C."
+ long_name="[null]" scope="PRJ" qualifier="SVW" kee="subview2" name="subview2"
+ description="[null]" language="[null]" copy_resource_id="[null]" person_id="[null]"
+ authorization_updated_at="[null]"/>
+
+ <!-- technical project of module 2-->
+ <projects id="4" enabled="[false]" root_id="3"
+ uuid="D" project_uuid="A" module_uuid="C" module_uuid_path=".A.C."
+ long_name="[null]" scope="FIL" qualifier="TRK" kee="TechProject" name="TechProject"
+ description="[null]" language="[null]" copy_resource_id="[null]" person_id="[null]"
+ authorization_updated_at="[null]"/>
+
+</dataset>