@Test
public void testGetPropertyMaps() throws Exception {

  AbstractResourceProvider provider = new TestResourceProvider();
  Map<String, Object> updatePropertyMap = new HashMap<String, Object>();
  updatePropertyMap.put("SomeProperty", "SomeUpdateValue");
  updatePropertyMap.put("SomeOtherProperty", 99);
  // get the property map to update resource
  // where ClusterName=c1 and ResourceName=r1
  PredicateBuilder pb = new PredicateBuilder();
  Predicate predicate = pb.property("ClusterName").equals("c1").and().property("ResourceName").equals("r1").toPredicate();
  Set<Map<String, Object>> propertyMaps = provider.getPropertyMaps(updatePropertyMap, predicate);
  Assert.assertEquals(1, propertyMaps.size());
  Map<String, Object> map = propertyMaps.iterator().next();
  Assert.assertEquals(4, map.size());
  Assert.assertEquals("c1", map.get("ClusterName"));
  Assert.assertEquals("r1", map.get("ResourceName"));
  Assert.assertEquals("SomeUpdateValue", map.get("SomeProperty"));
  Assert.assertEquals(99, map.get("SomeOtherProperty"));
  // get the property maps to update resources
  // where ClusterName=c1 and (ResourceName=r1 or ResourceName=r2)
  pb = new PredicateBuilder();
  predicate = pb.property("ClusterName").equals("c1").and().
      begin().
        property("ResourceName").equals("r1").or().property("ResourceName").equals("r2").
      end().toPredicate();
  propertyMaps = provider.getPropertyMaps(updatePropertyMap, predicate);
  Assert.assertEquals(2, propertyMaps.size());
  for (Map<String, Object> map2 : propertyMaps) {
    Assert.assertEquals(4, map2.size());
    Assert.assertEquals("c1", map2.get("ClusterName"));
    Object resourceName = map2.get("ResourceName");
    Assert.assertTrue(resourceName.equals("r1") || resourceName.equals("r2"));
    Assert.assertEquals("SomeUpdateValue", map2.get("SomeProperty"));
    Assert.assertEquals(99, map2.get("SomeOtherProperty"));
  }
  // get the property maps to update all resources
  predicate = new AlwaysPredicate();
  propertyMaps = provider.getPropertyMaps(updatePropertyMap, predicate);
  Assert.assertEquals(4, propertyMaps.size());
  for (Map<String, Object> map2 : propertyMaps) {
    Assert.assertEquals(4, map2.size());
    Assert.assertEquals("c1", map2.get("ClusterName"));
    Object resourceName = map2.get("ResourceName");
    Assert.assertTrue(resourceName.equals("r1") || resourceName.equals("r2")||
        resourceName.equals("r3") || resourceName.equals("r4"));
    Assert.assertEquals("SomeUpdateValue", map2.get("SomeProperty"));
    Assert.assertEquals(99, map2.get("SomeOtherProperty"));
  }
}