@Test @SuppressWarnings("unchecked") public void testFromDMNModelExpressionGridCacheIsHit() { setup(false); expression = new LiteralExpression(); mapper.fromDMNModel(0, 0); verify(literalExpressionEditorDefinition).getEditor(eq(parent), nodeUUIDCaptor.capture(), eq(hasExpression), eq(Optional.of(hasName)), eq(false), eq(0)); verify(expressionGridCache).putExpressionGrid(nodeUUIDCaptor.getValue().get(), Optional.of(literalExpressionEditor)); mapper.fromDMNModel(0, 0); verify(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt()); verify(expressionGridCache).putExpressionGrid(anyString(), any(Optional.class)); }
@Override public void fromDMNModel(final int rowIndex, final int columnIndex) { final String uuid = nodeUUID.get(); final GridData uiModel = this.uiModel.get(); final Optional<Expression> expression = dmnModel.get(); final Optional<HasName> hasName = this.hasName.get(); final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get(); final HasExpression hasExpression = this.hasExpression.get(); final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitions.get().getExpressionEditorDefinition(expression); expressionEditorDefinition.ifPresent(definition -> { Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = expressionGridCache.get().getExpressionGrid(uuid); if (!editor.isPresent()) { final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.of(uuid), hasExpression, hasName, isOnlyVisualChangeAllowed, 0); expressionGridCache.get().putExpressionGrid(uuid, oEditor); editor = oEditor; } final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> _editor = editor; uiModel.setCell(0, 0, () -> new ContextGridCell<>(new ExpressionCellValue(_editor), listSelector)); }); }
ExpressionContainerUIModelMapper extends BaseUIModelMapper<Expression> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { final String uuid = nodeUUID.get(); final GridData uiModel = this.uiModel.get(); final Optional<Expression> expression = dmnModel.get(); final Optional<HasName> hasName = this.hasName.get(); final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get(); final HasExpression hasExpression = this.hasExpression.get(); final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitions.get().getExpressionEditorDefinition(expression); expressionEditorDefinition.ifPresent(definition -> { Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = expressionGridCache.get().getExpressionGrid(uuid); if (!editor.isPresent()) { final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.of(uuid), hasExpression, hasName, isOnlyVisualChangeAllowed, 0); expressionGridCache.get().putExpressionGrid(uuid, oEditor); editor = oEditor; } final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> _editor = editor; uiModel.setCell(0, 0, () -> new ContextGridCell<>(new ExpressionCellValue(_editor), listSelector)); }); } }
ExpressionContainerUIModelMapper extends BaseUIModelMapper<Expression> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { final String uuid = nodeUUID.get(); final GridData uiModel = this.uiModel.get(); final Optional<Expression> expression = dmnModel.get(); final Optional<HasName> hasName = this.hasName.get(); final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get(); final HasExpression hasExpression = this.hasExpression.get(); final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitions.get().getExpressionEditorDefinition(expression); expressionEditorDefinition.ifPresent(definition -> { Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = expressionGridCache.get().getExpressionGrid(uuid); if (!editor.isPresent()) { final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.of(uuid), hasExpression, hasName, isOnlyVisualChangeAllowed, 0); expressionGridCache.get().putExpressionGrid(uuid, oEditor); editor = oEditor; } final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> _editor = editor; uiModel.setCell(0, 0, () -> new ContextGridCell<>(new ExpressionCellValue(_editor), listSelector)); }); } ExpressionContainerUIModelMapper(final GridCellTuple parent,
                                            final Supplier<GridData> uiModel,
                                            final Supplier<Optional<Expression>> dmnModel,
                                            final Supplier<String> nodeUUID,
                                            final Supplier<HasExpression> hasExpression,
                                            final Supplier<Optional<HasName>> hasName,
                                            final Supplier<Boolean> isOnlyVisualChangeAllowedSupplier,
                                            final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitions,
                                            final Supplier<ExpressionGridCache> expressionGridCache,
                                            final ListSelectorView.Presenter listSelector); }
ExpressionContainerUIModelMapper extends BaseUIModelMapper<Expression> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { final String uuid = nodeUUID.get(); final GridData uiModel = this.uiModel.get(); final Optional<Expression> expression = dmnModel.get(); final Optional<HasName> hasName = this.hasName.get(); final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get(); final HasExpression hasExpression = this.hasExpression.get(); final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitions.get().getExpressionEditorDefinition(expression); expressionEditorDefinition.ifPresent(definition -> { Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = expressionGridCache.get().getExpressionGrid(uuid); if (!editor.isPresent()) { final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.of(uuid), hasExpression, hasName, isOnlyVisualChangeAllowed, 0); expressionGridCache.get().putExpressionGrid(uuid, oEditor); editor = oEditor; } final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> _editor = editor; uiModel.setCell(0, 0, () -> new ContextGridCell<>(new ExpressionCellValue(_editor), listSelector)); }); } ExpressionContainerUIModelMapper(final GridCellTuple parent,
                                            final Supplier<GridData> uiModel,
                                            final Supplier<Optional<Expression>> dmnModel,
                                            final Supplier<String> nodeUUID,
                                            final Supplier<HasExpression> hasExpression,
                                            final Supplier<Optional<HasName>> hasName,
                                            final Supplier<Boolean> isOnlyVisualChangeAllowedSupplier,
                                            final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitions,
                                            final Supplier<ExpressionGridCache> expressionGridCache,
                                            final ListSelectorView.Presenter listSelector); @Override void fromDMNModel(final int rowIndex,
                             final int columnIndex); @Override void toDMNModel(final int rowIndex,
                           final int columnIndex,
                           final Supplier<Optional<GridCellValue<?>>> cell); }
ExpressionContainerUIModelMapper extends BaseUIModelMapper<Expression> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { final String uuid = nodeUUID.get(); final GridData uiModel = this.uiModel.get(); final Optional<Expression> expression = dmnModel.get(); final Optional<HasName> hasName = this.hasName.get(); final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get(); final HasExpression hasExpression = this.hasExpression.get(); final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitions.get().getExpressionEditorDefinition(expression); expressionEditorDefinition.ifPresent(definition -> { Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = expressionGridCache.get().getExpressionGrid(uuid); if (!editor.isPresent()) { final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.of(uuid), hasExpression, hasName, isOnlyVisualChangeAllowed, 0); expressionGridCache.get().putExpressionGrid(uuid, oEditor); editor = oEditor; } final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> _editor = editor; uiModel.setCell(0, 0, () -> new ContextGridCell<>(new ExpressionCellValue(_editor), listSelector)); }); } ExpressionContainerUIModelMapper(final GridCellTuple parent,
                                            final Supplier<GridData> uiModel,
                                            final Supplier<Optional<Expression>> dmnModel,
                                            final Supplier<String> nodeUUID,
                                            final Supplier<HasExpression> hasExpression,
                                            final Supplier<Optional<HasName>> hasName,
                                            final Supplier<Boolean> isOnlyVisualChangeAllowedSupplier,
                                            final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitions,
                                            final Supplier<ExpressionGridCache> expressionGridCache,
                                            final ListSelectorView.Presenter listSelector); @Override void fromDMNModel(final int rowIndex,
                             final int columnIndex); @Override void toDMNModel(final int rowIndex,
                           final int columnIndex,
                           final Supplier<Optional<GridCellValue<?>>> cell);  }