### Question:
NodeTextSetter { String getName(final Object node) { return getNamedElement(node) .map(namedElement -> namedElement.getName().getValue()) .orElse(""); } @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 testGetName() { final NamedElement named = mock(NamedElement.class); final Node node = mock(Node.class); final Name name = mock(Name.class); final String nodeName = "node name"; when(name.getValue()).thenReturn(nodeName); when(named.getName()).thenReturn(name); doReturn(Optional.of(named)).when(nodeTextSetter).getNamedElement(node); final String actualName = nodeTextSetter.getName(node); assertEquals(nodeName, actualName); }