diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-05-31 15:12:29 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-05-31 15:12:46 +0200 |
commit | be0fdd37d9b4cd911b88009114d2264f37035160 (patch) | |
tree | cea98dc00d639a82a14e1d065ac1a5f3d00bae22 /plugins/sonar-dbcleaner-plugin | |
parent | 9d06327a9d587832b93e1204a813120ae26075ee (diff) | |
download | sonarqube-be0fdd37d9b4cd911b88009114d2264f37035160.tar.gz sonarqube-be0fdd37d9b4cd911b88009114d2264f37035160.zip |
Fix some quality flaws
Diffstat (limited to 'plugins/sonar-dbcleaner-plugin')
2 files changed, 17 insertions, 12 deletions
diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java index afafdb93a2a..19f607b69a7 100644 --- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java +++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java @@ -62,9 +62,9 @@ public class DefaultPurgeTask implements PurgeTask { doPurge(resourceId); if (settings.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY)) { long duration = System.currentTimeMillis() - start; - System.out.println("\n -------- Profiling for purge: " + TimeUtils.formatDuration(duration) + " --------\n"); - profiler.dump(duration); - System.out.println("\n -------- End of profiling for purge --------\n"); + 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; } @@ -88,9 +88,9 @@ public class DefaultPurgeTask implements PurgeTask { } private PurgeConfiguration newConf(long resourceId) { - String[] scopes = new String[]{Scopes.FILE}; + String[] scopes = new String[] {Scopes.FILE}; if (settings.getBoolean(DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY)) { - scopes = new String[]{Scopes.DIRECTORY, Scopes.FILE}; + scopes = new String[] {Scopes.DIRECTORY, Scopes.FILE}; } return new PurgeConfiguration(resourceId, scopes, settings.getInt(DbCleanerConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES)); } diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DefaultPurgeTaskTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DefaultPurgeTaskTest.java index 93669697408..4469ad0ac65 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DefaultPurgeTaskTest.java +++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DefaultPurgeTaskTest.java @@ -19,6 +19,7 @@ */ package org.sonar.plugins.dbcleaner; +import ch.qos.logback.classic.Logger; import org.junit.Test; import org.mockito.ArgumentMatcher; import org.sonar.api.CoreProperties; @@ -33,7 +34,11 @@ import org.sonar.plugins.dbcleaner.period.DefaultPeriodCleaner; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyLong; -import static org.mockito.Mockito.*; +import static org.mockito.Matchers.argThat; +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 DefaultPurgeTaskTest { @Test @@ -48,8 +53,8 @@ public class DefaultPurgeTaskTest { verify(purgeDao).purge(argThat(new ArgumentMatcher<PurgeConfiguration>() { @Override public boolean matches(Object o) { - PurgeConfiguration conf = (PurgeConfiguration)o; - return conf.rootProjectId()==1L && conf.scopesWithoutHistoricalData().length==1 && conf.scopesWithoutHistoricalData()[0].equals(Scopes.FILE); + PurgeConfiguration conf = (PurgeConfiguration) o; + return conf.rootProjectId() == 1L && conf.scopesWithoutHistoricalData().length == 1 && conf.scopesWithoutHistoricalData()[0].equals(Scopes.FILE); } })); } @@ -65,9 +70,9 @@ public class DefaultPurgeTaskTest { verify(purgeDao).purge(argThat(new ArgumentMatcher<PurgeConfiguration>() { @Override public boolean matches(Object o) { - PurgeConfiguration conf = (PurgeConfiguration)o; - return conf.rootProjectId()==1L && - conf.scopesWithoutHistoricalData().length==2 && + PurgeConfiguration conf = (PurgeConfiguration) o; + return conf.rootProjectId() == 1L && + conf.scopesWithoutHistoricalData().length == 2 && conf.scopesWithoutHistoricalData()[0].equals(Scopes.DIRECTORY) && conf.scopesWithoutHistoricalData()[1].equals(Scopes.FILE); } @@ -97,6 +102,6 @@ public class DefaultPurgeTaskTest { DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, settings, mock(DefaultPeriodCleaner.class), profiler); task.purge(1L); - verify(profiler).dump(anyLong()); + verify(profiler).dump(anyLong(), any(Logger.class)); } } |