@Test
public void shouldOptimizePlanForQueryUsingTypeView() {

    node = optimize("SELECT type1.a1 AS a, type1.a2 AS b FROM type1 WHERE CONTAINS(type1.a2,'something')");
    // Create the expected plan ...
    PlanNode access = new PlanNode(Type.ACCESS, selector("type1"));
    PlanNode project = new PlanNode(Type.PROJECT, access, selector("type1"));
    project.setProperty(Property.PROJECT_COLUMNS, columns(column("type1", "a1", "a"), column("type1", "a2", "b")));
    PlanNode select1 = new PlanNode(Type.SELECT, project, selector("type1"));
    select1.setProperty(Property.SELECT_CRITERIA, new FullTextSearch(selector("type1"), "a2", "something"));
    PlanNode select2 = new PlanNode(Type.SELECT, select1, selector("type1"));
    select2.setProperty(Property.SELECT_CRITERIA, new SetCriteria(new PropertyValue(selector("type1"), "primaryType"),
                                                                  new Literal("t1"), new Literal("t0")));
    PlanNode select3 = new PlanNode(Type.SELECT, select2, selector("type1"));
    select3.setProperty(Property.SELECT_CRITERIA, new SetCriteria(new PropertyValue(selector("type1"), "mixins"),
                                                                  new Literal("t3"), new Literal("t4")));
    PlanNode source = new PlanNode(Type.SOURCE, select3, selector("type1"));
    source.setProperty(Property.SOURCE_NAME, selector("all"));
    source.setProperty(Property.SOURCE_ALIAS, selector("type1"));
    source.setProperty(Property.SOURCE_COLUMNS, context.getSchemata().getTable(selector("all")).getColumns());
    // Compare the expected and actual plan ...
    assertPlanMatches(access);
}