### Question:
ExpressionEditorDefinitions extends ArrayList<ExpressionEditorDefinition<Expression>> { public Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final Optional<Expression> expression) { if (!expression.isPresent()) { return this.stream() .filter(ed -> !ed.getModelClass().isPresent()) .findFirst(); } else { return this.stream() .filter(ed -> ed.getModelClass().isPresent()) .filter(ed -> ed.getModelClass().get().getClass().equals(expression.get().getClass())) .findFirst(); } }  Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final Optional<Expression> expression); Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final ExpressionType type);  }### Answer:
@Test public void textLookupForUndefinedExpression() { assertEquals(definition3, definitions.getExpressionEditorDefinition(Optional.empty()).get()); }
@Test public void textLookupByExpressionClass() { assertEquals(definition1, definitions.getExpressionEditorDefinition(Optional.of(new LiteralExpression())).get()); assertEquals(definition2, definitions.getExpressionEditorDefinition(Optional.of(new Context())).get()); }
@Test public void textLookupByExpressionType() { assertEquals(definition1, definitions.getExpressionEditorDefinition(ExpressionType.LITERAL_EXPRESSION).get()); assertEquals(definition2, definitions.getExpressionEditorDefinition(ExpressionType.CONTEXT).get()); }