use of com.qcadoo.plugin.api.Plugin in project qcadoo by qcadoo.
the class PluginDescriptorParserTest method shouldHavePluginInformationsForXml1.
@Test
public void shouldHavePluginInformationsForXml1() {
// given
// when
Plugin result = parser.parse(xmlFile1);
// then
assertEquals("testPluginName", result.getPluginInformation().getName());
assertEquals("testPluginDescription", result.getPluginInformation().getDescription());
assertEquals("testPluginVendorName", result.getPluginInformation().getVendor());
assertEquals("testPluginVendorUrl", result.getPluginInformation().getVendorUrl());
}
use of com.qcadoo.plugin.api.Plugin in project qcadoo by qcadoo.
the class PluginDescriptorParserTest method shouldParseAllPlugins.
@Test
public void shouldParseAllPlugins() throws Exception {
// given
Resource[] testXmlsList = new Resource[] { xmlFile1, xmlFile2 };
given(pluginDescriptorResolver.getDescriptors()).willReturn(testXmlsList);
Plugin p1 = parser.parse(xmlFile1);
Plugin p2 = parser.parse(xmlFile2);
// when
Set<InternalPlugin> result = parser.loadPlugins();
// then
assertEquals(2, result.size());
assertTrue(result.contains(p1));
assertTrue(result.contains(p2));
}
use of com.qcadoo.plugin.api.Plugin in project qcadoo by qcadoo.
the class PluginManagerTest method shouldUninstallNotTemporaryPlugin.
@Test
public void shouldUninstallNotTemporaryPlugin() throws Exception {
// given
given(plugin.hasState(PluginState.TEMPORARY)).willReturn(false);
given(plugin.hasState(PluginState.ENABLED)).willReturn(true);
PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.satisfiedDependencies();
given(pluginDependencyManager.getDependenciesToUninstall(Mockito.eq(singletonList((Plugin) plugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
given(pluginDependencyManager.sortPluginsInDependencyOrder(singletonList((Plugin) plugin))).willReturn(singletonList((Plugin) plugin));
given(plugin.getFilename()).willReturn("filename");
// when
PluginOperationResult pluginOperationResult = pluginManager.uninstallPlugin("pluginname");
// then
verify(plugin).changeStateTo(PluginState.DISABLED);
verify(pluginDao).delete(plugin);
verify(pluginAccessor).removePlugin(plugin);
verify(pluginFileManager).uninstallPlugin("filename");
assertTrue(pluginOperationResult.isSuccess());
assertEquals(PluginOperationStatus.SUCCESS_WITH_RESTART, pluginOperationResult.getStatus());
assertEquals(0, pluginOperationResult.getPluginDependencyResult().getDependenciesToUninstall().size());
}
use of com.qcadoo.plugin.api.Plugin in project qcadoo by qcadoo.
the class PluginManagerTest method shouldEnableUninstalledPlugin.
@Test
public void shouldEnableUninstalledPlugin() throws Exception {
// given
given(anotherPlugin.hasState(PluginState.TEMPORARY)).willReturn(true);
given(anotherPlugin.getFilename()).willReturn("filename");
given(pluginFileManager.installPlugin("filename")).willReturn(true);
PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.satisfiedDependencies();
given(pluginDependencyManager.getDependenciesToEnable(Mockito.eq(singletonList((Plugin) anotherPlugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
given(pluginDependencyManager.sortPluginsInDependencyOrder(singletonList((Plugin) anotherPlugin))).willReturn(singletonList((Plugin) anotherPlugin));
// when
PluginOperationResult pluginOperationResult = pluginManager.enablePlugin("anotherPluginname");
// then
verify(anotherPlugin).changeStateTo(PluginState.ENABLING);
verify(pluginDao).save(anotherPlugin);
verify(pluginAccessor).savePlugin(anotherPlugin);
assertTrue(pluginOperationResult.isSuccess());
assertEquals(PluginOperationStatus.SUCCESS_WITH_RESTART, pluginOperationResult.getStatus());
assertEquals(0, pluginOperationResult.getPluginDependencyResult().getDependenciesToEnable().size());
assertEquals(0, pluginOperationResult.getPluginDependencyResult().getUnsatisfiedDependencies().size());
}
use of com.qcadoo.plugin.api.Plugin in project qcadoo by qcadoo.
the class PluginManagerTest method shouldEnableMultiplePlugins.
@Test
public void shouldEnableMultiplePlugins() throws Exception {
// given
given(plugin.hasState(PluginState.DISABLED)).willReturn(true);
InternalPlugin nextPlugin = mock(InternalPlugin.class, "nextPlugin");
given(nextPlugin.hasState(PluginState.DISABLED)).willReturn(true);
given(pluginAccessor.getPlugin("nextPluginname")).willReturn(nextPlugin);
given(anotherPlugin.hasState(PluginState.TEMPORARY)).willReturn(true);
given(anotherPlugin.getFilename()).willReturn("filename");
given(pluginFileManager.installPlugin("filename")).willReturn(true);
PluginDependencyResult pluginDependencyResult = PluginDependencyResultImpl.satisfiedDependencies();
given(pluginDependencyManager.getDependenciesToEnable(Mockito.eq(newArrayList((Plugin) plugin, (Plugin) anotherPlugin, (Plugin) nextPlugin)), Mockito.any(SimplePluginStatusResolver.class))).willReturn(pluginDependencyResult);
given(pluginDependencyManager.sortPluginsInDependencyOrder(newArrayList((Plugin) plugin, (Plugin) anotherPlugin, (Plugin) nextPlugin))).willReturn(newArrayList((Plugin) plugin, (Plugin) anotherPlugin, (Plugin) nextPlugin));
// when
PluginOperationResult pluginOperationResult = pluginManager.enablePlugin("pluginname", "anotherPluginname", "nextPluginname");
// then
InOrder inOrder = inOrder(plugin, anotherPlugin, nextPlugin);
inOrder.verify(plugin).changeStateTo(PluginState.ENABLED);
inOrder.verify(anotherPlugin).changeStateTo(PluginState.ENABLING);
inOrder.verify(nextPlugin).changeStateTo(PluginState.ENABLED);
verify(pluginDao).save(plugin);
verify(pluginAccessor).savePlugin(plugin);
verify(pluginDao).save(nextPlugin);
verify(pluginAccessor).savePlugin(nextPlugin);
verify(pluginDao).save(anotherPlugin);
verify(pluginAccessor).savePlugin(anotherPlugin);
assertTrue(pluginOperationResult.isSuccess());
assertEquals(PluginOperationStatus.SUCCESS_WITH_RESTART, pluginOperationResult.getStatus());
assertEquals(0, pluginOperationResult.getPluginDependencyResult().getDependenciesToEnable().size());
assertEquals(0, pluginOperationResult.getPluginDependencyResult().getUnsatisfiedDependencies().size());
}
Aggregations