package org.sonar.server.computation;
import java.util.Calendar;
+import org.sonar.api.platform.Server;
+import org.sonar.api.platform.ServerStartHandler;
import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.log.Logger;
import org.sonar.db.DbSession;
@ServerSide
-public class PurgeCeActivities {
+public class PurgeCeActivities implements ServerStartHandler {
private static final Logger LOGGER = Loggers.get(PurgeCeActivities.class);
this.system2 = system2;
}
- /**
- * Do not rename. Used at server startup.
- */
- public void start() {
+ @Override
+ public void onServerStart(Server server) {
DbSession dbSession = dbClient.openSession(false);
try {
Calendar sixMonthsAgo = Calendar.getInstance();
import org.junit.Rule;
import org.junit.Test;
+import org.sonar.api.platform.Server;
import org.sonar.api.utils.internal.TestSystem2;
import org.sonar.db.DbTester;
import org.sonar.db.ce.CeActivityDto;
import org.sonar.db.ce.CeQueueDto;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
public class PurgeCeActivitiesTest {
insertWithDate("RECENT", 1_500_000_000_000L);
system2.setNow(1_500_000_000_100L);
- underTest.start();
+ underTest.onServerStart(mock(Server.class));
assertThat(dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), "VERY_OLD").isPresent()).isFalse();
assertThat(dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), "RECENT").isPresent()).isTrue();