use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginManagerTest method shouldNotEnablePluginWithUnsatisfiedDependencies.
@Test
public void shouldNotEnablePluginWithUnsatisfiedDependencies() throws Exception {
// given
given(plugin.hasState(PluginState.DISABLED)).willReturn(true);
PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.unsatisfiedDependencies(Collections.singleton(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
given(pluginDependencyManager.getDependenciesToEnable(Mockito.eq(singletonList((Plugin) plugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
// when
PluginOperationResult pluginOperationResult = pluginManager.enablePlugin("pluginname");
// then
verify(plugin, never()).changeStateTo(PluginState.ENABLED);
verify(pluginDao, never()).save(plugin);
verify(pluginAccessor, never()).savePlugin(plugin);
assertFalse(pluginOperationResult.isSuccess());
assertEquals(PluginOperationStatus.UNSATISFIED_DEPENDENCIES, pluginOperationResult.getStatus());
assertEquals(1, pluginOperationResult.getPluginDependencyResult().getUnsatisfiedDependencies().size());
assertEquals(1, pluginOperationResult.getPluginDependencyResult().getUnsatisfiedDependencies().size());
assertTrue(pluginOperationResult.getPluginDependencyResult().getUnsatisfiedDependencies().contains(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginManagerTest method shouldNotDisablePluginWithEnabledDependencies.
@Test
public void shouldNotDisablePluginWithEnabledDependencies() throws Exception {
// given
given(plugin.hasState(PluginState.ENABLED)).willReturn(true);
PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.dependenciesToDisable(Collections.singleton(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
given(pluginDependencyManager.getDependenciesToDisable(Mockito.eq(singletonList((Plugin) plugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
// when
PluginOperationResult pluginOperationResult = pluginManager.disablePlugin("pluginname");
// then
verify(plugin, never()).changeStateTo(PluginState.DISABLED);
verify(pluginDao, never()).save(plugin);
verify(pluginAccessor, never()).savePlugin(plugin);
assertFalse(pluginOperationResult.isSuccess());
assertEquals(PluginOperationStatus.DEPENDENCIES_TO_DISABLE, pluginOperationResult.getStatus());
assertEquals(1, pluginOperationResult.getPluginDependencyResult().getDependenciesToDisable().size());
assertEquals(1, pluginOperationResult.getPluginDependencyResult().getDependenciesToDisable().size());
assertTrue(pluginOperationResult.getPluginDependencyResult().getDependenciesToDisable().contains(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
}
use of com.qcadoo.plugin.api.PluginDependencyInformation 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.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginManagmentPerformer method addDependenciesToUrl.
private void addDependenciesToUrl(final StringBuilder url, final Set<PluginDependencyInformation> dependencies) {
if (dependencies != null) {
for (PluginDependencyInformation dependencyInfo : dependencies) {
url.append("&dep_");
url.append(dependencyInfo.getIdentifier());
url.append("=");
if (dependencyInfo.getVersionOfDependency() == null || "0.0.0".equals(dependencyInfo.getVersionOfDependency().toString())) {
url.append("none");
} else {
url.append(dependencyInfo.getVersionOfDependency().toString());
}
}
}
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginManagmentPerformer method createConfirmPageUrl.
private String createConfirmPageUrl(final String statusKey, final String cancelLabel, final String acceptLabel, final String acceptRedirect, final Set<PluginDependencyInformation> dependencies, final List<String> pluginIdentifiers) {
StringBuilder redirectUrl = new StringBuilder(acceptRedirect);
redirectUrl.append(".html?");
for (String pluginIdentifier : pluginIdentifiers) {
if (redirectUrl.charAt(redirectUrl.length() - 1) != '?') {
redirectUrl.append("&");
}
redirectUrl.append("plugin=");
redirectUrl.append(pluginIdentifier);
}
for (PluginDependencyInformation dependency : dependencies) {
redirectUrl.append("&plugin=");
redirectUrl.append(dependency.getIdentifier());
}
StringBuilder url = new StringBuilder("../pluginPages/infoPage.html?type=confirm&status=");
url.append(statusKey);
url.append("&cancelLabel=");
url.append(cancelLabel);
url.append("&acceptLabel=");
url.append(acceptLabel);
url.append("&acceptRedirect=");
try {
url.append(URLEncoder.encode(redirectUrl.toString(), "ISO-8859-1"));
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("Error while generating redirect url", e);
}
addDependenciesToUrl(url, dependencies);
return url.toString();
}
Aggregations