@Test public void testDeleteControlPointAt1() { tested = new DeleteControlPointCommand(EDGE_UUID, 1); CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext); ArgumentCaptor<ControlPoint[]> pointsCaptor = ArgumentCaptor.forClass(ControlPoint[].class); assertFalse(CommandUtils.isError(result)); verify(viewConnector, times(1)).setControlPoints(pointsCaptor.capture()); ControlPoint[] controlPoints = pointsCaptor.getValue(); assertNotNull(controlPoints); assertEquals(2, controlPoints.length); assertEquals(controlPoint1, controlPoints[0]); assertEquals(controlPoint3, controlPoints[1]); }
@Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { check(context); final HasControlPoints edgeControlPoints = getEdgeControlPoints(context); final int size = edgeControlPoints.getControlPoints().length; final ControlPoint[] cps = new ControlPoint[size - 1]; for (int i = 0, j = 0; i < size; i++, j++) { ControlPoint controlPoint = edgeControlPoints.getControlPoints()[i]; if (i == index) { j--; deletedControlPoint = controlPoint; } else { cps[j] = controlPoint; } } edgeControlPoints.setControlPoints(cps); return GraphCommandResultBuilder.SUCCESS; }
DeleteControlPointCommand extends AbstractControlPointCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { check(context); final HasControlPoints edgeControlPoints = getEdgeControlPoints(context); final int size = edgeControlPoints.getControlPoints().length; final ControlPoint[] cps = new ControlPoint[size - 1]; for (int i = 0, j = 0; i < size; i++, j++) { ControlPoint controlPoint = edgeControlPoints.getControlPoints()[i]; if (i == index) { j--; deletedControlPoint = controlPoint; } else { cps[j] = controlPoint; } } edgeControlPoints.setControlPoints(cps); return GraphCommandResultBuilder.SUCCESS; } }
DeleteControlPointCommand extends AbstractControlPointCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { check(context); final HasControlPoints edgeControlPoints = getEdgeControlPoints(context); final int size = edgeControlPoints.getControlPoints().length; final ControlPoint[] cps = new ControlPoint[size - 1]; for (int i = 0, j = 0; i < size; i++, j++) { ControlPoint controlPoint = edgeControlPoints.getControlPoints()[i]; if (i == index) { j--; deletedControlPoint = controlPoint; } else { cps[j] = controlPoint; } } edgeControlPoints.setControlPoints(cps); return GraphCommandResultBuilder.SUCCESS; } DeleteControlPointCommand(final @MapsTo("edgeUUID") String edgeUUID,
                                     final @MapsTo("index") int index); }
DeleteControlPointCommand extends AbstractControlPointCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { check(context); final HasControlPoints edgeControlPoints = getEdgeControlPoints(context); final int size = edgeControlPoints.getControlPoints().length; final ControlPoint[] cps = new ControlPoint[size - 1]; for (int i = 0, j = 0; i < size; i++, j++) { ControlPoint controlPoint = edgeControlPoints.getControlPoints()[i]; if (i == index) { j--; deletedControlPoint = controlPoint; } else { cps[j] = controlPoint; } } edgeControlPoints.setControlPoints(cps); return GraphCommandResultBuilder.SUCCESS; } DeleteControlPointCommand(final @MapsTo("edgeUUID") String edgeUUID,
                                     final @MapsTo("index") int index); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); }
DeleteControlPointCommand extends AbstractControlPointCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { check(context); final HasControlPoints edgeControlPoints = getEdgeControlPoints(context); final int size = edgeControlPoints.getControlPoints().length; final ControlPoint[] cps = new ControlPoint[size - 1]; for (int i = 0, j = 0; i < size; i++, j++) { ControlPoint controlPoint = edgeControlPoints.getControlPoints()[i]; if (i == index) { j--; deletedControlPoint = controlPoint; } else { cps[j] = controlPoint; } } edgeControlPoints.setControlPoints(cps); return GraphCommandResultBuilder.SUCCESS; } DeleteControlPointCommand(final @MapsTo("edgeUUID") String edgeUUID,
                                     final @MapsTo("index") int index); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context);  }