Search in sources :

Example 26 with PluginOperationResult

use of com.qcadoo.plugin.api.PluginOperationResult in project qcadoo by qcadoo.

the class PluginManagerTest method shouldNotUninstallPluginWithEnabledDependencies.

@Test
public void shouldNotUninstallPluginWithEnabledDependencies() throws Exception {
    // given
    PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.dependenciesToUninstall(Collections.singleton(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
    given(pluginDependencyManager.getDependenciesToUninstall(Mockito.eq(singletonList((Plugin) plugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
    given(plugin.getFilename()).willReturn("filename");
    // when
    PluginOperationResult pluginOperationResult = pluginManager.uninstallPlugin("pluginname");
    // then
    verify(plugin, never()).changeStateTo(PluginState.DISABLED);
    verify(pluginDao, never()).delete(plugin);
    verify(pluginAccessor, never()).removePlugin(plugin);
    verify(pluginFileManager, never()).uninstallPlugin("filename");
    assertFalse(pluginOperationResult.isSuccess());
    assertEquals(PluginOperationStatus.DEPENDENCIES_TO_UNINSTALL, pluginOperationResult.getStatus());
    assertEquals(1, pluginOperationResult.getPluginDependencyResult().getDependenciesToUninstall().size());
    assertTrue(pluginOperationResult.getPluginDependencyResult().getDependenciesToUninstall().contains(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) VersionOfDependency(com.qcadoo.plugin.api.VersionOfDependency) PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) PluginDependencyInformation(com.qcadoo.plugin.api.PluginDependencyInformation) SimplePluginStatusResolver(com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver) Test(org.junit.Test)

Example 27 with PluginOperationResult

use of com.qcadoo.plugin.api.PluginOperationResult in project qcadoo by qcadoo.

the class PluginManagerTest method shouldUninstallTemporaryPlugin.

@Test
public void shouldUninstallTemporaryPlugin() throws Exception {
    // given
    given(plugin.hasState(PluginState.TEMPORARY)).willReturn(true);
    PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.satisfiedDependencies();
    given(pluginDependencyManager.getDependenciesToUninstall(Mockito.eq(singletonList((Plugin) plugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
    given(pluginDependencyManager.sortPluginsInDependencyOrder(singletonList((Plugin) plugin))).willReturn(singletonList((Plugin) plugin));
    given(plugin.getFilename()).willReturn("filename");
    // when
    PluginOperationResult pluginOperationResult = pluginManager.uninstallPlugin("pluginname");
    // then
    verify(plugin, never()).changeStateTo(PluginState.DISABLED);
    verify(pluginDao).delete(plugin);
    verify(pluginAccessor).removePlugin(plugin);
    verify(pluginFileManager).uninstallPlugin("filename");
    assertTrue(pluginOperationResult.isSuccess());
    assertEquals(PluginOperationStatus.SUCCESS, pluginOperationResult.getStatus());
    assertEquals(0, pluginOperationResult.getPluginDependencyResult().getDependenciesToUninstall().size());
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) SimplePluginStatusResolver(com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver) Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) Test(org.junit.Test)

Example 28 with PluginOperationResult

use of com.qcadoo.plugin.api.PluginOperationResult in project qcadoo by qcadoo.

the class PluginManagerTest method shouldNotDisableNotEnabledPlugin.

@Test
public void shouldNotDisableNotEnabledPlugin() throws Exception {
    // given
    given(plugin.hasState(PluginState.ENABLED)).willReturn(false);
    // when
    PluginOperationResult pluginOperationResult = pluginManager.disablePlugin("pluginname");
    // then
    verify(plugin, never()).changeStateTo(PluginState.DISABLED);
    verify(pluginDao, never()).save(plugin);
    verify(pluginAccessor, never()).savePlugin(plugin);
    assertTrue(pluginOperationResult.isSuccess());
    assertEquals(PluginOperationStatus.SUCCESS, pluginOperationResult.getStatus());
}
Also used : PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) Test(org.junit.Test)

Example 29 with PluginOperationResult

use of com.qcadoo.plugin.api.PluginOperationResult in project qcadoo by qcadoo.

the class PluginManagmentPerformer method performRemove.

public String performRemove(final List<String> pluginIdentifiers) {
    PluginOperationResult result = pluginManagmentConnector.performRemove(pluginIdentifiers);
    String url = null;
    switch(result.getStatus()) {
        case SUCCESS:
            url = createSuccessPageUrl("uninstall.success");
            break;
        case SUCCESS_WITH_RESTART:
            url = createRestartPageUrl(createSuccessPageUrl("uninstall.success"));
            break;
        case SYSTEM_PLUGIN_UNINSTALLING:
            url = createErrorPageUrl("uninstall.systemPlugin");
            break;
        case DEPENDENCIES_TO_UNINSTALL:
            url = createConfirmPageUrl("uninstall.dependenciesToUninstall", "uninstall.dependenciesToUninstallCancelLabel", "uninstall.dependenciesToUninstallAcceptLabel", "performUninstallingMultiplePlugins", result.getPluginDependencyResult().getDependenciesToUninstall(), pluginIdentifiers);
            break;
        default:
            throw new IllegalStateException(L_WRONG_STATUS);
    }
    return url;
}
Also used : PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult)

Example 30 with PluginOperationResult

use of com.qcadoo.plugin.api.PluginOperationResult in project qcadoo by qcadoo.

the class PluginManagmentPerformer method performEnable.

public String performEnable(final List<String> pluginIdentifiers) {
    PluginOperationResult result = pluginManagmentConnector.performEnable(pluginIdentifiers);
    String url = null;
    switch(result.getStatus()) {
        case SUCCESS:
            url = createSuccessPageUrl("enable.success");
            break;
        case SUCCESS_WITH_RESTART:
            url = createRestartPageUrl(createSuccessPageUrl("enable.success"));
            break;
        case UNSATISFIED_DEPENDENCIES:
            url = createErrorPageUrl("enable.unsatisfiedDependencies", result.getPluginDependencyResult().getUnsatisfiedDependencies());
            break;
        case DEPENDENCIES_TO_ENABLE:
            url = createConfirmPageUrl("enable.dependenciesToEnable", "enable.dependenciesToEnableCancelLabel", "enable.dependenciesToEnableAcceptLabel", "performEnablingMultiplePlugins", result.getPluginDependencyResult().getDependenciesToEnable(), pluginIdentifiers);
            break;
        case CANNOT_INSTALL_PLUGIN_FILE:
            url = createErrorPageUrl("enable.cannotInstall");
            break;
        case PLUGIN_ENABLING_ENCOUNTERED_ERRORS:
            url = createErrorPageUrl("enable.encounteredErrors");
            break;
        default:
            throw new IllegalStateException(L_WRONG_STATUS);
    }
    return url;
}
Also used : PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult)

Aggregations

PluginOperationResult (com.qcadoo.plugin.api.PluginOperationResult)35 Test (org.junit.Test)31 PluginDependencyResult (com.qcadoo.plugin.api.PluginDependencyResult)15 SimplePluginStatusResolver (com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver)15 InternalPlugin (com.qcadoo.plugin.internal.api.InternalPlugin)9 Plugin (com.qcadoo.plugin.api.Plugin)8 JarPluginArtifact (com.qcadoo.plugin.api.artifact.JarPluginArtifact)7 File (java.io.File)7 PluginDependencyInformation (com.qcadoo.plugin.api.PluginDependencyInformation)4 VersionOfDependency (com.qcadoo.plugin.api.VersionOfDependency)4 Version (com.qcadoo.plugin.api.Version)3 InOrder (org.mockito.InOrder)3