mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-30 11:19:08 +01:00
implemented restarter to move control over the restart process to the core
This commit is contained in:
@@ -12,10 +12,12 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junitpioneer.jupiter.TempDirectory;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.ScmConstraintViolationException;
|
||||
import sonia.scm.lifecycle.Restarter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@@ -54,13 +56,15 @@ class DefaultPluginManagerTest {
|
||||
@Mock
|
||||
private PluginInstaller installer;
|
||||
|
||||
@Mock
|
||||
private Restarter restarter;
|
||||
|
||||
@InjectMocks
|
||||
private DefaultPluginManager manager;
|
||||
|
||||
@Mock
|
||||
private Subject subject;
|
||||
|
||||
private boolean restartTriggered = false;
|
||||
|
||||
@BeforeEach
|
||||
void mockInstaller() {
|
||||
lenient().when(installer.install(any())).then(ic -> {
|
||||
@@ -69,16 +73,6 @@ class DefaultPluginManagerTest {
|
||||
});
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void createPluginManagerToTestWithCapturedRestart() {
|
||||
manager = new DefaultPluginManager(null, loader, center, installer) { // event bus is only used in restart and this is replaced here
|
||||
@Override
|
||||
void triggerRestart(String cause) {
|
||||
restartTriggered = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nested
|
||||
class WithAdminPermissions {
|
||||
|
||||
@@ -185,7 +179,7 @@ class DefaultPluginManagerTest {
|
||||
manager.install("scm-git-plugin", false);
|
||||
|
||||
verify(installer).install(git);
|
||||
assertThat(restartTriggered).isFalse();
|
||||
verify(restarter, never()).restart(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -263,7 +257,7 @@ class DefaultPluginManagerTest {
|
||||
manager.install("scm-git-plugin", true);
|
||||
|
||||
verify(installer).install(git);
|
||||
assertThat(restartTriggered).isTrue();
|
||||
verify(restarter).restart(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -272,7 +266,7 @@ class DefaultPluginManagerTest {
|
||||
when(loader.getInstalledPlugins()).thenReturn(ImmutableList.of(gitInstalled));
|
||||
|
||||
manager.install("scm-git-plugin", true);
|
||||
assertThat(restartTriggered).isFalse();
|
||||
verify(restarter, never()).restart(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -294,14 +288,14 @@ class DefaultPluginManagerTest {
|
||||
manager.install("scm-review-plugin", false);
|
||||
manager.executePendingAndRestart();
|
||||
|
||||
assertThat(restartTriggered).isTrue();
|
||||
verify(restarter).restart(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotSendRestartEventWithoutPendingPlugins() {
|
||||
manager.executePendingAndRestart();
|
||||
|
||||
assertThat(restartTriggered).isFalse();
|
||||
verify(restarter, never()).restart(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -452,7 +446,7 @@ class DefaultPluginManagerTest {
|
||||
|
||||
manager.executePendingAndRestart();
|
||||
|
||||
assertThat(restartTriggered).isTrue();
|
||||
verify(restarter).restart(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user