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(""))));
}
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());
}
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());
}
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;
}
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;
}
Aggregations