@Test
public void testVisit() {

  ResourceProvider provider = createStrictMock(ResourceProvider.class);
  Capture<Set<String>> propertiesCapture = EasyMock.newCapture();
  SimplifyingPredicateVisitor visitor = new SimplifyingPredicateVisitor(provider);
  //expectations
  expect(provider.checkPropertyIds(capture(propertiesCapture))).andReturn(Collections.<String>emptySet()).anyTimes();
  replay(provider);
  PredicateHelper.visit(PREDICATE_1, visitor);
  List<Predicate> simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(1, simplifiedPredicates.size());
  Assert.assertEquals(PREDICATE_1, simplifiedPredicates.get(0));
  Set<String> setProps = propertiesCapture.getValue();
  assertEquals(1, setProps.size());
  assertEquals(PROPERTY_A, setProps.iterator().next());
  // ---
  PredicateHelper.visit(PREDICATE_3, visitor);
  simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(1, simplifiedPredicates.size());
  Assert.assertEquals(PREDICATE_3, simplifiedPredicates.get(0));
  // ---
  PredicateHelper.visit(PREDICATE_4, visitor);
  simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(2, simplifiedPredicates.size());
  Assert.assertEquals(PREDICATE_1, simplifiedPredicates.get(0));
  Assert.assertEquals(PREDICATE_2, simplifiedPredicates.get(1));
  // ---
  PredicateHelper.visit(PREDICATE_6, visitor);
  simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(3, simplifiedPredicates.size());
  Assert.assertEquals(PREDICATE_5, simplifiedPredicates.get(0));
  Assert.assertEquals(PREDICATE_1, simplifiedPredicates.get(1));
  Assert.assertEquals(PREDICATE_2, simplifiedPredicates.get(2));
  // ---
  PredicateHelper.visit(PREDICATE_8, visitor);
  simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(4, simplifiedPredicates.size());
  Assert.assertEquals(PREDICATE_5, simplifiedPredicates.get(0));
  Assert.assertEquals(PREDICATE_1, simplifiedPredicates.get(1));
  Assert.assertEquals(PREDICATE_2, simplifiedPredicates.get(2));
  Assert.assertEquals(PREDICATE_7, simplifiedPredicates.get(3));
  // ---
  PredicateHelper.visit(PREDICATE_9, visitor);
  simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(4, simplifiedPredicates.size());
    Assert.assertEquals(???, simplifiedPredicates.get(0));
  // ---
  PredicateHelper.visit(PREDICATE_11, visitor);
  simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(4, simplifiedPredicates.size());
    Assert.assertEquals(???, simplifiedPredicates.get(0));
  // ---
  PredicateHelper.visit(PREDICATE_16, visitor);
  simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(1, simplifiedPredicates.size());
  Assert.assertEquals(PREDICATE_16, simplifiedPredicates.get(0));
  //reset assertions.  For property D, indicate that it is not supported.
  verify(provider);
  reset(provider);
  expect(provider.checkPropertyIds(capture(propertiesCapture))).andReturn(Collections.<String>emptySet());
  expect(provider.checkPropertyIds(capture(propertiesCapture))).andReturn(Collections.<String>singleton(PROPERTY_D));
  replay(provider);
  // ---
  PredicateHelper.visit(PREDICATE_13, visitor);
  simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(1, simplifiedPredicates.size());
  Assert.assertEquals(PREDICATE_1, simplifiedPredicates.get(0));
  verify(provider);
  reset(provider);
  expect(provider.checkPropertyIds(capture(propertiesCapture))).andReturn(Collections.<String>emptySet()).anyTimes();
  replay(provider);
  // ---
  PredicateHelper.visit(PREDICATE_15, visitor);
  simplifiedPredicates = visitor.getSimplifiedPredicates();
  Assert.assertEquals(1, simplifiedPredicates.size());
  Assert.assertEquals(PREDICATE_1, simplifiedPredicates.get(0));
  verify(provider);
}