@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); 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")); 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")); } 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")); } }
protected Set<Map<String, Object>> getPropertyMaps(Predicate givenPredicate) { SimplifyingPredicateVisitor visitor = new SimplifyingPredicateVisitor(this); PredicateHelper.visit(givenPredicate, visitor); List<Predicate> predicates = visitor.getSimplifiedPredicates(); Set<Map<String, Object>> propertyMaps = new HashSet<Map<String, Object>>(); for (Predicate predicate : predicates) { propertyMaps.add(PredicateHelper.getProperties(predicate)); } return propertyMaps; }
AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider { protected Set<Map<String, Object>> getPropertyMaps(Predicate givenPredicate) { SimplifyingPredicateVisitor visitor = new SimplifyingPredicateVisitor(this); PredicateHelper.visit(givenPredicate, visitor); List<Predicate> predicates = visitor.getSimplifiedPredicates(); Set<Map<String, Object>> propertyMaps = new HashSet<Map<String, Object>>(); for (Predicate predicate : predicates) { propertyMaps.add(PredicateHelper.getProperties(predicate)); } return propertyMaps; } }
AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider { protected Set<Map<String, Object>> getPropertyMaps(Predicate givenPredicate) { SimplifyingPredicateVisitor visitor = new SimplifyingPredicateVisitor(this); PredicateHelper.visit(givenPredicate, visitor); List<Predicate> predicates = visitor.getSimplifiedPredicates(); Set<Map<String, Object>> propertyMaps = new HashSet<Map<String, Object>>(); for (Predicate predicate : predicates) { propertyMaps.add(PredicateHelper.getProperties(predicate)); } return propertyMaps; } protected  AbstractResourceProvider(Set<String> propertyIds,
                                     Map<Resource.Type, String> keyPropertyIds); }
AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider { protected Set<Map<String, Object>> getPropertyMaps(Predicate givenPredicate) { SimplifyingPredicateVisitor visitor = new SimplifyingPredicateVisitor(this); PredicateHelper.visit(givenPredicate, visitor); List<Predicate> predicates = visitor.getSimplifiedPredicates(); Set<Map<String, Object>> propertyMaps = new HashSet<Map<String, Object>>(); for (Predicate predicate : predicates) { propertyMaps.add(PredicateHelper.getProperties(predicate)); } return propertyMaps; } protected  AbstractResourceProvider(Set<String> propertyIds,
                                     Map<Resource.Type, String> keyPropertyIds); @Override Map<Resource.Type, String> getKeyPropertyIds(); @Override void updateObservers(ResourceProviderEvent event); @Override void addObserver(ResourceProviderObserver observer); static List<ConfigurationRequest> getConfigurationRequests(String parentCategory, Map<String, Object> properties); static void parseProperties(ConfigurationRequest config, String absCategory, String propName, String propValue); }
AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider { protected Set<Map<String, Object>> getPropertyMaps(Predicate givenPredicate) { SimplifyingPredicateVisitor visitor = new SimplifyingPredicateVisitor(this); PredicateHelper.visit(givenPredicate, visitor); List<Predicate> predicates = visitor.getSimplifiedPredicates(); Set<Map<String, Object>> propertyMaps = new HashSet<Map<String, Object>>(); for (Predicate predicate : predicates) { propertyMaps.add(PredicateHelper.getProperties(predicate)); } return propertyMaps; } protected  AbstractResourceProvider(Set<String> propertyIds,
                                     Map<Resource.Type, String> keyPropertyIds); @Override Map<Resource.Type, String> getKeyPropertyIds(); @Override void updateObservers(ResourceProviderEvent event); @Override void addObserver(ResourceProviderObserver observer); static List<ConfigurationRequest> getConfigurationRequests(String parentCategory, Map<String, Object> properties); static void parseProperties(ConfigurationRequest config, String absCategory, String propName, String propValue); static Pattern propertiesAttributesPattern; }