Search in sources :

Example 1 with Version

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

the class PluginDependencyManagerTest method init.

@Before
public void init() {
    manager = new DefaultPluginDependencyManager();
    manager.setPluginAccessor(pluginAccessor);
    plugin1 = mock(InternalPlugin.class, RETURNS_DEEP_STUBS);
    given(plugin1.getIdentifier()).willReturn("testPlugin1");
    given(plugin1.getVersion()).willReturn(new Version("1.1"));
    given(plugin1.toString()).willReturn("plugin1");
    plugin2 = mock(InternalPlugin.class, RETURNS_DEEP_STUBS);
    given(plugin2.getIdentifier()).willReturn("testPlugin2");
    given(plugin2.getVersion()).willReturn(new Version("1.1"));
    given(plugin2.toString()).willReturn("plugin2");
    plugin3 = mock(InternalPlugin.class, RETURNS_DEEP_STUBS);
    given(plugin3.getIdentifier()).willReturn("testPlugin3");
    given(plugin3.getVersion()).willReturn(new Version("1.1"));
    given(plugin3.toString()).willReturn("plugin3");
    plugin4 = mock(InternalPlugin.class, RETURNS_DEEP_STUBS);
    given(plugin4.getIdentifier()).willReturn("testPlugin4");
    given(plugin4.getVersion()).willReturn(new Version("1.1"));
    given(plugin4.toString()).willReturn("plugin4");
}
Also used : InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) Version(com.qcadoo.plugin.api.Version) Before(org.junit.Before)

Example 2 with Version

use of com.qcadoo.plugin.api.Version 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));
}
Also used : InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) Version(com.qcadoo.plugin.api.Version) 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 3 with Version

use of com.qcadoo.plugin.api.Version 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 Version

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

the class PluginDescriptorParserTest method shouldHaveIdentifierVersionAndSystemForXml1.

@Test
public void shouldHaveIdentifierVersionAndSystemForXml1() {
    // given
    // when
    Plugin result = parser.parse(xmlFile1);
    // then
    assertEquals("testPlugin", result.getIdentifier());
    assertEquals(new Version("1.2.3"), result.getVersion());
    assertTrue(result.isSystemPlugin());
}
Also used : Version(com.qcadoo.plugin.api.Version) Plugin(com.qcadoo.plugin.api.Plugin) InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) DefaultPlugin(com.qcadoo.plugin.internal.DefaultPlugin) Test(org.junit.Test)

Example 5 with Version

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

the class PluginTest method shouldHaveVersion.

@Test
public void shouldHaveVersion() throws Exception {
    // given
    Plugin plugin = DefaultPlugin.Builder.identifier("identifier1", Collections.<ModuleFactory<?>>emptyList()).withVersion("1.2.3").build();
    // then
    assertEquals(new Version("1.2.3"), plugin.getVersion());
}
Also used : Version(com.qcadoo.plugin.api.Version) Plugin(com.qcadoo.plugin.api.Plugin) Test(org.junit.Test)

Aggregations

Version (com.qcadoo.plugin.api.Version)18 Test (org.junit.Test)16 InternalPlugin (com.qcadoo.plugin.internal.api.InternalPlugin)11 Plugin (com.qcadoo.plugin.api.Plugin)8 QcadooPluginPlugin (com.qcadoo.model.beans.qcadooPlugin.QcadooPluginPlugin)5 PluginDependencyInformation (com.qcadoo.plugin.api.PluginDependencyInformation)3 PluginOperationResult (com.qcadoo.plugin.api.PluginOperationResult)3 JarPluginArtifact (com.qcadoo.plugin.api.artifact.JarPluginArtifact)3 File (java.io.File)3 HashSet (java.util.HashSet)3 PluginDependencyResult (com.qcadoo.plugin.api.PluginDependencyResult)2 VersionOfDependency (com.qcadoo.plugin.api.VersionOfDependency)2 DefaultPlugin (com.qcadoo.plugin.internal.DefaultPlugin)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1