propertyIds.add(ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID);
propertyIds.add(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID);
// create the request
Predicate predicate = new PredicateBuilder().property(ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").toPredicate();
Request request = PropertyHelper.getReadRequest("ServiceInfo");
Set<Resource> resources = provider.getResources(request, predicate);
Assert.assertEquals(5, resources.size());
Set<String> names = new HashSet<String>();
for (Resource resource : resources) {
String clusterName = (String) resource.getPropertyValue(ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID);
Assert.assertEquals("Cluster100", clusterName);
names.add((String) resource.getPropertyValue(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID));
}
// Make sure that all of the response objects got moved into resources
for (Service service : allResponseMap.values() ) {
Assert.assertTrue(names.contains(service.getName()));
}
// get service named Service102
predicate = new PredicateBuilder().property(ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").and().
property(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID).equals("Service102").toPredicate();
request = PropertyHelper.getReadRequest("ServiceInfo");
resources = provider.getResources(request, predicate);
Assert.assertEquals(1, resources.size());
Assert.assertEquals("Service102", resources.iterator().next().getPropertyValue(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID));
// get services where state == "INIT"
predicate = new PredicateBuilder().property(ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").and().
property(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID).equals("INIT").toPredicate();
request = PropertyHelper.getReadRequest(propertyIds);
resources = provider.getResources(request, predicate);
Assert.assertEquals(3, resources.size());