use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldSetCyclicFlagWhenCyclicDependenciesDependenciesButNotDependencyToArgument.
//
@Test
public void shouldSetCyclicFlagWhenCyclicDependenciesDependenciesButNotDependencyToArgument() 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(dependencyInfo2);
given(plugin3.getState()).willReturn(PluginState.TEMPORARY);
given(plugin3.getRequiredPlugins()).willReturn(disabledRequiredPlugins3);
given(pluginAccessor.getPlugin("testPlugin2")).willReturn(plugin2);
given(pluginAccessor.getPlugin("testPlugin3")).willReturn(plugin3);
// 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());
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldSortPluginsWithMissingDependencies.
@Test
public void shouldSortPluginsWithMissingDependencies() {
// given
Set<PluginDependencyInformation> rp1 = new HashSet<PluginDependencyInformation>();
rp1.add(new PluginDependencyInformation("p2"));
Set<PluginDependencyInformation> rp2 = new HashSet<PluginDependencyInformation>();
rp2.add(new PluginDependencyInformation("p3"));
Set<PluginDependencyInformation> rp3 = new HashSet<PluginDependencyInformation>();
Set<PluginDependencyInformation> rp4 = new HashSet<PluginDependencyInformation>();
rp4.add(new PluginDependencyInformation("p2"));
rp4.add(new PluginDependencyInformation("p3"));
Set<PluginDependencyInformation> rp5 = new HashSet<PluginDependencyInformation>();
rp5.add(new PluginDependencyInformation("p1"));
rp5.add(new PluginDependencyInformation("p3"));
InternalPlugin p1 = mock(InternalPlugin.class, "p1");
given(p1.getIdentifier()).willReturn("p1");
given(p1.getVersion()).willReturn(new Version("1.1"));
given(p1.getRequiredPlugins()).willReturn(rp1);
InternalPlugin p2 = mock(InternalPlugin.class, "p2");
given(p2.getIdentifier()).willReturn("p2");
given(p2.getVersion()).willReturn(new Version("1.1"));
given(p2.getRequiredPlugins()).willReturn(rp2);
InternalPlugin p3 = mock(InternalPlugin.class, "p3");
given(p3.getIdentifier()).willReturn("p3");
given(p3.getVersion()).willReturn(new Version("1.1"));
given(p3.getRequiredPlugins()).willReturn(rp3);
InternalPlugin p4 = mock(InternalPlugin.class, "p4");
given(p4.getIdentifier()).willReturn("p4");
given(p4.getVersion()).willReturn(new Version("1.1"));
given(p4.getRequiredPlugins()).willReturn(rp4);
InternalPlugin p5 = mock(InternalPlugin.class, "p5");
given(p5.getIdentifier()).willReturn("p5");
given(p5.getVersion()).willReturn(new Version("1.1"));
given(p5.getRequiredPlugins()).willReturn(rp5);
given(pluginAccessor.getPlugin("p1")).willReturn(p1);
given(pluginAccessor.getPlugin("p2")).willReturn(p2);
given(pluginAccessor.getPlugin("p3")).willReturn(p3);
given(pluginAccessor.getPlugin("p4")).willReturn(p4);
given(pluginAccessor.getPlugin("p5")).willReturn(p5);
List<Plugin> argumentPlugins = new ArrayList<Plugin>();
argumentPlugins.add(p1);
argumentPlugins.add(p2);
argumentPlugins.add(p4);
argumentPlugins.add(p5);
// when
List<Plugin> sortedPlugins = manager.sortPluginsInDependencyOrder(argumentPlugins);
// then
assertEquals(4, sortedPlugins.size());
assertEquals(p2, sortedPlugins.get(0));
assertEquals(p4, sortedPlugins.get(1));
assertEquals(p1, sortedPlugins.get(2));
assertEquals(p5, sortedPlugins.get(3));
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldReturnValidListToDisableAndDisabeUnsatisfiedWhenUpdateAndDependentPluginIsDisabled.
@Test
public void shouldReturnValidListToDisableAndDisabeUnsatisfiedWhenUpdateAndDependentPluginIsDisabled() 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.DISABLED);
given(plugin3.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo2));
given(plugin3.getState()).willReturn(PluginState.DISABLED);
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(0, result.getDependenciesToDisable().size());
assertEquals(1, result.getDependenciesToDisableUnsatisfiedAfterUpdate().size());
assertEquals(0, result.getDependenciesToUninstall().size());
assertTrue(result.getDependenciesToDisableUnsatisfiedAfterUpdate().contains(new PluginDependencyInformation("testPlugin2")));
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldSetCyclicFlagWhenCyclicDependenciesDependenciesToArgumentsDependency.
@Test
public void shouldSetCyclicFlagWhenCyclicDependenciesDependenciesToArgumentsDependency() 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(dependencyInfo4);
given(plugin3.getState()).willReturn(PluginState.TEMPORARY);
given(plugin3.getRequiredPlugins()).willReturn(disabledRequiredPlugins3);
Set<PluginDependencyInformation> disabledRequiredPlugins4 = new HashSet<PluginDependencyInformation>();
disabledRequiredPlugins4.add(dependencyInfo2);
given(plugin4.getState()).willReturn(PluginState.TEMPORARY);
given(plugin4.getRequiredPlugins()).willReturn(disabledRequiredPlugins4);
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());
}
use of com.qcadoo.plugin.api.PluginDependencyInformation in project qcadoo by qcadoo.
the class PluginDependencyManagerTest method shouldReturnValidListToDisableWhenUpdate.
@Test
public void shouldReturnValidListToDisableWhenUpdate() 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);
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);
// when
PluginDependencyResult result = manager.getDependenciesToUpdate(plugin1, plugin4, pluginStatusResolver);
// then
assertEquals(0, result.getDependenciesToEnable().size());
assertEquals(0, result.getUnsatisfiedDependencies().size());
assertEquals(1, result.getDependenciesToDisable().size());
assertEquals(0, result.getDependenciesToDisableUnsatisfiedAfterUpdate().size());
assertEquals(0, result.getDependenciesToUninstall().size());
assertTrue(result.getDependenciesToDisable().contains(new PluginDependencyInformation("testPlugin2")));
}
Aggregations