replay(managementController, clusters, cluster, configGroup1,
configGroup2, configGroup3, configGroup4, response1, response2,
response3, response4);
ResourceProvider resourceProvider = getConfigGroupResourceProvider
(managementController);
Set<String> propertyIds = new HashSet<String>();
propertyIds.add(ConfigGroupResourceProvider.CONFIGGROUP_CLUSTER_NAME_PROPERTY_ID);
propertyIds.add(ConfigGroupResourceProvider.CONFIGGROUP_ID_PROPERTY_ID);
// Read all
Predicate predicate = new PredicateBuilder().property
(ConfigGroupResourceProvider.CONFIGGROUP_CLUSTER_NAME_PROPERTY_ID)
.equals("Cluster100").toPredicate();
Request request = PropertyHelper.getReadRequest(propertyIds);
Set<Resource> resources = resourceProvider.getResources(request,
predicate);
assertEquals(4, resources.size());
// Read by id
predicate = new PredicateBuilder().property(ConfigGroupResourceProvider
.CONFIGGROUP_ID_PROPERTY_ID).equals(1L).and().property
(ConfigGroupResourceProvider.CONFIGGROUP_CLUSTER_NAME_PROPERTY_ID)
.equals("Cluster100").toPredicate();
resources = resourceProvider.getResources(request, predicate);
assertEquals(1, resources.size());
assertEquals(1L, resources.iterator().next().getPropertyValue
(ConfigGroupResourceProvider.CONFIGGROUP_ID_PROPERTY_ID));
// Read by Name
predicate = new PredicateBuilder().property(ConfigGroupResourceProvider
.CONFIGGROUP_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").and()
.property(ConfigGroupResourceProvider.CONFIGGROUP_NAME_PROPERTY_ID)
.equals("g2").toPredicate();
resources = resourceProvider.getResources(request, predicate);
assertEquals(1, resources.size());
assertEquals("g2", resources.iterator().next().getPropertyValue
(ConfigGroupResourceProvider.CONFIGGROUP_NAME_PROPERTY_ID));
// Read by tag
predicate = new PredicateBuilder().property(ConfigGroupResourceProvider
.CONFIGGROUP_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").and()
.property(ConfigGroupResourceProvider.CONFIGGROUP_TAG_PROPERTY_ID)
.equals("t3").toPredicate();
resources = resourceProvider.getResources(request, predicate);
assertEquals(1, resources.size());
assertEquals("t3", resources.iterator().next().getPropertyValue
(ConfigGroupResourceProvider.CONFIGGROUP_TAG_PROPERTY_ID));
// Read by hostname
predicate = new PredicateBuilder().property(ConfigGroupResourceProvider
.CONFIGGROUP_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").and()
.property(ConfigGroupResourceProvider.CONFIGGROUP_HOSTS_PROPERTY_ID)
.equals("h1").toPredicate();
resources = resourceProvider.getResources(request, predicate);
assertEquals(1, resources.size());
Set<Map<String, Object>> hostSet = (Set<Map<String, Object>>)
resources.iterator().next()
.getPropertyValue(ConfigGroupResourceProvider
.CONFIGGROUP_HOSTS_PROPERTY_ID);
assertEquals("h1", hostSet.iterator().next().get
(ConfigGroupResourceProvider.CONFIGGROUP_HOSTNAME_PROPERTY_ID));
// Read by tag and hostname - Positive
predicate = new PredicateBuilder().property(ConfigGroupResourceProvider
.CONFIGGROUP_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").and()
.property(ConfigGroupResourceProvider.CONFIGGROUP_TAG_PROPERTY_ID)
.equals("t4").and().property(ConfigGroupResourceProvider
.CONFIGGROUP_HOSTS_PROPERTY_ID).equals("h1").toPredicate();
resources = resourceProvider.getResources(request, predicate);
assertEquals(1, resources.size());
hostSet = (Set<Map<String, Object>>)
resources.iterator().next()
.getPropertyValue(ConfigGroupResourceProvider