@Test public void testGetSubResourceCategories() throws Exception { ResourceDefinition resourceDefinition = new StackResourceDefinition(); Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>(); mapIds.put(Resource.Type.Stack, "HDP"); QueryImpl instance = new QueryImplTest.TestQuery(mapIds, resourceDefinition); Predicate predicate = new PredicateBuilder().property("Stacks/stack_name").equals("HDP").and(). property("versions/stackServices/StackServices/service_name").equals("HBASE").and(). property("versions/operatingSystems/OperatingSystems/os_type").equals("centos5").toPredicate(); ProcessingPredicateVisitor visitor = new ProcessingPredicateVisitor(instance); PredicateHelper.visit(predicate, visitor); Set<String> categories = visitor.getSubResourceCategories(); Set<String> expected = new HashSet<String>(); expected.add("versions"); Assert.assertEquals(expected, categories); }
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();  }