Search in sources :

Example 56 with Plugin

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

the class PluginManagmentUrlController method addGroupsToPlugins.

private Map<String, String> addGroupsToPlugins(Map<String, String> dependencies) {
    Map<String, String> newDependencies = new HashMap<>();
    Iterator<Map.Entry<String, String>> it = dependencies.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, String> entry = it.next();
        Plugin plugin = pluginAccessor.getPlugin(entry.getKey());
        String key = plugin.getPluginInformation().getGroup() + "." + plugin.getIdentifier();
        newDependencies.put(key, entry.getValue());
    }
    return newDependencies;
}
Also used : Plugin(com.qcadoo.plugin.api.Plugin)

Example 57 with Plugin

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

the class PluginTest method shouldHaveInformation.

@Test
public void shouldHaveInformation() throws Exception {
    // given
    Plugin plugin = DefaultPlugin.Builder.identifier("identifier1", Collections.<ModuleFactory<?>>emptyList()).withDescription("description").withName("name").withVendor("vendor").withVendorUrl("vendorUrl").build();
    // then
    assertEquals("description", plugin.getPluginInformation().getDescription());
    assertEquals("name", plugin.getPluginInformation().getName());
    assertEquals("vendor", plugin.getPluginInformation().getVendor());
    assertEquals("vendorUrl", plugin.getPluginInformation().getVendorUrl());
}
Also used : ModuleFactory(com.qcadoo.plugin.api.ModuleFactory) Plugin(com.qcadoo.plugin.api.Plugin) Test(org.junit.Test)

Example 58 with Plugin

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

the class PluginTest method shouldHaveUnknownStateByDefault.

@Test
public void shouldHaveUnknownStateByDefault() throws Exception {
    // given
    Plugin plugin = DefaultPlugin.Builder.identifier("identifier", Collections.<ModuleFactory<?>>emptyList()).build();
    // then
    assertTrue(plugin.hasState(PluginState.UNKNOWN));
    assertEquals(PluginState.UNKNOWN, plugin.getState());
}
Also used : ModuleFactory(com.qcadoo.plugin.api.ModuleFactory) Plugin(com.qcadoo.plugin.api.Plugin) Test(org.junit.Test)

Example 59 with Plugin

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

the class PluginTest method shouldCompareVersions.

@Test
public void shouldCompareVersions() throws Exception {
    // given
    Plugin plugin1 = DefaultPlugin.Builder.identifier("identifier", Collections.<ModuleFactory<?>>emptyList()).withVersion("2.3.4").build();
    Plugin plugin2 = DefaultPlugin.Builder.identifier("identifier", Collections.<ModuleFactory<?>>emptyList()).withVersion("2.3.4").build();
    Plugin plugin3 = DefaultPlugin.Builder.identifier("identifier", Collections.<ModuleFactory<?>>emptyList()).withVersion("2.3.5").build();
    Plugin plugin4 = DefaultPlugin.Builder.identifier("identifier", Collections.<ModuleFactory<?>>emptyList()).withVersion("2.4.4").build();
    Plugin plugin5 = DefaultPlugin.Builder.identifier("identifier", Collections.<ModuleFactory<?>>emptyList()).withVersion("3.3.4").build();
    // then
    assertEquals(0, plugin1.compareVersion(plugin2.getVersion()));
    assertEquals(0, plugin2.compareVersion(plugin1.getVersion()));
    assertEquals(-1, plugin1.compareVersion(plugin3.getVersion()));
    assertEquals(-1, plugin1.compareVersion(plugin4.getVersion()));
    assertEquals(-1, plugin1.compareVersion(plugin5.getVersion()));
    assertEquals(-1, plugin3.compareVersion(plugin4.getVersion()));
    assertEquals(-1, plugin3.compareVersion(plugin5.getVersion()));
    assertEquals(-1, plugin4.compareVersion(plugin5.getVersion()));
    assertEquals(1, plugin5.compareVersion(plugin1.getVersion()));
    assertEquals(1, plugin5.compareVersion(plugin3.getVersion()));
    assertEquals(1, plugin5.compareVersion(plugin4.getVersion()));
    assertEquals(1, plugin4.compareVersion(plugin1.getVersion()));
    assertEquals(1, plugin4.compareVersion(plugin3.getVersion()));
    assertEquals(1, plugin3.compareVersion(plugin1.getVersion()));
}
Also used : Plugin(com.qcadoo.plugin.api.Plugin) Test(org.junit.Test)

Example 60 with Plugin

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

the class PluginTest method shouldHaveSystemFlag.

@Test
public void shouldHaveSystemFlag() throws Exception {
    // given
    Plugin plugin1 = DefaultPlugin.Builder.identifier("identifier1", Collections.<ModuleFactory<?>>emptyList()).asSystem().build();
    Plugin plugin2 = DefaultPlugin.Builder.identifier("identifier1", Collections.<ModuleFactory<?>>emptyList()).build();
    // then
    assertTrue(plugin1.isSystemPlugin());
    assertFalse(plugin2.isSystemPlugin());
}
Also used : ModuleFactory(com.qcadoo.plugin.api.ModuleFactory) Plugin(com.qcadoo.plugin.api.Plugin) 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