### Question:
RegisterNodeCommand extends org.kie.workbench.common.stunner.core.graph.command.impl.RegisterNodeCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = super.execute(context); if (!CommandUtils.isError(results)) { final Node<?, Edge> candidate = getCandidate(); if (candidate.getContent() instanceof View) { final DMNModelInstrumentedBase dmnModel = (DMNModelInstrumentedBase) ((View) candidate.getContent()).getDefinition(); if (dmnModel instanceof BusinessKnowledgeModel) { setupEncapsulatedLogicIfNodeIsNew((BusinessKnowledgeModel) dmnModel); } } } return results; } RegisterNodeCommand(final Node candidate); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context);  }### Answer:
@Test public void testExecuteWithBusinessKnowledgeModelNode() { when(candidateContent.getDefinition()).thenReturn(businessKnowledgeModel); assertThat(command.execute(graphCommandExecutionContext).getType()).isEqualTo(CommandResult.Type.INFO); final FunctionDefinition encapsulatedLogic = businessKnowledgeModel.getEncapsulatedLogic(); final Expression expression = encapsulatedLogic.getExpression(); assertThat(expression).isInstanceOf(LiteralExpression.class); assertThat(expression.getParent()).isEqualTo(encapsulatedLogic); assertThat(KindUtilities.getKind(encapsulatedLogic)).isEqualTo(FunctionDefinition.Kind.FEEL); }
@Test public void testExecuteWithBusinessKnowledgeModelNodeWhenNodeIsNotNew() { final FunctionDefinition functionDefinition = new FunctionDefinition(); final LiteralExpression literalExpression = makeLiteralExpression("123"); when(candidateContent.getDefinition()).thenReturn(businessKnowledgeModel); doReturn(functionDefinition).when(businessKnowledgeModel).getEncapsulatedLogic(); functionDefinition.setExpression(literalExpression); literalExpression.setParent(functionDefinition); assertThat(command.execute(graphCommandExecutionContext).getType()).isEqualTo(CommandResult.Type.INFO); final FunctionDefinition encapsulatedLogic = businessKnowledgeModel.getEncapsulatedLogic(); final Expression expression = encapsulatedLogic.getExpression(); assertThat(expression).isEqualTo(makeLiteralExpression("123")); assertThat(expression.getParent()).isEqualTo(encapsulatedLogic); assertThat(KindUtilities.getKind(encapsulatedLogic)).isEqualTo(FunctionDefinition.Kind.FEEL); }
@Test public void testExecuteWithNonBusinessKnowledgeModelNode() { when(candidateContent.getDefinition()).thenReturn(decision); assertThat(command.execute(graphCommandExecutionContext).getType()).isEqualTo(CommandResult.Type.INFO); }