### Question:
NodeTextSetter { public void setText(final String newText, final Node node) { final String name = getName(node); if (!Objects.equals(name, newText)) { getCurrentSession().ifPresent(session -> { final TextPropertyProvider textPropertyProvider = getTextPropertyProviderFactory().getProvider(node); getCanvasHandler(session).ifPresent(canvasHandler -> { textPropertyProvider.setText(canvasHandler, session.getCommandManager(), node, newText); fireCanvasElementUpdated(canvasHandler, node); }); }); } } @Inject  NodeTextSetter(final TextPropertyProviderFactory textPropertyProviderFactory,
                          final Event<CanvasElementUpdatedEvent> canvasElementUpdatedEvent,
                          final DMNGraphUtils dmnGraphUtils); TextPropertyProviderFactory getTextPropertyProviderFactory(); void setText(final String newText,
                        final Node node);  }### Answer:
@Test public void testSetText() { final Node node = mock(Node.class); final String oldName = "old name"; final String newName = "new name"; final DMNEditorSession dmnEditorSession = mock(DMNEditorSession.class); final Optional<DMNEditorSession> editorSession = Optional.of(dmnEditorSession); final TextPropertyProvider textPropertyProvider = mock(TextPropertyProvider.class); final CanvasCommandManager<AbstractCanvasHandler> commandManager = mock(CanvasCommandManager.class); final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class); final Optional<AbstractCanvasHandler> optionalCanvasHanlder = Optional.of(canvasHandler); when(dmnEditorSession.getCommandManager()).thenReturn(commandManager); when(textPropertyProviderFactory.getProvider(node)).thenReturn(textPropertyProvider); doReturn(oldName).when(nodeTextSetter).getName(node); doReturn(editorSession).when(nodeTextSetter).getCurrentSession(); doReturn(optionalCanvasHanlder).when(nodeTextSetter).getCanvasHandler(dmnEditorSession); nodeTextSetter.setText(newName, node); verify(textPropertyProvider).setText(canvasHandler, commandManager, node, newName); verify(nodeTextSetter).fireCanvasElementUpdated(canvasHandler, node); }