Search in sources :

Example 6 with VersionOfDependency

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

the class PluginManagerTest method shouldNotEnablePluginWithUnsatisfiedDependencies.

@Test
public void shouldNotEnablePluginWithUnsatisfiedDependencies() throws Exception {
    // given
    given(plugin.hasState(PluginState.DISABLED)).willReturn(true);
    PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.unsatisfiedDependencies(Collections.singleton(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
    given(pluginDependencyManager.getDependenciesToEnable(Mockito.eq(singletonList((Plugin) plugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
    // when
    PluginOperationResult pluginOperationResult = pluginManager.enablePlugin("pluginname");
    // then
    verify(plugin, never()).changeStateTo(PluginState.ENABLED);
    verify(pluginDao, never()).save(plugin);
    verify(pluginAccessor, never()).savePlugin(plugin);
    assertFalse(pluginOperationResult.isSuccess());
    assertEquals(PluginOperationStatus.UNSATISFIED_DEPENDENCIES, pluginOperationResult.getStatus());
    assertEquals(1, pluginOperationResult.getPluginDependencyResult().getUnsatisfiedDependencies().size());
    assertEquals(1, pluginOperationResult.getPluginDependencyResult().getUnsatisfiedDependencies().size());
    assertTrue(pluginOperationResult.getPluginDependencyResult().getUnsatisfiedDependencies().contains(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) VersionOfDependency(com.qcadoo.plugin.api.VersionOfDependency) PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) PluginDependencyInformation(com.qcadoo.plugin.api.PluginDependencyInformation) SimplePluginStatusResolver(com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver) Test(org.junit.Test)

Example 7 with VersionOfDependency

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

the class PluginManagerTest method shouldNotDisablePluginWithEnabledDependencies.

@Test
public void shouldNotDisablePluginWithEnabledDependencies() throws Exception {
    // given
    given(plugin.hasState(PluginState.ENABLED)).willReturn(true);
    PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.dependenciesToDisable(Collections.singleton(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
    given(pluginDependencyManager.getDependenciesToDisable(Mockito.eq(singletonList((Plugin) plugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
    // when
    PluginOperationResult pluginOperationResult = pluginManager.disablePlugin("pluginname");
    // then
    verify(plugin, never()).changeStateTo(PluginState.DISABLED);
    verify(pluginDao, never()).save(plugin);
    verify(pluginAccessor, never()).savePlugin(plugin);
    assertFalse(pluginOperationResult.isSuccess());
    assertEquals(PluginOperationStatus.DEPENDENCIES_TO_DISABLE, pluginOperationResult.getStatus());
    assertEquals(1, pluginOperationResult.getPluginDependencyResult().getDependenciesToDisable().size());
    assertEquals(1, pluginOperationResult.getPluginDependencyResult().getDependenciesToDisable().size());
    assertTrue(pluginOperationResult.getPluginDependencyResult().getDependenciesToDisable().contains(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) VersionOfDependency(com.qcadoo.plugin.api.VersionOfDependency) PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) PluginDependencyInformation(com.qcadoo.plugin.api.PluginDependencyInformation) SimplePluginStatusResolver(com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver) Test(org.junit.Test)

Example 8 with VersionOfDependency

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

the class PluginManagerTest method shouldNotUninstallPluginWithEnabledDependencies.

@Test
public void shouldNotUninstallPluginWithEnabledDependencies() throws Exception {
    // given
    PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.dependenciesToUninstall(Collections.singleton(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
    given(pluginDependencyManager.getDependenciesToUninstall(Mockito.eq(singletonList((Plugin) plugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
    given(plugin.getFilename()).willReturn("filename");
    // when
    PluginOperationResult pluginOperationResult = pluginManager.uninstallPlugin("pluginname");
    // then
    verify(plugin, never()).changeStateTo(PluginState.DISABLED);
    verify(pluginDao, never()).delete(plugin);
    verify(pluginAccessor, never()).removePlugin(plugin);
    verify(pluginFileManager, never()).uninstallPlugin("filename");
    assertFalse(pluginOperationResult.isSuccess());
    assertEquals(PluginOperationStatus.DEPENDENCIES_TO_UNINSTALL, pluginOperationResult.getStatus());
    assertEquals(1, pluginOperationResult.getPluginDependencyResult().getDependenciesToUninstall().size());
    assertTrue(pluginOperationResult.getPluginDependencyResult().getDependenciesToUninstall().contains(new PluginDependencyInformation("unknownplugin", new VersionOfDependency(""))));
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) VersionOfDependency(com.qcadoo.plugin.api.VersionOfDependency) PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) PluginDependencyInformation(com.qcadoo.plugin.api.PluginDependencyInformation) SimplePluginStatusResolver(com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver) Test(org.junit.Test)

Example 9 with VersionOfDependency

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

the class PluginManagmentUrlController method convertVersionString.

private String convertVersionString(final String versionStr, final Locale locale) {
    StringBuilder result = new StringBuilder();
    result.append(translationService.translate("qcadooPlugins.pluginInfo.inVersion", locale));
    result.append(" ");
    VersionOfDependency version = new VersionOfDependency(versionStr);
    if (version.getMinVersion() != null) {
        result.append(translationService.translate("qcadooPlugins.pluginInfo.versionFrom", locale));
        result.append(" ");
        result.append(version.getMinVersion());
    }
    if (version.getMinVersion() != null && version.getMaxVersion() != null) {
        result.append(" ");
        result.append(translationService.translate("qcadooPlugins.pluginInfo.versionAnd", locale));
        result.append(" ");
    }
    if (version.getMaxVersion() != null) {
        result.append(translationService.translate("qcadooPlugins.pluginInfo.versionTo", locale));
        result.append(" ");
        result.append(version.getMaxVersion());
    }
    return result.toString();
}
Also used : VersionOfDependency(com.qcadoo.plugin.api.VersionOfDependency)

Example 10 with VersionOfDependency

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

the class PluginDependencyInformationTest method shouldThrowExceptionWhenWrongVersions.

@Test
public void shouldThrowExceptionWhenWrongVersions() throws Exception {
    // when
    try {
        new PluginDependencyInformation("", new VersionOfDependency("[a1,1)"));
        Assert.fail();
    } catch (Exception e) {
        LOG.info("empty catch");
    }
    try {
        new PluginDependencyInformation("", new VersionOfDependency("[1,2s)"));
        Assert.fail();
    } catch (Exception e) {
        LOG.info("empty catch");
    }
    try {
        new PluginDependencyInformation("", new VersionOfDependency("[1.2.3.4,2s)"));
        Assert.fail();
    } catch (Exception e) {
        LOG.info("empty catch");
    }
    try {
        new PluginDependencyInformation("", new VersionOfDependency("[2,1.2.3.4)"));
        Assert.fail();
    } catch (Exception e) {
        LOG.info("empty catch");
    }
    try {
        new PluginDependencyInformation("", new VersionOfDependency("[1.1.1,1.1.0)"));
        Assert.fail();
    } catch (Exception e) {
        LOG.info("empty catch");
    }
    try {
        new PluginDependencyInformation("", new VersionOfDependency("(1.0.0,1]"));
        Assert.fail();
    } catch (Exception e) {
        LOG.info("empty catch");
    }
// then
}
Also used : VersionOfDependency(com.qcadoo.plugin.api.VersionOfDependency) PluginDependencyInformation(com.qcadoo.plugin.api.PluginDependencyInformation) Test(org.junit.Test)

Aggregations

VersionOfDependency (com.qcadoo.plugin.api.VersionOfDependency)11 PluginDependencyInformation (com.qcadoo.plugin.api.PluginDependencyInformation)10 Test (org.junit.Test)9 PluginDependencyResult (com.qcadoo.plugin.api.PluginDependencyResult)7 Plugin (com.qcadoo.plugin.api.Plugin)4 PluginOperationResult (com.qcadoo.plugin.api.PluginOperationResult)4 InternalPlugin (com.qcadoo.plugin.internal.api.InternalPlugin)4 SimplePluginStatusResolver (com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver)4 HashSet (java.util.HashSet)3 Version (com.qcadoo.plugin.api.Version)2 DefaultPlugin (com.qcadoo.plugin.internal.DefaultPlugin)1 Before (org.junit.Before)1