aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-03-06 09:22:19 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-03-06 09:22:19 +0100
commitc1d7bdb92af87e4e8882c7126cad5c5872254ba2 (patch)
tree17cd4e61ba8afd315857aaccdf0b8ba0a70bcd0d /sonar-core
parent345f2cd888a53ac18f6fa009285b0adec65076c4 (diff)
downloadsonarqube-c1d7bdb92af87e4e8882c7126cad5c5872254ba2.tar.gz
sonarqube-c1d7bdb92af87e4e8882c7126cad5c5872254ba2.zip
Commit instead of flush statements when changing preparedStatement of batch
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java195
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java176
-rw-r--r--sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java89
-rw-r--r--sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java75
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml (renamed from sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteResource.xml)0
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml (renamed from sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteSnapshot-result.xml)0
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml (renamed from sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteSnapshot.xml)0
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml (renamed from sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml)0
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml (renamed from sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml)0
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml (renamed from sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeSnapshot-result.xml)0
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml (renamed from sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeSnapshot.xml)0
11 files changed, 290 insertions, 245 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java
new file mode 100644
index 00000000000..22a841a2e3f
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java
@@ -0,0 +1,195 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.purge;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.apache.ibatis.session.SqlSession;
+
+import java.util.List;
+
+final class PurgeCommands {
+ private PurgeCommands() {
+ }
+
+ @VisibleForTesting
+ static void deleteResources(List<Long> resourceIds, SqlSession session, PurgeMapper mapper, PurgeVendorMapper vendorMapper) {
+ // Note : do not merge the delete statements into a single loop of resource ids. It's
+ // voluntarily grouped by tables in order to benefit from JDBC batch mode.
+ // Batch requests can only relate to the same PreparedStatement.
+
+ for (Long resourceId : resourceIds) {
+ deleteSnapshots(PurgeSnapshotQuery.create().setResourceId(resourceId), session, mapper);
+ }
+
+ // possible missing optimization: filter requests according to resource scope
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResourceLinks(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResourceProperties(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResourceIndex(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResourceGroupRoles(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResourceUserRoles(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResourceManualMeasures(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ vendorMapper.deleteResourceReviewComments(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ vendorMapper.deleteResourceActionPlansReviews(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResourceReviews(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResourceActionPlans(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResourceEvents(resourceId);
+ }
+ session.commit();
+
+ for (Long resourceId : resourceIds) {
+ mapper.deleteResource(resourceId);
+ }
+ session.commit();
+ }
+
+ @VisibleForTesting
+ static void deleteSnapshots(final PurgeSnapshotQuery query, final SqlSession session, final PurgeMapper mapper) {
+ deleteSnapshots(mapper.selectSnapshotIds(query), session, mapper);
+ }
+
+ private static void deleteSnapshots(final List<Long> snapshotIds, final SqlSession session, final PurgeMapper mapper) {
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotDependencies(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotDuplications(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotEvents(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotMeasureData(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotMeasures(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotSource(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotViolations(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshot(snapshotId);
+ }
+
+ session.commit();
+ }
+
+ @VisibleForTesting
+ static void purgeSnapshots(final PurgeSnapshotQuery query, final SqlSession session, final PurgeMapper mapper) {
+ purgeSnapshots(mapper.selectSnapshotIds(query), session, mapper);
+ }
+
+ private static void purgeSnapshots(final List<Long> snapshotIds, final SqlSession session, final PurgeMapper mapper) {
+ // note that events are not deleted
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotDependencies(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotDuplications(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotSource(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotViolations(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotWastedMeasures(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.deleteSnapshotMeasuresOnQualityModelRequirements(snapshotId);
+ }
+ session.commit();
+
+ for (Long snapshotId : snapshotIds) {
+ mapper.updatePurgeStatusToOne(snapshotId);
+ }
+ session.commit();
+ }
+
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
index 14792e2c12b..a93661f87a0 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
@@ -73,7 +73,7 @@ public class PurgeDao {
.setIslast(false)
.setStatus(new String[]{"U"})
.setRootProjectId(project.getId());
- deleteSnapshots(query, session, purgeMapper);
+ PurgeCommands.deleteSnapshots(query, session, purgeMapper);
session.commit();
}
}
@@ -97,16 +97,16 @@ public class PurgeDao {
.setIslast(false)
.setScopes(scopesWithoutHistoricalData)
.setRootSnapshotId(projectSnapshotId);
- deleteSnapshots(query, session, purgeMapper);
+ PurgeCommands.deleteSnapshots(query, session, purgeMapper);
session.commit();
}
PurgeSnapshotQuery query = PurgeSnapshotQuery.create().setRootSnapshotId(projectSnapshotId).setNotPurged(true);
- purgeSnapshots(query, session, purgeMapper);
+ PurgeCommands.purgeSnapshots(query, session, purgeMapper);
session.commit();
// must be executed at the end for reentrance
- purgeSnapshots(PurgeSnapshotQuery.create().setId(projectSnapshotId).setNotPurged(true), session, purgeMapper);
+ PurgeCommands.purgeSnapshots(PurgeSnapshotQuery.create().setId(projectSnapshotId).setNotPurged(true), session, purgeMapper);
session.commit();
}
}
@@ -156,84 +156,11 @@ public class PurgeDao {
}
List<Long> resourceIds = mapper.selectResourceIdsByRootId(rootProjectId);
- deleteResources(resourceIds, session, mapper, vendorMapper);
+ PurgeCommands.deleteResources(resourceIds, session, mapper, vendorMapper);
session.commit();
}
@VisibleForTesting
- void deleteResources(List<Long> resourceIds, SqlSession session, PurgeMapper mapper, PurgeVendorMapper vendorMapper) {
- // Note : do not merge the delete statements into a single loop of resource ids. It's
- // voluntarily grouped by tables in order to benefit from JDBC batch mode.
- // Batch requests can only relate to the same PreparedStatement.
-
- for (Long resourceId : resourceIds) {
- deleteSnapshots(PurgeSnapshotQuery.create().setResourceId(resourceId), session, mapper);
- }
-
- // possible missing optimization: filter requests according to resource scope
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResourceLinks(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResourceProperties(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResourceIndex(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResourceGroupRoles(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResourceUserRoles(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResourceManualMeasures(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- vendorMapper.deleteResourceReviewComments(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- vendorMapper.deleteResourceActionPlansReviews(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResourceReviews(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResourceActionPlans(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResourceEvents(resourceId);
- }
- session.flushStatements();
-
- for (Long resourceId : resourceIds) {
- mapper.deleteResource(resourceId);
- }
- session.flushStatements();
- }
-
- @VisibleForTesting
void disableResource(long resourceId, PurgeMapper mapper) {
mapper.deleteResourceIndex(resourceId);
mapper.setSnapshotIsLastToFalse(resourceId);
@@ -245,7 +172,7 @@ public class PurgeDao {
final SqlSession session = mybatis.openBatchSession();
try {
final PurgeMapper mapper = session.getMapper(PurgeMapper.class);
- deleteSnapshots(mapper.selectSnapshotIds(query), session, mapper);
+ PurgeCommands.deleteSnapshots(query, session, mapper);
session.commit();
return this;
@@ -254,97 +181,6 @@ public class PurgeDao {
}
}
- @VisibleForTesting
- void deleteSnapshots(final PurgeSnapshotQuery query, final SqlSession session, final PurgeMapper mapper) {
- deleteSnapshots(mapper.selectSnapshotIds(query), session, mapper);
- }
-
- private void deleteSnapshots(final List<Long> snapshotIds, final SqlSession session, final PurgeMapper mapper) {
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotDependencies(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotDuplications(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotEvents(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotMeasureData(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotMeasures(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotSource(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotViolations(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshot(snapshotId);
- }
-
- session.flushStatements();
- }
-
- @VisibleForTesting
- void purgeSnapshots(final PurgeSnapshotQuery query, final SqlSession session, final PurgeMapper mapper) {
- purgeSnapshots(mapper.selectSnapshotIds(query), session, mapper);
- }
-
- private void purgeSnapshots(final List<Long> snapshotIds, final SqlSession session, final PurgeMapper mapper) {
- // note that events are not deleted
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotDependencies(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotDuplications(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotSource(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotViolations(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotWastedMeasures(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.deleteSnapshotMeasuresOnQualityModelRequirements(snapshotId);
- }
- session.flushStatements();
-
- for (Long snapshotId : snapshotIds) {
- mapper.updatePurgeStatusToOne(snapshotId);
- }
- session.flushStatements();
- }
-
/**
* Load the whole tree of projects, including the project given in parameter.
*/
diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java
new file mode 100644
index 00000000000..d4411bfa8be
--- /dev/null
+++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java
@@ -0,0 +1,89 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.purge;
+
+import org.apache.ibatis.session.SqlSession;
+import org.junit.Test;
+import org.sonar.core.persistence.DaoTestCase;
+import org.sonar.core.persistence.MyBatis;
+
+import java.util.Arrays;
+
+public class PurgeCommandsTest extends DaoTestCase {
+ /**
+ * Test that all related data is deleted.
+ */
+ @Test
+ public void shouldDeleteSnapshot() {
+ setupData("shouldDeleteSnapshot");
+
+ SqlSession session = getMyBatis().openSession();
+ try {
+ PurgeCommands.deleteSnapshots(PurgeSnapshotQuery.create().setId(5L), session, session.getMapper(PurgeMapper.class));
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ checkTables("shouldDeleteSnapshot",
+ "snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources", "duplications_index", "events", "dependencies");
+ }
+
+ /**
+ * Test that all related data is purged.
+ */
+ @Test
+ public void shouldPurgeSnapshot() {
+ setupData("shouldPurgeSnapshot");
+
+ SqlSession session = getMyBatis().openSession();
+ try {
+ PurgeCommands.purgeSnapshots(PurgeSnapshotQuery.create().setId(1L), session, session.getMapper(PurgeMapper.class));
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ checkTables("shouldPurgeSnapshot",
+ "snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources", "duplications_index", "events", "dependencies", "reviews");
+ }
+
+ @Test
+ public void shouldDeleteWastedMeasuresWhenPurgingSnapshot() {
+ setupData("shouldDeleteWastedMeasuresWhenPurgingSnapshot");
+
+ SqlSession session = getMyBatis().openSession();
+ try {
+ PurgeCommands.purgeSnapshots(PurgeSnapshotQuery.create().setId(1L), session, session.getMapper(PurgeMapper.class));
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ checkTables("shouldDeleteWastedMeasuresWhenPurgingSnapshot", "project_measures");
+ }
+
+ @Test
+ public void shouldDeleteResource() {
+ setupData("shouldDeleteResource");
+ SqlSession session = getMyBatis().openSession();
+ try {
+ PurgeCommands.deleteResources(Arrays.asList(1L), session, session.getMapper(PurgeMapper.class), session.getMapper(PurgeVendorMapper.class));
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ assertEmptyTables("projects", "snapshots", "events", "reviews", "review_comments");
+ }
+
+}
diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java
index 2df27e177c2..9269f7c4daf 100644
--- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java
@@ -29,7 +29,6 @@ import org.sonar.core.persistence.DaoTestCase;
import org.sonar.core.persistence.MyBatis;
import org.sonar.core.resource.ResourceDao;
-import java.util.Arrays;
import java.util.List;
import static org.hamcrest.Matchers.is;
@@ -45,26 +44,6 @@ public class PurgeDaoTest extends DaoTestCase {
dao = new PurgeDao(getMyBatis(), new ResourceDao(getMyBatis()));
}
- /**
- * Test that all related data is deleted.
- */
- @Test
- public void shouldDeleteSnapshot() {
- setupData("shouldDeleteSnapshot");
-
- SqlSession session = getMyBatis().openSession();
- try {
- // this method does not commit and close the session
- dao.deleteSnapshots(PurgeSnapshotQuery.create().setId(5L), session, session.getMapper(PurgeMapper.class));
- session.commit();
-
- } finally {
- MyBatis.closeQuietly(session);
- }
- checkTables("shouldDeleteSnapshot",
- "snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources", "duplications_index", "events", "dependencies");
- }
-
@Test
public void shouldDeleteAbortedBuilds() {
setupData("shouldDeleteAbortedBuilds");
@@ -72,44 +51,6 @@ public class PurgeDaoTest extends DaoTestCase {
checkTables("shouldDeleteAbortedBuilds", "snapshots");
}
- /**
- * Test that all related data is purged.
- */
- @Test
- public void shouldPurgeSnapshot() {
- setupData("shouldPurgeSnapshot");
-
- SqlSession session = getMyBatis().openSession();
- try {
- dao.purgeSnapshots(PurgeSnapshotQuery.create().setId(1L), session, session.getMapper(PurgeMapper.class));
-
- // the above method does not commit and close the session
- session.commit();
-
- } finally {
- MyBatis.closeQuietly(session);
- }
- checkTables("shouldPurgeSnapshot",
- "snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources", "duplications_index", "events", "dependencies", "reviews");
- }
-
- @Test
- public void shouldDeleteWastedMeasuresWhenPurgingSnapshot() {
- setupData("shouldDeleteWastedMeasuresWhenPurgingSnapshot");
-
- SqlSession session = getMyBatis().openSession();
- try {
- dao.purgeSnapshots(PurgeSnapshotQuery.create().setId(1L), session, session.getMapper(PurgeMapper.class));
-
- // the above method does not commit and close the session
- session.commit();
-
- } finally {
- MyBatis.closeQuietly(session);
- }
- checkTables("shouldDeleteWastedMeasuresWhenPurgingSnapshot", "project_measures");
- }
-
@Test
public void shouldCloseReviewWhenDisablingResource() {
setupData("shouldCloseReviewWhenDisablingResource");
@@ -168,22 +109,6 @@ public class PurgeDaoTest extends DaoTestCase {
}
@Test
- public void shouldDeleteResource() {
- setupData("shouldDeleteResource");
- SqlSession session = getMyBatis().openSession();
- try {
- dao.deleteResources(Arrays.asList(1L), session, session.getMapper(PurgeMapper.class), session.getMapper(PurgeVendorMapper.class));
-
- // the above method does not commit and close the session
- session.commit();
-
- } finally {
- MyBatis.closeQuietly(session);
- }
- assertEmptyTables("projects", "snapshots", "events", "reviews", "review_comments");
- }
-
- @Test
public void shouldDeleteProject() {
setupData("shouldDeleteProject");
dao.deleteProject(1L);
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteResource.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml
index df9741558c4..df9741558c4 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteResource.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml
index 6734c0522a8..6734c0522a8 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteSnapshot-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteSnapshot.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml
index 61ebfe5caab..61ebfe5caab 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteSnapshot.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
index d264293021c..d264293021c 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
index b9fddbbc0c9..b9fddbbc0c9 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml
index b8af6c0b035..b8af6c0b035 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeSnapshot-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeSnapshot.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml
index ef7489378b9..ef7489378b9 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeSnapshot.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml