PlanNode select1 = new PlanNode(Type.SELECT, project, selector("t1"));
PlanNode select2 = new PlanNode(Type.SELECT, select1, selector("t1"));
PlanNode select3 = new PlanNode(Type.SELECT, select2, selector("t1"));
PlanNode source = new PlanNode(Type.SOURCE, select3, selector("t1"));
source.setProperty(Property.SOURCE_NAME, selector("t1"));
select1.setProperty(Property.SELECT_CRITERIA, new Comparison(new PropertyValue(selector("t1"), "c2"), Operator.EQUAL_TO,
new Literal(100L)));
select2.setProperty(Property.SELECT_CRITERIA, new Comparison(new PropertyValue(selector("t1"), "c1"),
Operator.LESS_THAN_OR_EQUAL_TO, new Literal(3L)));
select3.setProperty(Property.SELECT_CRITERIA, new Comparison(new PropertyValue(selector("t1"), "c1"),
Operator.GREATER_THAN_OR_EQUAL_TO, new Literal(3L)));
// Execute the rule ...
print(access);
PlanNode result = executeRules(access);
print(result);
// Compare results ...
assertThat(result, is(sameInstance(access)));
assertThat(access.getProperty(Property.ACCESS_NO_RESULTS, Boolean.class), is(nullValue()));
assertChildren(access, project);
PlanNode newSelect = project.getFirstChild();
assertThat(newSelect.getType(), is(Type.SELECT));
assertThat(newSelect.getSelectors(), is(access.getSelectors()));
assertThat(newSelect.getParent(), is(sameInstance(project)));
Comparison equality = newSelect.getProperty(Property.SELECT_CRITERIA, Comparison.class);
assertThat(equality.getOperand1(), is(select2.getProperty(Property.SELECT_CRITERIA, Comparison.class).getOperand1()));
assertThat(equality.operator(), is(Operator.EQUAL_TO));
assertThat(equality.getOperand2(), is(select2.getProperty(Property.SELECT_CRITERIA, Comparison.class).getOperand2()));
assertChildren(newSelect, select1);
assertChildren(select1, source);
}