### Question:
FieldConstraintArrayUtil { public static void moveDown(int index, FieldConstraint[] fieldConstraints) { if (index < (fieldConstraints.length - 1)) { final FieldConstraint first = fieldConstraints[index]; final FieldConstraint second = fieldConstraints[index + 1]; if (blockSwap(first, second)) { return; } fieldConstraints[index] = second; fieldConstraints[index + 1] = first; } } private  FieldConstraintArrayUtil(); static void moveDown(int index, FieldConstraint[] fieldConstraints); static void moveUp(int index, FieldConstraint[] fieldConstraints);  }### Answer:
@Test public void down() { final FieldConstraint[] fieldConstraints = new FieldConstraint[2]; final FieldConstraint top = mock(FieldConstraint.class); fieldConstraints[0] = top; fieldConstraints[1] = mock(FieldConstraint.class); FieldConstraintArrayUtil.moveDown(0, fieldConstraints); assertEquals(top, fieldConstraints[1]); }
@Test public void downWhenAlreadyBottom() { final FieldConstraint[] fieldConstraints = new FieldConstraint[2]; fieldConstraints[0] = mock(FieldConstraint.class); final FieldConstraint bottom = mock(FieldConstraint.class); fieldConstraints[1] = bottom; FieldConstraintArrayUtil.moveDown(1, fieldConstraints); assertEquals(bottom, fieldConstraints[1]); }
@Test public void shouldNotMoveLowerThanUsedVariables() { final FieldConstraint[] fieldConstraints = new FieldConstraint[2]; final SingleFieldConstraint top = new SingleFieldConstraint(); top.setFieldBinding("a"); fieldConstraints[0] = top; final SingleFieldConstraint bottom = new SingleFieldConstraint(); bottom.setConstraintValueType(BaseSingleFieldConstraint.TYPE_VARIABLE); bottom.setValue("a"); fieldConstraints[1] = bottom; FieldConstraintArrayUtil.moveDown(0, fieldConstraints); assertEquals(top, fieldConstraints[0]); assertEquals(bottom, fieldConstraints[1]); }
@Test public void shouldNotMoveLowerThanUsedVariables_MoveToMiddle() { final FieldConstraint[] fieldConstraints = new FieldConstraint[3]; final SingleFieldConstraint top = new SingleFieldConstraint(); top.setFieldBinding("a"); fieldConstraints[0] = top; final SingleFieldConstraint middle = new SingleFieldConstraint(); middle.setConstraintValueType(BaseSingleFieldConstraint.TYPE_VARIABLE); middle.setValue("a"); fieldConstraints[1] = middle; final SingleFieldConstraint bottom = new SingleFieldConstraint(); bottom.setConstraintValueType(BaseSingleFieldConstraint.TYPE_VARIABLE); bottom.setValue("b"); fieldConstraints[2] = bottom; FieldConstraintArrayUtil.moveDown(0, fieldConstraints); FieldConstraintArrayUtil.moveDown(1, fieldConstraints); assertEquals(top, fieldConstraints[0]); assertEquals(bottom, fieldConstraints[1]); assertEquals(middle, fieldConstraints[2]); }