@Test public void testGetSubResourcePredicate() throws Exception { Predicate predicate = new PredicateBuilder().property("ServiceInfo/service_name").equals("HBASE").and(). property("components/ServiceComponentInfo/category").equals("SLAVE").and(). property("components/host_components/metrics/cpu/cpu_num").greaterThanEqualTo(1).toPredicate(); SubResourcePredicateVisitor visitor = new SubResourcePredicateVisitor("components"); PredicateHelper.visit(predicate, visitor); Predicate subResourcePredicate = visitor.getSubResourcePredicate(); Predicate expectedPredicate = new PredicateBuilder().property("ServiceComponentInfo/category").equals("SLAVE").and(). property("host_components/metrics/cpu/cpu_num").greaterThanEqualTo(1).toPredicate(); Assert.assertEquals(expectedPredicate, subResourcePredicate); predicate = new PredicateBuilder().property("ServiceInfo/service_name").equals("HBASE").and(). property("ServiceInfo/component_name").equals("HBASE_MASTER").toPredicate(); visitor = new SubResourcePredicateVisitor("components"); PredicateHelper.visit(predicate, visitor); subResourcePredicate = visitor.getSubResourcePredicate(); Assert.assertEquals(new AndPredicate(), subResourcePredicate); Predicate notPredicate = new PredicateBuilder().not().property("host_components/HostRoles/component_name"). equals("ZOOKEEPER_SERVER").toPredicate(); Predicate expectedNotPredicate = new PredicateBuilder().not().property("HostRoles/component_name"). equals("ZOOKEEPER_SERVER").toPredicate(); visitor = new SubResourcePredicateVisitor("host_components"); PredicateHelper.visit(notPredicate, visitor); subResourcePredicate = visitor.getSubResourcePredicate(); Assert.assertEquals(expectedNotPredicate, subResourcePredicate); }
public Predicate getSubResourcePredicate() { return lastVisited; }
SubResourcePredicateVisitor implements PredicateVisitor { public Predicate getSubResourcePredicate() { return lastVisited; } }
SubResourcePredicateVisitor implements PredicateVisitor { public Predicate getSubResourcePredicate() { return lastVisited; } SubResourcePredicateVisitor(String category); }
SubResourcePredicateVisitor implements PredicateVisitor { public Predicate getSubResourcePredicate() { return lastVisited; } SubResourcePredicateVisitor(String category); @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 getSubResourcePredicate(); }
SubResourcePredicateVisitor implements PredicateVisitor { public Predicate getSubResourcePredicate() { return lastVisited; } SubResourcePredicateVisitor(String category); @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 getSubResourcePredicate();  }