}
@Test(dependsOnMethods = { "deletePlugins" })
public void isPluginReadyForPurge() throws Exception {
ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
InventoryManagerLocal inventoryManager = LookupUtil.getInventoryManager();
Plugin plugin = getDeletedPlugin(PLUGIN_1);
if (plugin == null) {
//ok so there's no delete plugin like that. Let's check that there's no installed plugin either
plugin = pluginMgr.getPlugin(PLUGIN_1);
if (plugin != null) {
fail(PLUGIN_1 + "should have been deleted in PluginManagerBeanTest#deletePlugins()");
}
//So there's no such plugin at all. This means that some other test intertwined between this test and
//deletePlugins.
//
//Because tests are configured to clean up after themselves (mainly in the afterClassWork() method)
//it may happen that the plugin we marked for deletion in deletePlugins has actually been deleted
//by the clean up methods.
//
//The point of this test is in that case fulfilled anyway because by the plugin disappearing,
//we proved that at some point in time between deletePlugins and this test it was indeed purgeable.
return;
}
List<ResourceType> resourceTypes = resourceTypeManager.getResourceTypesByPlugin(plugin.getName());
List<ResourceType> deletedTypes = inventoryManager.getDeletedTypes();
boolean resourceTypesPurged = resourceTypes.isEmpty() && deletedTypes.isEmpty();
//ack the plugins as deleted so that the only remaining condition for their
//purge-ability is the disappearance of their resource types.