}
public void testResourceErrors() {
ResourceError error;
List<ResourceError> errors;
DiscoveryServerServiceImpl serverService = new DiscoveryServerServiceImpl();
errors = resourceManager.findResourceErrors(getOverlord(), newResource.getId(),
ResourceErrorType.INVALID_PLUGIN_CONFIGURATION);
assert errors.size() == 0;
error = new ResourceError(newResource, ResourceErrorType.INVALID_PLUGIN_CONFIGURATION, "test summary",
"test detail", 12345);
// simulate the agent notifying the server about an error
// this will exercise the addResourceError in the SLSB
serverService.setResourceError(error);
errors = resourceManager.findResourceErrors(getOverlord(), newResource.getId(),
ResourceErrorType.INVALID_PLUGIN_CONFIGURATION);
assert errors.size() == 1;
error = errors.get(0);
assert error.getId() > 0;
assert error.getSummary().equals("test summary");
assert error.getDetail().equals("test detail");
assert error.getErrorType() == ResourceErrorType.INVALID_PLUGIN_CONFIGURATION;
assert error.getTimeOccurred() == 12345;
// simulate the agent notifying the server about another error.
// there will only be a single invalid plugin config allowed; the prior one will be deleted
// this will exercise the addResourceError and deleteResourceError in the SLSB
error.setId(0);
error.setTimeOccurred(567890);
error.setSummary("another summary");
error.setDetail("another detail");
serverService.setResourceError(error);
errors = resourceManager.findResourceErrors(getOverlord(), newResource.getId(),
ResourceErrorType.INVALID_PLUGIN_CONFIGURATION);
assert errors.size() == 1;
error = errors.get(0);
assert error.getId() > 0;