Search in sources :

Example 46 with Plugin

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

the class PluginDependencyManagerTest method shouldReturnEmptyDependencyToEnableWhenNoDependenciesSpecifiedInOnePlugin.

@Test
public void shouldReturnEmptyDependencyToEnableWhenNoDependenciesSpecifiedInOnePlugin() throws Exception {
    // given
    given(plugin1.getRequiredPlugins()).willReturn(Collections.<PluginDependencyInformation>emptySet());
    // when
    PluginDependencyResult result = manager.getDependenciesToEnable(singletonList((Plugin) plugin1), pluginStatusResolver);
    // then
    assertFalse(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) Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) Test(org.junit.Test)

Example 47 with Plugin

use of com.qcadoo.plugin.api.Plugin 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());
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) ArrayList(java.util.ArrayList) 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 48 with Plugin

use of com.qcadoo.plugin.api.Plugin 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());
}
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 49 with Plugin

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

the class PluginDescriptorParserTest method shouldHaveModulesForXml1.

@Test
public void shouldHaveModulesForXml1() throws Exception {
    // given
    // when
    Plugin result = parser.parse(xmlFile1);
    // then
    DefaultPlugin castedResult = (DefaultPlugin) result;
    assertTrue(castedResult.getModules(testModule1Factory).contains(testModule1));
    assertTrue(castedResult.getModules(testModule2Factory).contains(testModule2));
}
Also used : Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) DefaultPlugin(com.qcadoo.plugin.internal.DefaultPlugin) DefaultPlugin(com.qcadoo.plugin.internal.DefaultPlugin) Test(org.junit.Test)

Example 50 with Plugin

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

the class PluginDescriptorParserTest method shouldHavePluginDependenciesInformationsForXml2.

@Test
public void shouldHavePluginDependenciesInformationsForXml2() {
    // given
    // when
    Plugin result = parser.parse(xmlFile2);
    // then
    assertEquals(0, result.getRequiredPlugins().size());
}
Also used : Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) DefaultPlugin(com.qcadoo.plugin.internal.DefaultPlugin) Test(org.junit.Test)

Aggregations

Plugin (com.qcadoo.plugin.api.Plugin)71 InternalPlugin (com.qcadoo.plugin.internal.api.InternalPlugin)59 Test (org.junit.Test)58 PluginDependencyResult (com.qcadoo.plugin.api.PluginDependencyResult)38 PluginDependencyInformation (com.qcadoo.plugin.api.PluginDependencyInformation)28 HashSet (java.util.HashSet)25 ArrayList (java.util.ArrayList)15 QcadooPluginPlugin (com.qcadoo.model.beans.qcadooPlugin.QcadooPluginPlugin)13 DefaultPlugin (com.qcadoo.plugin.internal.DefaultPlugin)11 PluginOperationResult (com.qcadoo.plugin.api.PluginOperationResult)8 Version (com.qcadoo.plugin.api.Version)8 SimplePluginStatusResolver (com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver)8 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)6 InOrder (org.mockito.InOrder)6 ModuleFactory (com.qcadoo.plugin.api.ModuleFactory)5 VersionOfDependency (com.qcadoo.plugin.api.VersionOfDependency)4 Entity (com.qcadoo.model.api.Entity)2 EntityList (com.qcadoo.model.api.EntityList)2 Module (com.qcadoo.plugin.api.Module)2 PluginException (com.qcadoo.plugin.internal.PluginException)2