@Test @SuppressWarnings("unchecked") public void testOnCanvasElementUpdatedDifferentNode() { final CanvasElementUpdatedEvent event = new CanvasElementUpdatedEvent(canvasHandler, node); final Decision differentNodeDefinition = mock(Decision.class); when(node.getContent()).thenReturn(definition); when(definition.getDefinition()).thenReturn(differentNodeDefinition); setupExpression(decision, decision, toolbarStateHandler, false); testedEditor.handleCanvasElementUpdated(event); verify(view, never()).setExpressionNameText(any(Optional.class)); }
@Override public void handleCanvasElementUpdated(final CanvasElementUpdatedEvent event) { final Element<?> element = event.getElement(); if ((element instanceof Node)) { if (element.getContent() instanceof Definition) { final Definition definition = (Definition) element.getContent(); final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); definitions.ifPresent(d -> { if (Objects.equals(d, definition.getDefinition())) { view.setReturnToLinkText(returnToLinkTextSupplier.get()); } }); hasExpression.ifPresent(e -> { if (Objects.equals(e.asDMNModelInstrumentedBase(), definition.getDefinition())) { view.setExpressionNameText(Optional.ofNullable((HasName) definition.getDefinition())); view.refresh(); } }); } } }
ExpressionEditor implements ExpressionEditorView.Presenter { @Override public void handleCanvasElementUpdated(final CanvasElementUpdatedEvent event) { final Element<?> element = event.getElement(); if ((element instanceof Node)) { if (element.getContent() instanceof Definition) { final Definition definition = (Definition) element.getContent(); final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); definitions.ifPresent(d -> { if (Objects.equals(d, definition.getDefinition())) { view.setReturnToLinkText(returnToLinkTextSupplier.get()); } }); hasExpression.ifPresent(e -> { if (Objects.equals(e.asDMNModelInstrumentedBase(), definition.getDefinition())) { view.setExpressionNameText(Optional.ofNullable((HasName) definition.getDefinition())); view.refresh(); } }); } } } }
ExpressionEditor implements ExpressionEditorView.Presenter { @Override public void handleCanvasElementUpdated(final CanvasElementUpdatedEvent event) { final Element<?> element = event.getElement(); if ((element instanceof Node)) { if (element.getContent() instanceof Definition) { final Definition definition = (Definition) element.getContent(); final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); definitions.ifPresent(d -> { if (Objects.equals(d, definition.getDefinition())) { view.setReturnToLinkText(returnToLinkTextSupplier.get()); } }); hasExpression.ifPresent(e -> { if (Objects.equals(e.asDMNModelInstrumentedBase(), definition.getDefinition())) { view.setExpressionNameText(Optional.ofNullable((HasName) definition.getDefinition())); view.refresh(); } }); } } } @SuppressWarnings("unchecked")  ExpressionEditor(final ExpressionEditorView view,
                            final DecisionNavigatorPresenter decisionNavigator,
                            final DMNGraphUtils dmnGraphUtils,
                            final DMNDiagramsSession dmnDiagramsSession,
                            final DRDNameChanger drdNameChanger); }
ExpressionEditor implements ExpressionEditorView.Presenter { @Override public void handleCanvasElementUpdated(final CanvasElementUpdatedEvent event) { final Element<?> element = event.getElement(); if ((element instanceof Node)) { if (element.getContent() instanceof Definition) { final Definition definition = (Definition) element.getContent(); final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); definitions.ifPresent(d -> { if (Objects.equals(d, definition.getDefinition())) { view.setReturnToLinkText(returnToLinkTextSupplier.get()); } }); hasExpression.ifPresent(e -> { if (Objects.equals(e.asDMNModelInstrumentedBase(), definition.getDefinition())) { view.setExpressionNameText(Optional.ofNullable((HasName) definition.getDefinition())); view.refresh(); } }); } } } @SuppressWarnings("unchecked")  ExpressionEditor(final ExpressionEditorView view,
                            final DecisionNavigatorPresenter decisionNavigator,
                            final DMNGraphUtils dmnGraphUtils,
                            final DMNDiagramsSession dmnDiagramsSession,
                            final DRDNameChanger drdNameChanger); @Override HTMLElement getElement(); @Override void bind(final DMNSession session); @Override ExpressionEditorView getView(); @Override void setToolbarStateHandler(final ToolbarStateHandler toolbarStateHandler); @Override void setExpression(final String nodeUUID,
                              final HasExpression hasExpression,
                              final Optional<HasName> hasName,
                              final boolean isOnlyVisualChangeAllowed); @Override void setExitCommand(final Command exitCommand); @Override void exit(); @Override void handleCanvasElementUpdated(final CanvasElementUpdatedEvent event); @Override boolean isActive(); }
ExpressionEditor implements ExpressionEditorView.Presenter { @Override public void handleCanvasElementUpdated(final CanvasElementUpdatedEvent event) { final Element<?> element = event.getElement(); if ((element instanceof Node)) { if (element.getContent() instanceof Definition) { final Definition definition = (Definition) element.getContent(); final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); definitions.ifPresent(d -> { if (Objects.equals(d, definition.getDefinition())) { view.setReturnToLinkText(returnToLinkTextSupplier.get()); } }); hasExpression.ifPresent(e -> { if (Objects.equals(e.asDMNModelInstrumentedBase(), definition.getDefinition())) { view.setExpressionNameText(Optional.ofNullable((HasName) definition.getDefinition())); view.refresh(); } }); } } } @SuppressWarnings("unchecked")  ExpressionEditor(final ExpressionEditorView view,
                            final DecisionNavigatorPresenter decisionNavigator,
                            final DMNGraphUtils dmnGraphUtils,
                            final DMNDiagramsSession dmnDiagramsSession,
                            final DRDNameChanger drdNameChanger); @Override HTMLElement getElement(); @Override void bind(final DMNSession session); @Override ExpressionEditorView getView(); @Override void setToolbarStateHandler(final ToolbarStateHandler toolbarStateHandler); @Override void setExpression(final String nodeUUID,
                              final HasExpression hasExpression,
                              final Optional<HasName> hasName,
                              final boolean isOnlyVisualChangeAllowed); @Override void setExitCommand(final Command exitCommand); @Override void exit(); @Override void handleCanvasElementUpdated(final CanvasElementUpdatedEvent event); @Override boolean isActive();  }