Pipeline implements ConnectionValidator, SettingsProvider, StepIndexer { public synchronized void moveStep(Step step, int delta) { checkNotNull(step, "The step can not be null"); checkArgument(this.steps.contains(step), "The step must exist in the pipeline to be moved"); writeStepsSafelyConsume(steps -> { final int oldIndex = this.steps.indexOf(step); this.steps.remove(oldIndex); final int newIndex = Math.min(Math.max(oldIndex + delta, 0), this.steps.size()); this.steps.add(newIndex, step); }); eventBus.post(new StepMovedEvent(step, delta)); }  void clear(); final ImmutableList<Source> getSources(); final ImmutableList<Step> getSteps(); Set<Connection> getConnections(); @Override ProjectSettings getProjectSettings(); @Override AppSettings getAppSettings(); @Override CodeGenerationSettings getCodeGenerationSettings(); @SuppressWarnings("unchecked") @Override boolean canConnect(OutputSocket<?> outputSocket, InputSocket<?> inputSocket); @Subscribe void onSourceAdded(SourceAddedEvent event); @Subscribe void onSourceRemoved(SourceRemovedEvent event); void addStepBetween(Step stepToAdd, @Nullable Step lower, @Nullable Step higher); void moveStepBetween(Step toMove, @Nullable Step lower, @Nullable Step higher); void addStep(int index, Step step); void addStep(Step step); void removeStep(Step step); synchronized void moveStep(Step step, int delta); @Override int indexOf(Step step); @Subscribe void onConnectionAdded(ConnectionAddedEvent event); @Subscribe void onConnectionRemoved(ConnectionRemovedEvent event); @Subscribe void onProjectSettingsChanged(ProjectSettingsChangedEvent event); @Subscribe void onAppSettingsChanged(AppSettingsChangedEvent event); @Subscribe void onCodeGenerationSettingsChanged(CodeGenerationSettingsChangedEvent event);  }
@Test public void testMoveStep() { Step step1 = new MockStep(); Step step2 = new MockStep(); Step step3 = new MockStep(); pipeline.addStep(step1); pipeline.addStep(step2); pipeline.addStep(step3); pipeline.moveStep(step1, +1); assertEquals("The step order did not change as expected", Arrays.asList(step2, step1, step3), pipeline.getSteps()); }