// this is simulating what the UI would be doing, build the config and call the server-side API
// we'll pretend the user is the overlord - another test will check a real user to see permission errors
Configuration configuration = new Configuration();
configuration.put(new PropertySimple("myboolean", "true"));
ResourceConfigurationUpdate request = new ResourceConfigurationUpdate(resource, configuration, "dummyuser");
assert request.getStatus().equals(ConfigurationUpdateStatus.INPROGRESS);
configurationManager.updateResourceConfiguration(overlord, resource.getId(), configuration);
Thread.sleep(2000); // wait for the test agent to complete the request
// at this point in time, the round trip messaging is done and we have the agent response
ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
criteria.addFilterResourceIds(resource.getId());
criteria.fetchConfiguration(true);
criteria.addSortCreatedTime(PageOrdering.ASC);
List<ResourceConfigurationUpdate> requests;
requests = configurationManager.findResourceConfigurationUpdatesByCriteria(overlord, criteria);
assert requests.size() == 1;
assert requests.get(0) != null;
request = requests.get(0);
assert request.getStatus().equals(ConfigurationUpdateStatus.SUCCESS);
assert request.getErrorMessage() == null;
assert request.getConfiguration() != null;
PropertySimple mybool = request.getConfiguration().getSimple("myboolean");
assert mybool != null;
assert mybool.getStringValue().equals("true");
assert mybool.getErrorMessage() == null;
ResourceConfigurationUpdate current;
current = configurationManager.getLatestResourceConfigurationUpdate(overlord, resource.getId());
assert current != null;
assert current.getId() == request.getId();
assert current.getResource().equals(resource);
assert current.getStatus().equals(request.getStatus());
assert current.getSubjectName().equals(request.getSubjectName());
assert current.getCreatedTime() == request.getCreatedTime();
assert current.getModifiedTime() == request.getModifiedTime();
assert current.getConfiguration().getId() == request.getConfiguration().getId();
Configuration live = configurationManager.getLiveResourceConfiguration(overlord, resource.getId(), false);
assert live != null;
mybool = live.getSimple("myboolean");
assert mybool != null;