@Test public void testGetNamedElement() { final Node node = mock(Node.class); final View content = mock(View.class); final NamedElement namedElement = mock(NamedElement.class); when(node.getContent()).thenReturn(content); when(content.getDefinition()).thenReturn(namedElement); final Optional<NamedElement> actualNamed = nodeTextSetter.getNamedElement(node); assertTrue(actualNamed.isPresent()); assertEquals(namedElement, actualNamed.get()); }
Optional<NamedElement> getNamedElement(final Object node) { return Optional .ofNullable(node) .filter(obj -> obj instanceof Node) .map(obj -> (Node) obj) .map(Node::getContent) .filter(content -> content instanceof View) .map(content -> (View) content) .map(View::getDefinition) .filter(content -> content instanceof NamedElement) .map(content -> (NamedElement) content); }
NodeTextSetter { Optional<NamedElement> getNamedElement(final Object node) { return Optional .ofNullable(node) .filter(obj -> obj instanceof Node) .map(obj -> (Node) obj) .map(Node::getContent) .filter(content -> content instanceof View) .map(content -> (View) content) .map(View::getDefinition) .filter(content -> content instanceof NamedElement) .map(content -> (NamedElement) content); } }
NodeTextSetter { Optional<NamedElement> getNamedElement(final Object node) { return Optional .ofNullable(node) .filter(obj -> obj instanceof Node) .map(obj -> (Node) obj) .map(Node::getContent) .filter(content -> content instanceof View) .map(content -> (View) content) .map(View::getDefinition) .filter(content -> content instanceof NamedElement) .map(content -> (NamedElement) content); } @Inject  NodeTextSetter(final TextPropertyProviderFactory textPropertyProviderFactory,
                          final Event<CanvasElementUpdatedEvent> canvasElementUpdatedEvent,
                          final DMNGraphUtils dmnGraphUtils); }
NodeTextSetter { Optional<NamedElement> getNamedElement(final Object node) { return Optional .ofNullable(node) .filter(obj -> obj instanceof Node) .map(obj -> (Node) obj) .map(Node::getContent) .filter(content -> content instanceof View) .map(content -> (View) content) .map(View::getDefinition) .filter(content -> content instanceof NamedElement) .map(content -> (NamedElement) content); } @Inject  NodeTextSetter(final TextPropertyProviderFactory textPropertyProviderFactory,
                          final Event<CanvasElementUpdatedEvent> canvasElementUpdatedEvent,
                          final DMNGraphUtils dmnGraphUtils); TextPropertyProviderFactory getTextPropertyProviderFactory(); void setText(final String newText,
                        final Node node); }
NodeTextSetter { Optional<NamedElement> getNamedElement(final Object node) { return Optional .ofNullable(node) .filter(obj -> obj instanceof Node) .map(obj -> (Node) obj) .map(Node::getContent) .filter(content -> content instanceof View) .map(content -> (View) content) .map(View::getDefinition) .filter(content -> content instanceof NamedElement) .map(content -> (NamedElement) content); } @Inject  NodeTextSetter(final TextPropertyProviderFactory textPropertyProviderFactory,
                          final Event<CanvasElementUpdatedEvent> canvasElementUpdatedEvent,
                          final DMNGraphUtils dmnGraphUtils); TextPropertyProviderFactory getTextPropertyProviderFactory(); void setText(final String newText,
                        final Node node);  }