@@ -275,4 +275,64 @@ public void testCannotConnectIncompatibleTypes() {
275275
276276 assertFalse ("Should not be able to connect incompatible types" , pipeline .canConnect ((OutputSocket ) b , (InputSocket ) a ));
277277 }
278+
279+ @ Test
280+ public void testAddBetweenSteps () {
281+ final Step
282+ stepToAdd = new MockStep (),
283+ lowerStep = new MockStep (),
284+ upperStep = new MockStep ();
285+ pipeline .addStep (lowerStep );
286+ pipeline .addStep (upperStep );
287+
288+ pipeline .addStepBetween (stepToAdd , lowerStep , upperStep );
289+ assertEquals ("The step was not added to the middle of the pipeline" ,
290+ Arrays .asList (lowerStep , stepToAdd , upperStep ), pipeline .getSteps ());
291+ }
292+
293+ @ Test
294+ public void testAddBetweenNullAndStep () {
295+ final Step
296+ stepToAdd = new MockStep (),
297+ lowerStep = new MockStep (),
298+ upperStep = new MockStep ();
299+ pipeline .addStep (lowerStep );
300+ pipeline .addStep (upperStep );
301+ pipeline .addStepBetween (stepToAdd , null , lowerStep );
302+ assertEquals ("The step was not added to the begining of the pipeline" ,
303+ Arrays .asList (stepToAdd , lowerStep , upperStep ), pipeline .getSteps ());
304+ }
305+
306+ @ Test
307+ public void testAddBetweenStepAndNull () {
308+ final Step
309+ stepToAdd = new MockStep (),
310+ lowerStep = new MockStep (),
311+ upperStep = new MockStep ();
312+ pipeline .addStep (lowerStep );
313+ pipeline .addStep (upperStep );
314+ pipeline .addStepBetween (stepToAdd , upperStep , null );
315+ assertEquals ("The step was not added to the end of the pipeline" ,
316+ Arrays .asList (lowerStep , upperStep , stepToAdd ), pipeline .getSteps ());
317+ }
318+
319+ @ Test
320+ public void testAddBetweenTwoNulls () {
321+ final Step stepToAdd = new MockStep ();
322+ pipeline .addStepBetween (stepToAdd , null , null );
323+ assertEquals ("The step should have been added to the pipeline" ,
324+ Collections .singletonList (stepToAdd ), pipeline .getSteps ());
325+ }
326+
327+ @ Test (expected = AssertionError .class )
328+ public void testAddBetweenStepsOutOfOrder () {
329+ final Step
330+ stepToAdd = new MockStep (),
331+ lowerStep = new MockStep (),
332+ upperStep = new MockStep ();
333+ pipeline .addStep (lowerStep );
334+ pipeline .addStep (upperStep );
335+
336+ pipeline .addStepBetween (stepToAdd , upperStep , lowerStep );
337+ }
278338}
0 commit comments