@Test public void testGetSubResourceForNotPredicate() throws Exception { ResourceDefinition resourceDefinition = new HostResourceDefinition(); Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>(); mapIds.put(Resource.Type.Host, null); QueryImpl instance = new QueryImplTest.TestQuery(mapIds, resourceDefinition); Predicate notPredicate1 = new PredicateBuilder().not().property("host_components/HostRoles/component_name"). equals("ZOOKEEPER_SERVER").toPredicate(); Predicate notPredicate2 = new PredicateBuilder().not().property("host_components/HostRoles/component_name"). equals("HBASE_MASTER").toPredicate(); Predicate andPredicate = new AndPredicate(notPredicate1,notPredicate2); ProcessingPredicateVisitor visitor = new ProcessingPredicateVisitor(instance); PredicateHelper.visit(andPredicate, visitor); Set<String> categories = visitor.getSubResourceCategories(); Assert.assertEquals(categories.iterator().next(), "host_components"); }
public Set<String> getSubResourceCategories() { return subResourceCategories; }
ProcessingPredicateVisitor implements PredicateVisitor { public Set<String> getSubResourceCategories() { return subResourceCategories; } }
ProcessingPredicateVisitor implements PredicateVisitor { public Set<String> getSubResourceCategories() { return subResourceCategories; } ProcessingPredicateVisitor(QueryImpl query); }
ProcessingPredicateVisitor implements PredicateVisitor { public Set<String> getSubResourceCategories() { return subResourceCategories; } ProcessingPredicateVisitor(QueryImpl query); @Override void acceptComparisonPredicate(ComparisonPredicate predicate); @Override void acceptArrayPredicate(ArrayPredicate arrayPredicate); @Override void acceptUnaryPredicate(UnaryPredicate predicate); @Override void acceptAlwaysPredicate(AlwaysPredicate predicate); @Override void acceptCategoryPredicate(CategoryPredicate predicate); Predicate getProcessedPredicate(); Set<String> getSubResourceCategories(); Set<String> getSubResourceProperties(); }
ProcessingPredicateVisitor implements PredicateVisitor { public Set<String> getSubResourceCategories() { return subResourceCategories; } ProcessingPredicateVisitor(QueryImpl query); @Override void acceptComparisonPredicate(ComparisonPredicate predicate); @Override void acceptArrayPredicate(ArrayPredicate arrayPredicate); @Override void acceptUnaryPredicate(UnaryPredicate predicate); @Override void acceptAlwaysPredicate(AlwaysPredicate predicate); @Override void acceptCategoryPredicate(CategoryPredicate predicate); Predicate getProcessedPredicate(); Set<String> getSubResourceCategories(); Set<String> getSubResourceProperties();  }