### Question:
DecisionNavigatorNestedItemFactory { public boolean hasNestedElement(final Node<View, Edge> node) { return helper.getOptionalHasExpression(node).isPresent() && helper.getOptionalExpression(node).isPresent(); } @Inject  DecisionNavigatorNestedItemFactory(final SessionManager sessionManager,
                                              final Event<EditExpressionEvent> editExpressionEvent,
                                              final DMNGraphUtils dmnGraphUtils,
                                              final @DMNEditor Supplier<ExpressionEditorDefinitions> expressionEditorDefinitionsSupplier,
                                              final Event<CanvasSelectionEvent> canvasSelectionEvent,
                                              final BoxedExpressionHelper helper); DecisionNavigatorItem makeItem(final Node<View, Edge> node); boolean hasNestedElement(final Node<View, Edge> node);  }### Answer:
@Test public void testHasNestedElementWhenNodeHasExpressionIsNull() { final Optional<HasExpression> hasExpression = Optional.empty(); final Optional<Expression> expression = Optional.empty(); when(boxedExpressionHelper.getOptionalHasExpression(node)).thenReturn(hasExpression); when(boxedExpressionHelper.getOptionalExpression(node)).thenReturn(expression); assertFalse(factory.hasNestedElement(node)); }
@Test public void testHasNestedElementWhenNodeExpressionIsNull() { final Optional<HasExpression> hasExpression = Optional.ofNullable(mock(HasExpression.class)); final Optional<Expression> expression = Optional.empty(); when(boxedExpressionHelper.getOptionalHasExpression(node)).thenReturn(hasExpression); when(boxedExpressionHelper.getOptionalExpression(node)).thenReturn(expression); assertFalse(factory.hasNestedElement(node)); }
@Test public void testHasNestedElementWhenNodeHasNestedElement() { final Optional<HasExpression> hasExpression = Optional.ofNullable(mock(HasExpression.class)); final Optional<Expression> expression = Optional.ofNullable(mock(Expression.class)); when(boxedExpressionHelper.getOptionalHasExpression(node)).thenReturn(hasExpression); when(boxedExpressionHelper.getOptionalExpression(node)).thenReturn(expression); assertTrue(factory.hasNestedElement(node)); }