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());
}
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")));
}
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());
}
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();
}
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));
}
Aggregations