@Test @SuppressWarnings("unchecked") public void testExecute() { final CommandResult<CanvasViolation> result = tested.execute(canvasHandler); assertNotEquals(CommandResult.Type.ERROR, result.getType()); verify(canvasHandler, times(0)).register(anyString(), eq(candidate)); verify(canvasHandler, times(0)).addChild(any(Node.class), any(Node.class)); verify(canvasHandler, times(1)).undock(eq(parent), eq(candidate)); verify(canvasHandler, times(1)).applyElementMutation(eq(candidate), any(MutationContext.class)); verify(canvasHandler, times(1)).applyElementMutation(eq(parent), any(MutationContext.class)); }
@Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { if (Objects.isNull(parent) || Objects.isNull(child)) { throw new IllegalArgumentException("Parent and child should not be null"); } context.undock(parent, child); getChild().getInEdges().stream() .filter(e -> e.getContent() instanceof Child) .findAny() .ifPresent(e -> context.addChild(e.getSourceNode(), child)); if (existNode(parent, context)) { context.applyElementMutation(parent, MutationContext.STATIC); } if (existNode(child, context)) { context.applyElementMutation(child, MutationContext.STATIC); } return buildResult(); }
CanvasUndockNodeCommand extends AbstractCanvasCommand { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { if (Objects.isNull(parent) || Objects.isNull(child)) { throw new IllegalArgumentException("Parent and child should not be null"); } context.undock(parent, child); getChild().getInEdges().stream() .filter(e -> e.getContent() instanceof Child) .findAny() .ifPresent(e -> context.addChild(e.getSourceNode(), child)); if (existNode(parent, context)) { context.applyElementMutation(parent, MutationContext.STATIC); } if (existNode(child, context)) { context.applyElementMutation(child, MutationContext.STATIC); } return buildResult(); } }
CanvasUndockNodeCommand extends AbstractCanvasCommand { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { if (Objects.isNull(parent) || Objects.isNull(child)) { throw new IllegalArgumentException("Parent and child should not be null"); } context.undock(parent, child); getChild().getInEdges().stream() .filter(e -> e.getContent() instanceof Child) .findAny() .ifPresent(e -> context.addChild(e.getSourceNode(), child)); if (existNode(parent, context)) { context.applyElementMutation(parent, MutationContext.STATIC); } if (existNode(child, context)) { context.applyElementMutation(child, MutationContext.STATIC); } return buildResult(); } CanvasUndockNodeCommand(final Node parent,
                                   final Node child); }
CanvasUndockNodeCommand extends AbstractCanvasCommand { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { if (Objects.isNull(parent) || Objects.isNull(child)) { throw new IllegalArgumentException("Parent and child should not be null"); } context.undock(parent, child); getChild().getInEdges().stream() .filter(e -> e.getContent() instanceof Child) .findAny() .ifPresent(e -> context.addChild(e.getSourceNode(), child)); if (existNode(parent, context)) { context.applyElementMutation(parent, MutationContext.STATIC); } if (existNode(child, context)) { context.applyElementMutation(child, MutationContext.STATIC); } return buildResult(); } CanvasUndockNodeCommand(final Node parent,
                                   final Node child); @Override CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); Node getParent(); Node<?, Edge> getChild(); @Override String toString(); }
CanvasUndockNodeCommand extends AbstractCanvasCommand { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { if (Objects.isNull(parent) || Objects.isNull(child)) { throw new IllegalArgumentException("Parent and child should not be null"); } context.undock(parent, child); getChild().getInEdges().stream() .filter(e -> e.getContent() instanceof Child) .findAny() .ifPresent(e -> context.addChild(e.getSourceNode(), child)); if (existNode(parent, context)) { context.applyElementMutation(parent, MutationContext.STATIC); } if (existNode(child, context)) { context.applyElementMutation(child, MutationContext.STATIC); } return buildResult(); } CanvasUndockNodeCommand(final Node parent,
                                   final Node child); @Override CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); Node getParent(); Node<?, Edge> getChild(); @Override String toString();  }