server = waitForResourceByTypeAndKey(platform, platform, STANDALONE_RESOURCE_TYPE, STANDALONE_RESOURCE_KEY);
}
@Test(priority = 11)
public void loadUpdateTemplatedResourceConfiguration() throws Exception {
ConfigurationManager configurationManager = this.pluginContainer.getConfigurationManager();
for (ResourceData resourceData : testResourceData) {
ResourceType resourceType = new ResourceType(resourceData.resourceTypeName, PLUGIN_NAME,
ResourceCategory.SERVICE, null);
Resource subsystem = waitForResourceByTypeAndKey(platform, server, resourceType, resourceData.resourceKey);
Assert.assertNotNull(subsystem);
Queue<Resource> unparsedResources = new LinkedList<Resource>();
unparsedResources.add(subsystem);
List<Resource> foundResources = new ArrayList<Resource>();
while (!unparsedResources.isEmpty()) {
Resource currentResource = unparsedResources.poll();
for (Resource childResource : currentResource.getChildResources()) {
unparsedResources.add(childResource);
if (childResource.getResourceType().getName().equals(resourceData.subResourceType)) {
foundResources.add(childResource);
}
}
}
for (Resource resourceUnderTest : foundResources) {
log.info(foundResources);
assert resourceUnderTest.getId() != 0 : "Resource not properly initialized. Id = 0. Try extending sleep after discovery.";
Configuration resourceUnderTestConfig = configurationManager
.loadResourceConfiguration(resourceUnderTest.getId());
Assert.assertNotNull(resourceUnderTestConfig);
Assert.assertFalse(resourceUnderTestConfig.getProperties().isEmpty());
boolean specialPropertyFound = false;
for (Property property : resourceUnderTestConfig.getProperties()) {
if (property.getName().equals(resourceData.specialConfigurationProperty)) {
Assert.assertNotNull(((PropertySimple) property).getStringValue());
specialPropertyFound = true;
break;
}
}
Assert.assertTrue(specialPropertyFound, resourceData.specialConfigurationProperty
+ "property not found in the list of properties");
ConfigurationUpdateRequest testUpdateRequest = new ConfigurationUpdateRequest(1,
resourceUnderTestConfig, resourceUnderTest.getId());
ConfigurationUpdateResponse response = configurationManager
.executeUpdateResourceConfigurationImmediately(testUpdateRequest);
Assert.assertNotNull(response);
}
}