expect(hostRoleCommand.getStatus()).andReturn(HostRoleStatus.IN_PROGRESS);
// replay
replay(managementController, actionManager, hostRoleCommand, clusters, cluster, requestMock);
ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
type,
PropertyHelper.getPropertyIds(type),
PropertyHelper.getKeyPropertyIds(type),
managementController);
Set<String> propertyIds = new HashSet<String>();
propertyIds.add(RequestResourceProvider.REQUEST_ID_PROPERTY_ID);
propertyIds.add(RequestResourceProvider.REQUEST_STATUS_PROPERTY_ID);
Predicate predicate = new PredicateBuilder().
property(RequestResourceProvider.REQUEST_CLUSTER_NAME_PROPERTY_ID).equals("c1").and().
property(RequestResourceProvider.REQUEST_ID_PROPERTY_ID).equals("100").
toPredicate();
Request request = PropertyHelper.getReadRequest(propertyIds);
Set<Resource> resources = provider.getResources(request, predicate);
Assert.assertEquals(1, resources.size());
for (Resource resource : resources) {
Assert.assertEquals(100L, (long) (Long) resource.getPropertyValue(RequestResourceProvider.REQUEST_ID_PROPERTY_ID));
Assert.assertEquals("IN_PROGRESS", resource.getPropertyValue(RequestResourceProvider.REQUEST_STATUS_PROPERTY_ID));
}
// try again with a bad cluster name
predicate = new PredicateBuilder().
property(RequestResourceProvider.REQUEST_CLUSTER_NAME_PROPERTY_ID).equals("bad-cluster").and().
property(RequestResourceProvider.REQUEST_ID_PROPERTY_ID).equals("100").
toPredicate();
try {
provider.getResources(request, predicate);
} catch (NoSuchParentResourceException e) {
e.printStackTrace();
}
// verify