use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldCheckDependenciesDependenciesAndReturnMultipleDependenciesForDisableWhenSomePluginDisabled.
@Test
public void shouldCheckDependenciesDependenciesAndReturnMultipleDependenciesForDisableWhenSomePluginDisabled() throws Exception {
// given
given(plugin2.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo1));
given(plugin2.getState()).willReturn(PluginState.ENABLED);
given(plugin3.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo2));
given(plugin3.getState()).willReturn(PluginState.DISABLED);
given(plugin4.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo3));
given(plugin4.getState()).willReturn(PluginState.ENABLED);
Set<Plugin> plugins = new HashSet<Plugin>();
plugins.add(plugin1);
plugins.add(plugin2);
plugins.add(plugin3);
plugins.add(plugin4);
given(pluginAccessor.getPlugins()).willReturn(plugins);
// when
PluginDependencyResult result = manager.getDependenciesToDisable(singletonList((Plugin) plugin1), pluginStatusResolver);
// then
assertEquals(0, result.getDependenciesToEnable().size());
assertEquals(0, result.getUnsatisfiedDependencies().size());
assertEquals(1, result.getDependenciesToDisable().size());
assertTrue(result.getDependenciesToDisable().contains(new PluginDependencyInformation("testPlugin2")));
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldReturnMultipleEnabledDependencyForOnePlugin.
@Test
public void shouldReturnMultipleEnabledDependencyForOnePlugin() throws Exception {
// given
given(plugin2.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo1));
given(plugin2.getState()).willReturn(PluginState.ENABLED);
given(plugin3.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo1));
given(plugin3.getState()).willReturn(PluginState.ENABLED);
given(plugin4.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo1));
given(plugin4.getState()).willReturn(PluginState.ENABLED);
Set<Plugin> plugins = new HashSet<Plugin>();
plugins.add(plugin1);
plugins.add(plugin2);
plugins.add(plugin3);
plugins.add(plugin4);
given(pluginAccessor.getPlugins()).willReturn(plugins);
// when
PluginDependencyResult result = manager.getDependenciesToDisable(singletonList((Plugin) plugin1), pluginStatusResolver);
// then
assertEquals(0, result.getDependenciesToEnable().size());
assertEquals(0, result.getUnsatisfiedDependencies().size());
assertEquals(3, result.getDependenciesToDisable().size());
assertTrue(result.getDependenciesToDisable().contains(new PluginDependencyInformation("testPlugin2")));
assertTrue(result.getDependenciesToDisable().contains(new PluginDependencyInformation("testPlugin3")));
assertTrue(result.getDependenciesToDisable().contains(new PluginDependencyInformation("testPlugin4")));
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldReturnValidListToDisableAndDisabeUnsatisfiedWhenUpdate.
@Test
public void shouldReturnValidListToDisableAndDisabeUnsatisfiedWhenUpdate() throws Exception {
// given
Set<Plugin> plugins = new HashSet<Plugin>();
plugins.add(plugin1);
plugins.add(plugin2);
plugins.add(plugin3);
plugins.add(plugin4);
given(pluginAccessor.getPlugins()).willReturn(plugins);
PluginDependencyInformation dependency = new PluginDependencyInformation("testPlugin1", new VersionOfDependency("[1.0.0,2.0.0]"));
given(plugin2.getRequiredPlugins()).willReturn(Collections.singleton(dependency));
given(plugin2.getState()).willReturn(PluginState.ENABLED);
given(plugin3.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo2));
given(plugin3.getState()).willReturn(PluginState.ENABLED);
given(plugin1.getVersion()).willReturn(new Version("1.1.0"));
given(plugin4.getVersion()).willReturn(new Version("2.1.0"));
// when
PluginDependencyResult result = manager.getDependenciesToUpdate(plugin1, plugin4, pluginStatusResolver);
// then
assertEquals(0, result.getDependenciesToEnable().size());
assertEquals(0, result.getUnsatisfiedDependencies().size());
assertEquals(2, result.getDependenciesToDisable().size());
assertEquals(1, result.getDependenciesToDisableUnsatisfiedAfterUpdate().size());
assertEquals(0, result.getDependenciesToUninstall().size());
assertTrue(result.getDependenciesToDisable().contains(new PluginDependencyInformation("testPlugin2")));
assertTrue(result.getDependenciesToDisable().contains(new PluginDependencyInformation("testPlugin3")));
assertTrue(result.getDependenciesToDisableUnsatisfiedAfterUpdate().contains(new PluginDependencyInformation("testPlugin2")));
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldReturnUnsatisfiedDependenciesForMultiplePlugins.
@Test
public void shouldReturnUnsatisfiedDependenciesForMultiplePlugins() throws Exception {
// given
Set<PluginDependencyInformation> disabledRequiredPlugins = new HashSet<PluginDependencyInformation>();
disabledRequiredPlugins.add(dependencyInfo2);
disabledRequiredPlugins.add(dependencyInfo4);
given(plugin1.getRequiredPlugins()).willReturn(disabledRequiredPlugins);
Set<PluginDependencyInformation> disabledRequiredPlugins2 = new HashSet<PluginDependencyInformation>();
disabledRequiredPlugins2.add(dependencyInfo3);
given(plugin2.getRequiredPlugins()).willReturn(disabledRequiredPlugins2);
given(plugin3.getState()).willReturn(PluginState.TEMPORARY);
given(plugin4.getState()).willReturn(PluginState.TEMPORARY);
given(pluginAccessor.getPlugin("testPlugin3")).willReturn(plugin3);
List<Plugin> plugins = new ArrayList<Plugin>();
plugins.add(plugin1);
plugins.add(plugin2);
// when
PluginDependencyResult result = manager.getDependenciesToEnable(plugins, pluginStatusResolver);
// then
assertFalse(result.isCyclic());
assertEquals(0, result.getDependenciesToEnable().size());
assertEquals(1, result.getUnsatisfiedDependencies().size());
assertTrue(result.getUnsatisfiedDependencies().contains(new PluginDependencyInformation("testPlugin4")));
assertEquals(0, result.getDependenciesToDisable().size());
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldCheckDependenciesDependenciesAndReturnMultipleDependenciesForUninstallWhenMultiplePlugins.
@Test
public void shouldCheckDependenciesDependenciesAndReturnMultipleDependenciesForUninstallWhenMultiplePlugins() throws Exception {
// given
given(plugin2.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo1));
given(plugin2.getState()).willReturn(PluginState.DISABLED);
given(plugin3.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo2));
given(plugin3.getState()).willReturn(PluginState.ENABLED);
given(plugin4.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo3));
given(plugin4.getState()).willReturn(PluginState.DISABLED);
Set<Plugin> plugins = new HashSet<Plugin>();
plugins.add(plugin1);
plugins.add(plugin2);
plugins.add(plugin3);
plugins.add(plugin4);
given(pluginAccessor.getPlugins()).willReturn(plugins);
List<Plugin> argumentPlugins = new ArrayList<Plugin>();
argumentPlugins.add(plugin1);
argumentPlugins.add(plugin3);
// when
PluginDependencyResult result = manager.getDependenciesToUninstall(argumentPlugins, pluginStatusResolver);
// then
assertEquals(0, result.getDependenciesToEnable().size());
assertEquals(0, result.getUnsatisfiedDependencies().size());
assertEquals(0, result.getDependenciesToDisable().size());
assertEquals(2, result.getDependenciesToUninstall().size());
assertTrue(result.getDependenciesToUninstall().contains(new PluginDependencyInformation("testPlugin2")));
assertTrue(result.getDependenciesToUninstall().contains(new PluginDependencyInformation("testPlugin4")));
}
Aggregations