Search in sources :

Example 1 with PluginDependencyResult

use of com.qcadoo.plugin.api.PluginDependencyResult 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());
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) PluginDependencyInformation(com.qcadoo.plugin.api.PluginDependencyInformation) HashSet(java.util.HashSet) Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) Test(org.junit.Test)

Example 2 with PluginDependencyResult

use of com.qcadoo.plugin.api.PluginDependencyResult in project qcadoo by qcadoo.

the class PluginDependencyManagerTest method shouldReturnEnabledDependenciesForMultiplePlugins.

@Test
public void shouldReturnEnabledDependenciesForMultiplePlugins() throws Exception {
    // given
    given(plugin2.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo1));
    given(plugin2.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);
    List<Plugin> argumentPlugins = new ArrayList<Plugin>();
    argumentPlugins.add(plugin1);
    argumentPlugins.add(plugin2);
    // when
    PluginDependencyResult result = manager.getDependenciesToDisable(argumentPlugins, pluginStatusResolver);
    // then
    assertEquals(0, result.getDependenciesToEnable().size());
    assertEquals(0, result.getUnsatisfiedDependencies().size());
    assertEquals(0, result.getDependenciesToDisable().size());
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) ArrayList(java.util.ArrayList) Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with PluginDependencyResult

use of com.qcadoo.plugin.api.PluginDependencyResult 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")));
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) VersionOfDependency(com.qcadoo.plugin.api.VersionOfDependency) Version(com.qcadoo.plugin.api.Version) PluginDependencyInformation(com.qcadoo.plugin.api.PluginDependencyInformation) Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with PluginDependencyResult

use of com.qcadoo.plugin.api.PluginDependencyResult 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());
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) PluginDependencyInformation(com.qcadoo.plugin.api.PluginDependencyInformation) HashSet(java.util.HashSet) Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) Test(org.junit.Test)

Example 5 with PluginDependencyResult

use of com.qcadoo.plugin.api.PluginDependencyResult in project qcadoo by qcadoo.

the class PluginDependencyManagerTest method shouldReturnEmptyDependencyToDisableWhenNoDependenciesSpecifiedInOnePlugin.

@Test
public void shouldReturnEmptyDependencyToDisableWhenNoDependenciesSpecifiedInOnePlugin() throws Exception {
    // given
    given(plugin1.getRequiredPlugins()).willReturn(Collections.<PluginDependencyInformation>emptySet());
    // when
    PluginDependencyResult result = manager.getDependenciesToDisable(singletonList((Plugin) plugin1), pluginStatusResolver);
    // then
    assertEquals(0, result.getDependenciesToEnable().size());
    assertEquals(0, result.getUnsatisfiedDependencies().size());
    assertEquals(0, result.getDependenciesToDisable().size());
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) Test(org.junit.Test)

Aggregations

PluginDependencyResult (com.qcadoo.plugin.api.PluginDependencyResult)46 Test (org.junit.Test)39 Plugin (com.qcadoo.plugin.api.Plugin)38 InternalPlugin (com.qcadoo.plugin.internal.api.InternalPlugin)36 PluginDependencyInformation (com.qcadoo.plugin.api.PluginDependencyInformation)28 HashSet (java.util.HashSet)23 PluginOperationResult (com.qcadoo.plugin.api.PluginOperationResult)15 SimplePluginStatusResolver (com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver)15 ArrayList (java.util.ArrayList)11 VersionOfDependency (com.qcadoo.plugin.api.VersionOfDependency)7 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)4 QcadooPluginPlugin (com.qcadoo.model.beans.qcadooPlugin.QcadooPluginPlugin)4 InOrder (org.mockito.InOrder)3 Version (com.qcadoo.plugin.api.Version)2 PluginException (com.qcadoo.plugin.internal.PluginException)2 File (java.io.File)1 LinkedList (java.util.LinkedList)1 CycleDetector (org.jgrapht.alg.CycleDetector)1 DefaultDirectedGraph (org.jgrapht.graph.DefaultDirectedGraph)1 DefaultEdge (org.jgrapht.graph.DefaultEdge)1