// lifted from ResourceManagerBeanTest, with the addition of adding bundle config to the type
private ResourceGroup createTestResourceGroup() throws Exception {
getTransactionManager().begin();
ResourceGroup resourceGroup = null;
Resource resource;
try {
// Naming this with TEST_PREFIX allows cleanupDatabase to blow away these test resources along
// with the bundle resource type
ResourceType resourceType = new ResourceType(TEST_PREFIX + "-platform-" + System.currentTimeMillis(),
"test", ResourceCategory.PLATFORM, null);
// we need to make this test type bundle targetable
ConfigurationDefinition pcDef = new ConfigurationDefinition(TEST_PREFIX + "-testdef", "bundle test");
PropertyDefinitionSimple propDef = new PropertyDefinitionSimple(TEST_BUNDLE_DESTBASEDIR_PROP, "", true,
PropertySimpleType.STRING);
propDef.setDisplayName(TEST_BUNDLE_DESTBASEDIR_PROP);
pcDef.put(propDef);
em.persist(pcDef);
ResourceTypeBundleConfiguration rtbc = new ResourceTypeBundleConfiguration(new Configuration());
rtbc.addBundleDestinationBaseDirectory(TEST_DESTBASEDIR_NAME,
ResourceTypeBundleConfiguration.BundleDestinationBaseDirectory.Context.pluginConfiguration.name(),
TEST_BUNDLE_DESTBASEDIR_PROP, null);
resourceType.setResourceTypeBundleConfiguration(rtbc);
resourceType.setPluginConfigurationDefinition(pcDef);
em.persist(resourceType);
// make sure the bundle config is ok
rtbc = resourceType.getResourceTypeBundleConfiguration();
assert rtbc != null;
assert rtbc.getBundleDestinationBaseDirectories().size() == 1;
BundleDestinationBaseDirectory bdbd = rtbc.getBundleDestinationBaseDirectories().iterator().next();
assert bdbd.getName().equals(TEST_DESTBASEDIR_NAME);
assert bdbd.getValueContext() == ResourceTypeBundleConfiguration.BundleDestinationBaseDirectory.Context.pluginConfiguration;
assert bdbd.getValueName().equals(TEST_BUNDLE_DESTBASEDIR_PROP);
Agent agent = new Agent(TEST_PREFIX + "-testagent", "testaddress", 1, "", "testtoken");
em.persist(agent);
em.flush();
Configuration rc = new Configuration();
rc.put(new PropertySimple(TEST_BUNDLE_DESTBASEDIR_PROP, TEST_BUNDLE_DESTBASEDIR_PROP_VALUE));
em.persist(rc);
resource = new Resource("reskey" + System.currentTimeMillis(), TEST_PREFIX + "-resname", resourceType);
resource.setUuid("" + System.currentTimeMillis());
resource.setInventoryStatus(InventoryStatus.COMMITTED);
resource.setAgent(agent);
resource.setResourceConfiguration(rc);
em.persist(resource);
resourceGroup = new ResourceGroup(TEST_PREFIX + "-group-" + System.currentTimeMillis());
resourceGroup.addExplicitResource(resource);
resourceGroup.addImplicitResource(resource);
resourceGroup.setResourceType(resourceType); // need to tell the group the type it is
em.persist(resourceGroup);
getTransactionManager().commit();
} catch (Exception e) {
try {