Search in sources :

Example 11 with Version

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

the class PluginIntegrationTest method shouldNotDowngradePlugin.

@Test
public void shouldNotDowngradePlugin() throws Exception {
    // given
    JarPluginArtifact artifact = new JarPluginArtifact(new File("src/test/resources/com/qcadoo/plugin/integration/plugin4.jar"));
    JarPluginArtifact artifact2 = new JarPluginArtifact(new File("src/test/resources/com/qcadoo/plugin/integration/plugin4.1.jar"));
    pluginManager.installPlugin(artifact2);
    // when
    PluginOperationResult result = pluginManager.installPlugin(artifact);
    // then
    assertFalse(result.isSuccess());
    assertEquals(PluginOperationStatus.CANNOT_DOWNGRADE_PLUGIN, result.getStatus());
    assertNotNull(pluginAccessor.getPlugin("plugin4"));
    assertTrue(pluginAccessor.getPlugin("plugin4").hasState(PluginState.TEMPORARY));
    assertEquals(new Version("1.2.4"), pluginAccessor.getPlugin("plugin4").getVersion());
}
Also used : JarPluginArtifact(com.qcadoo.plugin.api.artifact.JarPluginArtifact) Version(com.qcadoo.plugin.api.Version) PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) File(java.io.File) Test(org.junit.Test)

Example 12 with Version

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

the class PluginDependencyManagerTest method shouldReturnValidListToDisableAndDisabeUnsatisfiedWhenUpdate.

@Test
public void shouldReturnValidListToDisableAndDisabeUnsatisfiedWhenUpdate() 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.ENABLED);
    given(plugin3.getRequiredPlugins()).willReturn(Collections.singleton(dependencyInfo2));
    given(plugin3.getState()).willReturn(PluginState.ENABLED);
    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(2, result.getDependenciesToDisable().size());
    assertEquals(1, result.getDependenciesToDisableUnsatisfiedAfterUpdate().size());
    assertEquals(0, result.getDependenciesToUninstall().size());
    assertTrue(result.getDependenciesToDisable().contains(new PluginDependencyInformation("testPlugin2")));
    assertTrue(result.getDependenciesToDisable().contains(new PluginDependencyInformation("testPlugin3")));
    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 13 with Version

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

the class PluginDescriptorParserTest method shouldHaveIdentifierVersionAndSystemForXml2.

@Test
public void shouldHaveIdentifierVersionAndSystemForXml2() {
    // given
    // when
    Plugin result = parser.parse(xmlFile2);
    // then
    assertEquals("testPlugin2", result.getIdentifier());
    assertEquals(new Version("2.3.1"), result.getVersion());
    assertFalse(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 14 with Version

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

the class PluginAccessorTest method shouldFailOnPluginDowngrade.

@Test(expected = IllegalStateException.class)
public void shouldFailOnPluginDowngrade() throws Exception {
    // given
    InternalPlugin plugin11 = mock(InternalPlugin.class);
    given(plugin11.getIdentifier()).willReturn("identifier11");
    QcadooPluginPlugin pluginsPlugin12 = mock(QcadooPluginPlugin.class);
    given(pluginsPlugin12.getIdentifier()).willReturn("identifier11");
    given(pluginsPlugin12.getVersion()).willReturn("0.0.0");
    given(pluginsPlugin12.getState()).willReturn("ENABLED");
    given(plugin11.compareVersion(new Version(pluginsPlugin12.getVersion()))).willReturn(-1);
    Set<InternalPlugin> pluginsFromDescriptor = Sets.newHashSet(plugin11);
    Set<QcadooPluginPlugin> pluginsFromDatabase = Sets.newHashSet(pluginsPlugin12);
    given(pluginDescriptorParser.loadPlugins()).willReturn(pluginsFromDescriptor);
    given(pluginDao.list()).willReturn(pluginsFromDatabase);
    // when
    pluginAccessor.init();
}
Also used : InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) QcadooPluginPlugin(com.qcadoo.model.beans.qcadooPlugin.QcadooPluginPlugin) Version(com.qcadoo.plugin.api.Version) Test(org.junit.Test)

Example 15 with Version

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

the class PluginDaoTest method shouldSaveNotPersistentPlugin.

@Test
public void shouldSaveNotPersistentPlugin() throws Exception {
    // given
    given(plugin11.getState()).willReturn(PluginState.ENABLED);
    given(plugin11.getVersion()).willReturn(new Version("0.0.0"));
    // when
    pluginDao.save(plugin11);
    // then
    verify(session, never()).save(plugin1);
    verify(session).save(any(QcadooPluginPlugin.class));
}
Also used : QcadooPluginPlugin(com.qcadoo.model.beans.qcadooPlugin.QcadooPluginPlugin) Version(com.qcadoo.plugin.api.Version) 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