### Question:
MorphNodeCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { checkSafeCandidate(context); final CommandResult<RuleViolation> results = check(context); final DefinitionManager definitionManager = context.getDefinitionManager(); final Object currentDef = candidate.getContent().getDefinition(); final String currentDefId = definitionManager.adapters().forDefinition().getId(currentDef).value(); this.oldMorphTarget = currentDefId; final MorphAdapter<Object> morphAdapter = context.getDefinitionManager().adapters().registry().getMorphAdapter(currentDef.getClass()); if (null == morphAdapter) { throw new RuntimeException("No morph adapter found for definition [" + currentDef.toString() + "] " + "and target morph [" + morphTarget + "]"); } final Object targetDef = morphAdapter.morph(currentDef, morphDefinition, morphTarget); if (null == targetDef) { throw new RuntimeException("No morph resulting Definition. [ morphSource=" + currentDefId + ", " + "morphTarget=" + morphTarget + "]"); } candidate.getContent().setDefinition(targetDef); final DefinitionAdapter<Object> adapter = definitionManager .adapters() .registry() .getDefinitionAdapter(targetDef.getClass()); candidate.getLabels().clear(); final String[] labels = AbstractElementFactory.computeLabels(adapter, targetDef); for (String label : labels) { candidate.getLabels().add(label); } return results; } MorphNodeCommand(final @MapsTo("uuid") String uuid,
                            final @MapsTo("morphDefinition") MorphDefinition morphDefinition,
                            final @MapsTo("morphTarget") String morphTarget);  MorphNodeCommand(final Node<Definition, Edge> candidate,
                            final MorphDefinition morphDefinition,
                            final String morphTarget); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); @Override String toString();  }### Answer:
@Test @SuppressWarnings("unchecked") public void testExecute() { CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext); assertEquals(CommandResult.Type.INFO, result.getType()); verify(content).setDefinition(eq(NEW_DEFINITION)); assertEquals(2, labels.size()); assertTrue(labels.contains(NEW_DEFINITION_ID)); assertTrue(labels.contains(NEW_DEFINITION_LABEL)); }