### Question:
FunctionUIModelMapper extends BaseUIModelMapper<FunctionDefinition> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { dmnModel.get().ifPresent(function -> { final FunctionDefinition.Kind kind = extractExpressionLanguage(function); final Optional<Expression> expression = Optional.ofNullable(function.getExpression()); if (kind == null) { return; } switch (kind) { case FEEL: final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression); expressionEditorDefinition.ifPresent(ed -> { setUiModelEditor(rowIndex, columnIndex, function, ed); }); break; case JAVA: case PMML: final Optional<ExpressionEditorDefinition<Expression>> supplementaryEditorDefinition = supplementaryEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression); supplementaryEditorDefinition.ifPresent(ed -> { setUiModelEditor(rowIndex, columnIndex, function, ed); }); } }); } FunctionUIModelMapper(final GridWidget gridWidget,
                                 final Supplier<GridData> uiModel,
                                 final Supplier<Optional<FunctionDefinition>> dmnModel,
                                 final Supplier<Boolean> isOnlyVisualChangeAllowedSupplier,
                                 final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitionsSupplier,
                                 final Supplier<ExpressionEditorDefinitions> supplementaryEditorDefinitionsSupplier,
                                 final ListSelectorView.Presenter listSelector,
                                 final int nesting); @Override void fromDMNModel(final int rowIndex,
                             final int columnIndex); @Override @SuppressWarnings("unchecked") void toDMNModel(final int rowIndex,
                           final int columnIndex,
                           final Supplier<Optional<GridCellValue<?>>> cell);  }### Answer:
@Test public void testFromDMNModelExpressionKindFEEL() { setup(false); this.function.setExpression(literalExpression); this.function.setKind(FunctionDefinition.Kind.FEEL); mapper.fromDMNModel(0, 0); assertFromDMNModelEditor(literalExpressionEditor, literalExpressionEditorDefinition, false); }
@Test public void testFromDMNModelExpressionKindJava() { setup(false); this.function.setExpression(context); this.function.setKind(FunctionDefinition.Kind.JAVA); mapper.fromDMNModel(0, 0); assertFromDMNModelEditor(supplementaryEditor, supplementaryEditorDefinition, false); }
@Test public void testFromDMNModelExpressionKindPMML() { setup(false); this.function.setExpression(context); this.function.setKind(FunctionDefinition.Kind.PMML); mapper.fromDMNModel(0, 0); assertFromDMNModelEditor(supplementaryEditor, supplementaryEditorDefinition, false); }
@Test public void testFromDMNModelExpressionKindFEELWhenOnlyVisualChangeAllowed() { setup(true); this.function.setExpression(literalExpression); this.function.setKind(FunctionDefinition.Kind.FEEL); mapper.fromDMNModel(0, 0); assertFromDMNModelEditor(literalExpressionEditor, literalExpressionEditorDefinition, true); }
@Test public void testFromDMNModelExpressionKindJavaWhenOnlyVisualChangeAllowed() { setup(true); this.function.setExpression(context); this.function.setKind(FunctionDefinition.Kind.JAVA); mapper.fromDMNModel(0, 0); assertFromDMNModelEditor(supplementaryEditor, supplementaryEditorDefinition, true); }
@Test public void testFromDMNModelExpressionKindPMMLWhenOnlyVisualChangeAllowed() { setup(true); this.function.setExpression(context); this.function.setKind(FunctionDefinition.Kind.PMML); mapper.fromDMNModel(0, 0); assertFromDMNModelEditor(supplementaryEditor, supplementaryEditorDefinition, true); }