]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9057 make PurgeCeActivities startable
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 30 Mar 2017 16:52:30 +0000 (18:52 +0200)
committerEric Hartmann <hartmann.eric@gmail.Com>
Thu, 27 Apr 2017 07:23:18 +0000 (09:23 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/queue/PurgeCeActivities.java
server/sonar-server/src/test/java/org/sonar/server/computation/queue/PurgeCeActivitiesTest.java

index 1621fadc1771d74fa8841b1d8ad6ac34b518519b..3c91b933fda867f661e0617239c77d6022b4cafe 100644 (file)
@@ -21,9 +21,8 @@ package org.sonar.server.computation.queue;
 
 import java.util.Calendar;
 import java.util.Set;
+import org.sonar.api.Startable;
 import org.sonar.api.ce.ComputeEngineSide;
-import org.sonar.api.platform.Server;
-import org.sonar.api.platform.ServerStartHandler;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
@@ -33,7 +32,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.ce.CeActivityDto;
 
 @ComputeEngineSide
-public class PurgeCeActivities implements ServerStartHandler {
+public class PurgeCeActivities implements Startable {
 
   private static final Logger LOGGER = Loggers.get(PurgeCeActivities.class);
 
@@ -46,7 +45,7 @@ public class PurgeCeActivities implements ServerStartHandler {
   }
 
   @Override
-  public void onServerStart(Server server) {
+  public void start() {
     try (DbSession dbSession = dbClient.openSession(false)) {
       Calendar sixMonthsAgo = Calendar.getInstance();
       sixMonthsAgo.setTimeInMillis(system2.now());
@@ -62,4 +61,9 @@ public class PurgeCeActivities implements ServerStartHandler {
       dbSession.commit();
     }
   }
+
+  @Override
+  public void stop() {
+    // nothing to do
+  }
 }
index e6d205866ab940ca4fa19913493ec417d56b55f7..2436a316fc662ab350efbdf69f09972b08788513 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.computation.queue;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.platform.Server;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.ce.CeActivityDto;
@@ -29,7 +28,6 @@ import org.sonar.db.ce.CeQueueDto;
 import org.sonar.db.ce.CeTaskTypes;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
@@ -48,7 +46,7 @@ public class PurgeCeActivitiesTest {
     insertWithDate("RECENT", 1_500_000_000_000L);
     when(system2.now()).thenReturn(1_500_000_000_100L);
 
-    underTest.onServerStart(mock(Server.class));
+    underTest.start();
 
     assertThat(dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), "VERY_OLD").isPresent()).isFalse();
     assertThat(dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), "RECENT").isPresent()).isTrue();