### Question:
AddAccessNodes implements OptimizerRule { public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode source : plan.findAllAtOrBelow(Type.SOURCE)) { if (source.getChildCount() != 0) continue; PlanNode access = new PlanNode(Type.ACCESS); access.addSelectors(source.getSelectors()); source.insertAsParent(access); } return plan; }  PlanNode execute( QueryContext context,
                             PlanNode plan,
                             LinkedList<OptimizerRule> ruleStack ); @Override String toString(); static final AddAccessNodes INSTANCE; }### Answer:
@Test public void shouldAddAccessNodeAboveSourceNode() { PlanNode project = new PlanNode(Type.PROJECT, selector("Selector1")); PlanNode source = new PlanNode(Type.SOURCE, project, selector("Selector1")); PlanNode result = rule.execute(context, project, new LinkedList<OptimizerRule>()); assertThat(result, is(sameInstance(project))); PlanNode access = project.getFirstChild(); assertThat(access.getType(), is(Type.ACCESS)); assertSelectors(access, "Selector1"); assertChildren(access, source); assertChildren(source); }