Search in sources :

Example 16 with PluginOperationResult

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

the class PluginIntegrationTest method shouldEnablePluginWithDependencies.

@Test
public void shouldEnablePluginWithDependencies() throws Exception {
    // given
    pluginManager.disablePlugin("plugin2");
    // when
    PluginOperationResult result = pluginManager.enablePlugin("plugin2");
    // then
    assertTrue(result.isSuccess());
    assertEquals(PluginOperationStatus.SUCCESS, result.getStatus());
}
Also used : PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) Test(org.junit.Test)

Example 17 with PluginOperationResult

use of com.qcadoo.plugin.api.PluginOperationResult 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 18 with PluginOperationResult

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

the class PluginIntegrationTest method shouldNotDisableSystemPlugin.

@Test
public void shouldNotDisableSystemPlugin() throws Exception {
    // given
    pluginManager.enablePlugin("plugin3");
    // when
    PluginOperationResult result = pluginManager.disablePlugin("plugin3");
    // then
    assertFalse(result.isSuccess());
    assertEquals(PluginOperationStatus.SYSTEM_PLUGIN_DISABLING, result.getStatus());
}
Also used : PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) Test(org.junit.Test)

Example 19 with PluginOperationResult

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

the class PluginIntegrationTest method shouldEnablePluginAndDependency.

@Test
public void shouldEnablePluginAndDependency() throws Exception {
    // given
    pluginManager.disablePlugin("plugin1", "plugin2");
    // when
    PluginOperationResult result = pluginManager.enablePlugin("plugin1", "plugin2");
    // then
    assertTrue(result.isSuccess());
    assertEquals(PluginOperationStatus.SUCCESS, result.getStatus());
}
Also used : PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) Test(org.junit.Test)

Example 20 with PluginOperationResult

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

the class PluginManagmentPerformer method performInstall.

public String performInstall(final PluginArtifact artifact) {
    PluginOperationResult result = pluginManagmentConnector.performInstall(artifact);
    String url = null;
    switch(result.getStatus()) {
        case SUCCESS:
            url = createSuccessPageUrl("install.success");
            break;
        case SUCCESS_WITH_RESTART:
            url = createRestartPageUrl(createSuccessPageUrl("install.success"));
            break;
        case SUCCESS_WITH_MISSING_DEPENDENCIES:
            url = createSuccessPageUrl("install.successWithMissingDependencies", result.getPluginDependencyResult().getUnsatisfiedDependencies());
            break;
        case DEPENDENCIES_CYCLES_EXISTS:
            url = createErrorPageUrl("install.cyclingDependency");
            break;
        case CANNOT_UPLOAD_PLUGIN:
            url = createErrorPageUrl("install.cannotUploadPlugin");
            break;
        case CORRUPTED_PLUGIN:
            url = createErrorPageUrl("install.corruptedPlugin");
            break;
        case SYSTEM_PLUGIN_UPDATING:
            url = createErrorPageUrl("install.systemPlugin");
            break;
        case CANNOT_DOWNGRADE_PLUGIN:
            url = createErrorPageUrl("install.incorrectVersion");
            break;
        case CANNOT_INSTALL_PLUGIN_FILE:
            url = createErrorPageUrl("install.cannotInstallPlugin");
            break;
        case DEPENDENCIES_TO_ENABLE:
            url = createErrorPageUrl("install.dependenciesToEnable", result.getPluginDependencyResult().getDependenciesToEnable());
            break;
        case UNSATISFIED_DEPENDENCIES:
            url = createErrorPageUrl("install.unsatisfiedDependencies", result.getPluginDependencyResult().getUnsatisfiedDependencies());
            break;
        case UNSATISFIED_DEPENDENCIES_AFTER_UPDATE:
            url = createErrorPageUrl("install.unsatisfiedDependenciesAfterUpdate", result.getPluginDependencyResult().getDependenciesToDisableUnsatisfiedAfterUpdate());
            break;
        default:
            throw new IllegalStateException(L_WRONG_STATUS);
    }
    return url;
}
Also used : PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult)

Aggregations

PluginOperationResult (com.qcadoo.plugin.api.PluginOperationResult)35 Test (org.junit.Test)31 PluginDependencyResult (com.qcadoo.plugin.api.PluginDependencyResult)15 SimplePluginStatusResolver (com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver)15 InternalPlugin (com.qcadoo.plugin.internal.api.InternalPlugin)9 Plugin (com.qcadoo.plugin.api.Plugin)8 JarPluginArtifact (com.qcadoo.plugin.api.artifact.JarPluginArtifact)7 File (java.io.File)7 PluginDependencyInformation (com.qcadoo.plugin.api.PluginDependencyInformation)4 VersionOfDependency (com.qcadoo.plugin.api.VersionOfDependency)4 Version (com.qcadoo.plugin.api.Version)3 InOrder (org.mockito.InOrder)3