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