@Test
public void shouldStopExecutingRulesIfThereIsAnErrorInTheProblems() {

    // Change of the rules to generate an error ...
    this.rules.set(3, new OptimizerRule() {
        @Override
        public PlanNode execute( QueryContext context,
                                 PlanNode plan,
                                 LinkedList<OptimizerRule> ruleStack ) {
            context.getProblems().addError(GraphI18n.errorReadingPropertyValueBytes);
            return plan;
        }
    });
    optimizer.optimize(context, node);
    assertThat(ruleExecutionOrder.get(0), is(0));
    assertThat(ruleExecutionOrder.get(1), is(1));
    assertThat(ruleExecutionOrder.get(2), is(2));
    assertThat(ruleExecutionOrder.size(), is(3));
}