use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldCheckDependenciesDependenciesAndReturnMultipleDependenciesForDisable.
@Test
public void shouldCheckDependenciesDependenciesAndReturnMultipleDependenciesForDisable() 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.ENABLED);
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(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 shouldReturnMultipleDisabledDependencyForOnePlugin.
@Test
public void shouldReturnMultipleDisabledDependencyForOnePlugin() throws Exception {
// given
given(plugin1.getState()).willReturn(PluginState.DISABLED);
given(plugin1.getIdentifier()).willReturn("testPlugin1");
given(plugin2.getState()).willReturn(PluginState.TEMPORARY);
given(plugin2.getIdentifier()).willReturn("testPlugin2");
given(plugin3.getState()).willReturn(PluginState.ENABLED);
given(plugin3.getIdentifier()).willReturn("testPlugin3");
given(pluginAccessor.getPlugin("testPlugin1")).willReturn(plugin1);
given(pluginAccessor.getPlugin("testPlugin2")).willReturn(plugin2);
given(pluginAccessor.getPlugin("testPlugin3")).willReturn(plugin3);
InternalPlugin pluginToEnable = mock(InternalPlugin.class);
Set<PluginDependencyInformation> disabledRequiredPlugins = new HashSet<PluginDependencyInformation>();
disabledRequiredPlugins.add(dependencyInfo1);
disabledRequiredPlugins.add(dependencyInfo2);
disabledRequiredPlugins.add(dependencyInfo3);
given(pluginToEnable.getRequiredPlugins()).willReturn(disabledRequiredPlugins);
given(pluginToEnable.getIdentifier()).willReturn("plugin");
// when
PluginDependencyResult result = manager.getDependenciesToEnable(singletonList((Plugin) pluginToEnable), pluginStatusResolver);
// then
assertFalse(result.isCyclic());
assertEquals(2, result.getDependenciesToEnable().size());
assertTrue(result.getDependenciesToEnable().contains(new PluginDependencyInformation("testPlugin1")));
assertTrue(result.getDependenciesToEnable().contains(new PluginDependencyInformation("testPlugin2")));
assertEquals(0, result.getUnsatisfiedDependencies().size());
assertEquals(0, result.getDependenciesToDisable().size());
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldReturnEnabledDependenciesForOnePluginWhenSomeAreSatisfied.
@Test
public void shouldReturnEnabledDependenciesForOnePluginWhenSomeAreSatisfied() throws Exception {
// given
given(plugin2.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo1));
given(plugin2.getState()).willReturn(PluginState.DISABLED);
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.TEMPORARY);
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("testPlugin3")));
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldReturnDisabledDependenciesForMultiplePlugins.
@Test
public void shouldReturnDisabledDependenciesForMultiplePlugins() 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);
given(pluginAccessor.getPlugin("testPlugin4")).willReturn(plugin4);
List<Plugin> plugins = new ArrayList<Plugin>();
plugins.add(plugin1);
plugins.add(plugin2);
// when
PluginDependencyResult result = manager.getDependenciesToEnable(plugins, pluginStatusResolver);
// then
assertFalse(result.isCyclic());
assertEquals(2, result.getDependenciesToEnable().size());
assertTrue(result.getDependenciesToEnable().contains(new PluginDependencyInformation("testPlugin3")));
assertTrue(result.getDependenciesToEnable().contains(new PluginDependencyInformation("testPlugin4")));
assertEquals(0, result.getUnsatisfiedDependencies().size());
assertEquals(0, result.getDependenciesToDisable().size());
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldSetCyclicFlagWhenCyclicDependenciesDependencies.
@Test
public void shouldSetCyclicFlagWhenCyclicDependenciesDependencies() throws Exception {
// given
Set<PluginDependencyInformation> disabledRequiredPlugins1 = new HashSet<PluginDependencyInformation>();
disabledRequiredPlugins1.add(dependencyInfo2);
given(plugin1.getRequiredPlugins()).willReturn(disabledRequiredPlugins1);
Set<PluginDependencyInformation> disabledRequiredPlugins2 = new HashSet<PluginDependencyInformation>();
disabledRequiredPlugins2.add(dependencyInfo3);
given(plugin2.getState()).willReturn(PluginState.DISABLED);
given(plugin2.getRequiredPlugins()).willReturn(disabledRequiredPlugins2);
Set<PluginDependencyInformation> disabledRequiredPlugins3 = new HashSet<PluginDependencyInformation>();
disabledRequiredPlugins3.add(dependencyInfo1);
given(plugin3.getState()).willReturn(PluginState.TEMPORARY);
given(plugin3.getRequiredPlugins()).willReturn(disabledRequiredPlugins3);
given(pluginAccessor.getPlugin("testPlugin1")).willReturn(plugin1);
given(pluginAccessor.getPlugin("testPlugin2")).willReturn(plugin2);
given(pluginAccessor.getPlugin("testPlugin3")).willReturn(plugin3);
given(pluginAccessor.getPlugin("testPlugin4")).willReturn(plugin4);
// when
PluginDependencyResult result = manager.getDependenciesToEnable(singletonList((Plugin) plugin1), pluginStatusResolver);
// then
assertTrue(result.isCyclic());
assertEquals(0, result.getDependenciesToEnable().size());
assertEquals(0, result.getUnsatisfiedDependencies().size());
assertEquals(0, result.getDependenciesToDisable().size());
}
Aggregations