@Test public void testInitialize() throws Exception { cloneNodeCommand.initialize(graphCommandExecutionContext); Node<View, Edge> clone = cloneNodeCommand.getClone(); assertEquals(clone, this.clone); RegisterNodeCommand registerNodeCommand = (RegisterNodeCommand) cloneNodeCommand.getCommands().stream().filter(command -> command instanceof RegisterNodeCommand).findFirst().get(); assertNotNull(registerNodeCommand); assertEquals(registerNodeCommand.getCandidate(), clone); AddChildNodeCommand addChildCommand = (AddChildNodeCommand) cloneNodeCommand.getCommands().stream().filter(command -> command instanceof AddChildNodeCommand).findFirst().get(); assertNotNull(addChildCommand); assertEquals(addChildCommand.getCandidate(), clone); assertEquals(addChildCommand.getParent(graphCommandExecutionContext), graphInstance.parentNode); if (addChildCommand.getLocation() != null) { assertEquals(addChildCommand.getLocation().getX(), position.getX(), 0); assertEquals(addChildCommand.getLocation().getY(), position.getY(), 0); } }
@Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<GraphCommandExecutionContext, RuleViolation> initialize(GraphCommandExecutionContext context) { Optional<String> parentUUID = getParentUUID(); if (!parentUUID.isPresent()) { throw new IllegalStateException("Parent not found for node " + candidate); } final Object bean = candidate.getContent().getDefinition(); final DefinitionId definitionId = context.getDefinitionManager().adapters().forDefinition().getId(bean); clone = (Node<View, Edge>) context.getFactoryManager().newElement(UUID.uuid(), definitionId.value()).asNode(); cloneNodeContentWithProperties(context); createNodeCommands(clone, parentUUID.get(), position); return this; }
CloneNodeCommand extends AbstractGraphCompositeCommand { @Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<GraphCommandExecutionContext, RuleViolation> initialize(GraphCommandExecutionContext context) { Optional<String> parentUUID = getParentUUID(); if (!parentUUID.isPresent()) { throw new IllegalStateException("Parent not found for node " + candidate); } final Object bean = candidate.getContent().getDefinition(); final DefinitionId definitionId = context.getDefinitionManager().adapters().forDefinition().getId(bean); clone = (Node<View, Edge>) context.getFactoryManager().newElement(UUID.uuid(), definitionId.value()).asNode(); cloneNodeContentWithProperties(context); createNodeCommands(clone, parentUUID.get(), position); return this; } }
CloneNodeCommand extends AbstractGraphCompositeCommand { @Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<GraphCommandExecutionContext, RuleViolation> initialize(GraphCommandExecutionContext context) { Optional<String> parentUUID = getParentUUID(); if (!parentUUID.isPresent()) { throw new IllegalStateException("Parent not found for node " + candidate); } final Object bean = candidate.getContent().getDefinition(); final DefinitionId definitionId = context.getDefinitionManager().adapters().forDefinition().getId(bean); clone = (Node<View, Edge>) context.getFactoryManager().newElement(UUID.uuid(), definitionId.value()).asNode(); cloneNodeContentWithProperties(context); createNodeCommands(clone, parentUUID.get(), position); return this; } protected  CloneNodeCommand();  CloneNodeCommand(final @MapsTo("candidate") Node candidate, final @MapsTo("parentUuid") String parentUuid);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback); }
CloneNodeCommand extends AbstractGraphCompositeCommand { @Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<GraphCommandExecutionContext, RuleViolation> initialize(GraphCommandExecutionContext context) { Optional<String> parentUUID = getParentUUID(); if (!parentUUID.isPresent()) { throw new IllegalStateException("Parent not found for node " + candidate); } final Object bean = candidate.getContent().getDefinition(); final DefinitionId definitionId = context.getDefinitionManager().adapters().forDefinition().getId(bean); clone = (Node<View, Edge>) context.getFactoryManager().newElement(UUID.uuid(), definitionId.value()).asNode(); cloneNodeContentWithProperties(context); createNodeCommands(clone, parentUUID.get(), position); return this; } protected  CloneNodeCommand();  CloneNodeCommand(final @MapsTo("candidate") Node candidate, final @MapsTo("parentUuid") String parentUuid);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); List<CommandResult<RuleViolation>> processChildrenNodes(GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); Node<View, Edge> getClone(); Node<Definition, Edge> getCandidate(); List<Command<GraphCommandExecutionContext, RuleViolation>> getChildrenCommands(); }
CloneNodeCommand extends AbstractGraphCompositeCommand { @Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<GraphCommandExecutionContext, RuleViolation> initialize(GraphCommandExecutionContext context) { Optional<String> parentUUID = getParentUUID(); if (!parentUUID.isPresent()) { throw new IllegalStateException("Parent not found for node " + candidate); } final Object bean = candidate.getContent().getDefinition(); final DefinitionId definitionId = context.getDefinitionManager().adapters().forDefinition().getId(bean); clone = (Node<View, Edge>) context.getFactoryManager().newElement(UUID.uuid(), definitionId.value()).asNode(); cloneNodeContentWithProperties(context); createNodeCommands(clone, parentUUID.get(), position); return this; } protected  CloneNodeCommand();  CloneNodeCommand(final @MapsTo("candidate") Node candidate, final @MapsTo("parentUuid") String parentUuid);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); List<CommandResult<RuleViolation>> processChildrenNodes(GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); Node<View, Edge> getClone(); Node<Definition, Edge> getCandidate(); List<Command<GraphCommandExecutionContext, RuleViolation>> getChildrenCommands();  }