From: Simon Brandhof Date: Wed, 20 May 2015 20:56:23 +0000 (+0200) Subject: Delete DefaultPurgeTask and remove DefaultPeriodCleaner from batch X-Git-Tag: 5.2-RC1~1890 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6a3878fc89eedc318c941ee76ef961a124d2094c;p=sonarqube.git Delete DefaultPurgeTask and remove DefaultPeriodCleaner from batch --- diff --git a/server/sonar-server/src/main/java/org/sonar/core/computation/dbcleaner/ProjectCleaner.java b/server/sonar-server/src/main/java/org/sonar/core/computation/dbcleaner/ProjectCleaner.java index bc42ff16bcb..06045818a17 100644 --- a/server/sonar-server/src/main/java/org/sonar/core/computation/dbcleaner/ProjectCleaner.java +++ b/server/sonar-server/src/main/java/org/sonar/core/computation/dbcleaner/ProjectCleaner.java @@ -20,9 +20,11 @@ package org.sonar.core.computation.dbcleaner; +import java.util.Date; +import javax.annotation.Nullable; import org.sonar.api.CoreProperties; -import org.sonar.api.server.ServerSide; import org.sonar.api.config.Settings; +import org.sonar.api.server.ServerSide; import org.sonar.api.utils.TimeUtils; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; @@ -35,10 +37,6 @@ import org.sonar.core.purge.PurgeListener; import org.sonar.core.purge.PurgeProfiler; import org.sonar.server.issue.index.IssueIndex; -import javax.annotation.Nullable; - -import java.util.Date; - import static org.sonar.core.purge.PurgeConfiguration.newDefaultPurgeConfiguration; @ServerSide diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index fb540860f08..987e8901d21 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -19,6 +19,7 @@ */ package org.sonar.server.platform.platformlevel; +import java.util.List; import org.sonar.api.config.EmailSettings; import org.sonar.api.issue.action.Actions; import org.sonar.api.profiles.AnnotationProfileParser; @@ -29,7 +30,6 @@ import org.sonar.api.resources.ResourceTypes; import org.sonar.api.rules.AnnotationRuleParser; import org.sonar.api.rules.XMLRuleParser; import org.sonar.api.server.rule.RulesDefinitionXmlLoader; -import org.sonar.core.computation.dbcleaner.DefaultPurgeTask; import org.sonar.core.computation.dbcleaner.IndexPurgeListener; import org.sonar.core.computation.dbcleaner.ProjectCleaner; import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner; @@ -292,8 +292,6 @@ import org.sonar.server.view.index.ViewIndexer; import org.sonar.server.ws.ListingWs; import org.sonar.server.ws.WebServiceEngine; -import java.util.List; - public class PlatformLevel4 extends PlatformLevel { private final List level4AddedComponents; @@ -681,7 +679,6 @@ public class PlatformLevel4 extends PlatformLevel { QueueAction.class, HistoryAction.class, DefaultPeriodCleaner.class, - DefaultPurgeTask.class, ProjectCleaner.class, ProjectSettingsFactory.class, IndexPurgeListener.class, diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java index 5c6d7e073d1..c584274eaf5 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java @@ -20,6 +20,8 @@ package org.sonar.batch.bootstrap; import com.google.common.collect.Lists; +import java.util.Collection; +import java.util.List; import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.batch.cpd.CpdComponents; import org.sonar.batch.debt.DebtDecorator; @@ -48,14 +50,9 @@ import org.sonar.batch.scm.ScmConfiguration; import org.sonar.batch.scm.ScmSensor; import org.sonar.batch.source.CodeColorizerSensor; import org.sonar.batch.source.LinesSensor; -import org.sonar.core.computation.dbcleaner.DefaultPurgeTask; -import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner; import org.sonar.core.config.CorePropertyDefinitions; import org.sonar.core.notification.DefaultNotificationManager; -import java.util.Collection; -import java.util.List; - public class BatchComponents { private BatchComponents() { // only static stuff @@ -84,10 +81,6 @@ public class BatchComponents { SourceProvider.class, RuleNameProvider.class, - // dbcleaner - DefaultPeriodCleaner.class, - DefaultPurgeTask.class, - QualityGateVerifier.class, // language diff --git a/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTask.java b/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTask.java deleted file mode 100644 index d9e7f18193b..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTask.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.core.computation.dbcleaner; - -import com.google.common.annotations.VisibleForTesting; -import org.sonar.api.CoreProperties; -import org.sonar.api.config.Settings; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.utils.TimeUtils; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner; -import org.sonar.core.purge.IdUuidPair; -import org.sonar.core.purge.PurgeConfiguration; -import org.sonar.core.purge.PurgeDao; -import org.sonar.core.purge.PurgeListener; -import org.sonar.core.purge.PurgeProfiler; -import org.sonar.core.resource.ResourceDao; -import org.sonar.core.resource.ResourceDto; -import org.sonar.plugins.dbcleaner.api.PurgeTask; - -import static org.sonar.core.purge.PurgeConfiguration.newDefaultPurgeConfiguration; - -/** - * @since 2.14 - */ -public class DefaultPurgeTask implements PurgeTask { - private static final Logger LOG = Loggers.get(DefaultPurgeTask.class); - private final PurgeProfiler profiler; - private final PurgeDao purgeDao; - private final ResourceDao resourceDao; - private final Settings settings; - private final DefaultPeriodCleaner periodCleaner; - - public DefaultPurgeTask(PurgeDao purgeDao, ResourceDao resourceDao, Settings settings, DefaultPeriodCleaner periodCleaner, PurgeProfiler profiler) { - this.purgeDao = purgeDao; - this.resourceDao = resourceDao; - this.settings = settings; - this.periodCleaner = periodCleaner; - this.profiler = profiler; - } - - @Override - public DefaultPurgeTask delete(long resourceId) { - ResourceDto resource = resourceDao.getResource(resourceId); - if (resource != null) { - purgeDao.deleteResourceTree(new IdUuidPair(resource.getId(), resource.getUuid())); - } - - return this; - } - - @VisibleForTesting - boolean isNotViewNorSubview(String resourceQualifier) { - return !(Qualifiers.VIEW.equals(resourceQualifier) || Qualifiers.SUBVIEW.equals(resourceQualifier)); - } - - @Override - public DefaultPurgeTask purge(long resourceId) { - long start = System.currentTimeMillis(); - ResourceDto component = resourceDao.getResource(resourceId); - if (isNotViewNorSubview(component.getQualifier())) { - profiler.reset(); - cleanHistoricalData(resourceId); - doPurge(new IdUuidPair(component.getId(), component.getUuid())); - if (settings.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY)) { - long duration = System.currentTimeMillis() - start; - LOG.info("\n -------- Profiling for purge: " + TimeUtils.formatDuration(duration) + " --------\n"); - profiler.dump(duration, LOG); - LOG.info("\n -------- End of profiling for purge --------\n"); - } - } - return this; - } - - private void cleanHistoricalData(long resourceId) { - try { - periodCleaner.clean(resourceId); - } catch (Exception e) { - // purge errors must not fail the batch - LOG.error("Fail to clean historical data [id=" + resourceId + "]", e); - } - } - - private void doPurge(IdUuidPair componentIdUuid) { - try { - purgeDao.purge(newPurgeConfigurationOnResource(componentIdUuid), PurgeListener.EMPTY); - } catch (Exception e) { - // purge errors must not fail the report analysis - LOG.error("Fail to purge data [id=" + componentIdUuid + "]", e); - } - } - - public PurgeConfiguration newPurgeConfigurationOnResource(IdUuidPair componentIdUuid) { - return newDefaultPurgeConfiguration(settings, componentIdUuid); - } -} diff --git a/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/period/DefaultPeriodCleaner.java b/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/period/DefaultPeriodCleaner.java index 73bf08436d0..65dce4be5eb 100644 --- a/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/period/DefaultPeriodCleaner.java +++ b/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/period/DefaultPeriodCleaner.java @@ -21,46 +21,25 @@ package org.sonar.core.computation.dbcleaner.period; import com.google.common.annotations.VisibleForTesting; -import org.sonar.api.batch.BatchSide; -import org.sonar.api.server.ServerSide; +import java.util.List; import org.sonar.api.config.Settings; +import org.sonar.api.server.ServerSide; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.core.persistence.DbSession; -import org.sonar.core.persistence.MyBatis; import org.sonar.core.purge.PurgeDao; import org.sonar.core.purge.PurgeSnapshotQuery; import org.sonar.core.purge.PurgeableSnapshotDto; -import java.util.List; - -@BatchSide @ServerSide public class DefaultPeriodCleaner { private static final Logger LOG = Loggers.get(DefaultPeriodCleaner.class); private PurgeDao purgeDao; - private Settings settings; - private MyBatis mybatis; - public DefaultPeriodCleaner(PurgeDao purgeDao, Settings settings, MyBatis mybatis) { + public DefaultPeriodCleaner(PurgeDao purgeDao) { this.purgeDao = purgeDao; - this.settings = settings; - this.mybatis = mybatis; - } - - public void clean(long projectId) { - clean(projectId, settings); - } - - public void clean(long projectId, Settings settings) { - DbSession session = mybatis.openSession(true); - try { - doClean(projectId, new Filters(settings).all(), session); - } finally { - MyBatis.closeQuietly(session); - } } public void clean(DbSession session, long projectId, Settings settings) { diff --git a/sonar-core/src/main/java/org/sonar/plugins/dbcleaner/api/DbCleanerConstants.java b/sonar-core/src/main/java/org/sonar/plugins/dbcleaner/api/DbCleanerConstants.java deleted file mode 100644 index 8cad98c10c5..00000000000 --- a/sonar-core/src/main/java/org/sonar/plugins/dbcleaner/api/DbCleanerConstants.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.dbcleaner.api; - -/** - * @deprecated (is used by the plugin views only. Will rely on the implementation when views analysis views moved on the server side) - */ -@Deprecated -public interface DbCleanerConstants extends org.sonar.core.computation.dbcleaner.DbCleanerConstants { -} diff --git a/sonar-core/src/main/java/org/sonar/plugins/dbcleaner/api/PurgeTask.java b/sonar-core/src/main/java/org/sonar/plugins/dbcleaner/api/PurgeTask.java deleted file mode 100644 index 7636b136936..00000000000 --- a/sonar-core/src/main/java/org/sonar/plugins/dbcleaner/api/PurgeTask.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.dbcleaner.api; - -import org.sonar.api.batch.BatchSide; -import org.sonar.api.server.ServerSide; - -/** - * @since 2.14 - * @deprecated (is used by the plugin views only. Will rely on the implementation when views analysis views moved on the server side) - */ -@Deprecated -@BatchSide -@ServerSide -public interface PurgeTask { - /** - * Purges the data related to a tree of resources. - *

- * Exceptions are logged and are not thrown again, so this method fails only on {@link Error}s. - * - * @param resourceId the root of the tree - * @return this - */ - PurgeTask purge(long resourceId); - - /** - * Completely deletes a tree of resources. - * - * @param resourceId the root of the tree - * @return this - */ - PurgeTask delete(long resourceId); -} diff --git a/sonar-core/src/main/java/org/sonar/plugins/dbcleaner/api/package-info.java b/sonar-core/src/main/java/org/sonar/plugins/dbcleaner/api/package-info.java deleted file mode 100644 index 87f1b0c4dc3..00000000000 --- a/sonar-core/src/main/java/org/sonar/plugins/dbcleaner/api/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@ParametersAreNonnullByDefault -package org.sonar.plugins.dbcleaner.api; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTaskTest.java b/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTaskTest.java deleted file mode 100644 index 2cdaf6ff69a..00000000000 --- a/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTaskTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.core.computation.dbcleaner; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentMatcher; -import org.sonar.api.CoreProperties; -import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.config.Settings; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; -import org.sonar.api.utils.log.Logger; -import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner; -import org.sonar.core.purge.IdUuidPair; -import org.sonar.core.purge.PurgeConfiguration; -import org.sonar.core.purge.PurgeDao; -import org.sonar.core.purge.PurgeListener; -import org.sonar.core.purge.PurgeProfiler; -import org.sonar.core.resource.ResourceDao; -import org.sonar.core.resource.ResourceDto; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; - -public class DefaultPurgeTaskTest { - - private DefaultPurgeTask sut; - private ResourceDao resourceDao; - private PurgeDao purgeDao; - private Settings settings; - private DefaultPeriodCleaner periodCleaner; - private PurgeProfiler profiler; - - @Before - public void before() { - this.purgeDao = mock(PurgeDao.class); - this.resourceDao = mock(ResourceDao.class); - when(resourceDao.getResource(anyLong())).thenReturn(new ResourceDto().setQualifier(Qualifiers.PROJECT).setUuid("1").setId(1L)); - - this.settings = mock(Settings.class); - this.periodCleaner = mock(DefaultPeriodCleaner.class); - this.profiler = mock(PurgeProfiler.class); - - this.sut = new DefaultPurgeTask(purgeDao, resourceDao, settings, periodCleaner, profiler); - } - - @Test - public void shouldNotDeleteHistoricalDataOfDirectories() { - PurgeDao purgeDao = mock(PurgeDao.class); - Settings settings = new Settings(new PropertyDefinitions(DataCleanerProperties.all())); - settings.setProperty(DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY, "false"); - DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, resourceDao, settings, mock(DefaultPeriodCleaner.class), mock(PurgeProfiler.class)); - - task.purge(1L); - - verify(purgeDao).purge(argThat(new ArgumentMatcher() { - @Override - public boolean matches(Object o) { - PurgeConfiguration conf = (PurgeConfiguration) o; - return conf.rootProjectIdUuid().getId() == 1L && conf.scopesWithoutHistoricalData().length == 1 && conf.scopesWithoutHistoricalData()[0].equals(Scopes.FILE); - } - }), any(PurgeListener.class)); - } - - @Test - public void shouldDeleteHistoricalDataOfDirectoriesByDefault() { - PurgeDao purgeDao = mock(PurgeDao.class); - Settings settings = new Settings(new PropertyDefinitions(DataCleanerProperties.all())); - DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, resourceDao, settings, mock(DefaultPeriodCleaner.class), mock(PurgeProfiler.class)); - - task.purge(1L); - - verify(purgeDao).purge(argThat(new ArgumentMatcher() { - @Override - public boolean matches(Object o) { - PurgeConfiguration conf = (PurgeConfiguration) o; - return conf.rootProjectIdUuid().getId() == 1L && - conf.scopesWithoutHistoricalData().length == 2 && - conf.scopesWithoutHistoricalData()[0].equals(Scopes.DIRECTORY) && - conf.scopesWithoutHistoricalData()[1].equals(Scopes.FILE); - } - }), any(PurgeListener.class)); - } - - @Test - public void shouldNotFailOnErrors() { - PurgeDao purgeDao = mock(PurgeDao.class); - when(purgeDao.purge(any(PurgeConfiguration.class), any(PurgeListener.class))).thenThrow(new RuntimeException()); - DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, resourceDao, new Settings(), mock(DefaultPeriodCleaner.class), mock(PurgeProfiler.class)); - - task.purge(1L); - - verify(purgeDao, times(1)).purge(any(PurgeConfiguration.class), any(PurgeListener.class)); - } - - @Test - public void shouldDumpProfiling() { - PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30); - PurgeDao purgeDao = mock(PurgeDao.class); - when(purgeDao.purge(conf, PurgeListener.EMPTY)).thenThrow(new RuntimeException()); - Settings settings = new Settings(new PropertyDefinitions(DataCleanerProperties.all())); - settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, true); - PurgeProfiler profiler = mock(PurgeProfiler.class); - - DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, resourceDao, settings, mock(DefaultPeriodCleaner.class), profiler); - task.purge(1L); - - verify(profiler).dump(anyLong(), any(Logger.class)); - } - - @Test - public void recognize_view_and_subview() { - boolean viewCheck = sut.isNotViewNorSubview(Qualifiers.VIEW); - boolean subViewCheck = sut.isNotViewNorSubview(Qualifiers.SUBVIEW); - - assertThat(viewCheck).isFalse(); - assertThat(subViewCheck).isFalse(); - } - - @Test - public void call_dao_delete_when_deleting() { - when(resourceDao.getResource(123L)).thenReturn(new ResourceDto().setId(123L).setUuid("A")); - - sut.delete(123L); - - verify(purgeDao, times(1)).deleteResourceTree(any(IdUuidPair.class)); - } -} diff --git a/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/period/DefaultPeriodCleanerTest.java b/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/period/DefaultPeriodCleanerTest.java index 1ee4682e374..fafd5bf23f3 100644 --- a/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/period/DefaultPeriodCleanerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/period/DefaultPeriodCleanerTest.java @@ -20,23 +20,26 @@ package org.sonar.core.computation.dbcleaner.period; +import java.util.Arrays; import org.apache.commons.lang.ObjectUtils; import org.hamcrest.BaseMatcher; import org.junit.Test; import org.mockito.ArgumentMatcher; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.sonar.api.config.Settings; import org.sonar.api.utils.System2; import org.sonar.core.persistence.DbSession; -import org.sonar.core.persistence.MyBatis; import org.sonar.core.purge.PurgeDao; import org.sonar.core.purge.PurgeSnapshotQuery; import org.sonar.core.purge.PurgeableSnapshotDto; -import java.util.Arrays; - -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.anyListOf; +import static org.mockito.Mockito.argThat; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class DefaultPeriodCleanerTest { @@ -49,7 +52,7 @@ public class DefaultPeriodCleanerTest { Filter filter1 = newLazyFilter(); Filter filter2 = newLazyFilter(); - DefaultPeriodCleaner cleaner = new DefaultPeriodCleaner(dao, mock(Settings.class), mock(MyBatis.class)); + DefaultPeriodCleaner cleaner = new DefaultPeriodCleaner(dao); cleaner.doClean(123L, Arrays.asList(filter1, filter2), session); verify(filter1).log();