@Test
public void shouldOptimizePlanForQueryUsingView() {

    node = optimize("SELECT v1.c11 AS c1 FROM v1 WHERE v1.c11 = 'x' AND v1.c2 = 'y'");
    // Create the expected plan ...
    PlanNode access = new PlanNode(Type.ACCESS, selector("v1"));
    PlanNode project = new PlanNode(Type.PROJECT, access, selector("v1"));
    project.setProperty(Property.PROJECT_COLUMNS, columns(column("v1", "c11", "c1")));
    PlanNode select1 = new PlanNode(Type.SELECT, project, selector("v1"));
    select1.setProperty(Property.SELECT_CRITERIA, new Comparison(new PropertyValue(selector("v1"), "c11"), Operator.EQUAL_TO,
                                                                 new Literal("x")));
    PlanNode select2 = new PlanNode(Type.SELECT, select1, selector("v1"));
    select2.setProperty(Property.SELECT_CRITERIA, new Comparison(new PropertyValue(selector("v1"), "c12"), Operator.EQUAL_TO,
                                                                 new Literal("y")));
    PlanNode select3 = new PlanNode(Type.SELECT, select2, selector("v1"));
    select3.setProperty(Property.SELECT_CRITERIA, new Comparison(new PropertyValue(selector("v1"), "c13"),
                                                                 Operator.LESS_THAN, new Literal(3L)));
    PlanNode source = new PlanNode(Type.SOURCE, select3, selector("v1"));
    source.setProperty(Property.SOURCE_NAME, selector("t1"));
    source.setProperty(Property.SOURCE_ALIAS, selector("v1"));
    source.setProperty(Property.SOURCE_COLUMNS, context.getSchemata().getTable(selector("t1")).getColumns());
    // Compare the expected and actual plan ...
    assertPlanMatches(access);
}