@Test public void shouldIncreaseIndexIfIndexOfAddToListIsLessOrEqual() { final ReplaceInList toRepair1 = new ReplaceInList(SOME_LIST, SOME_CHANGE, SOME_VALUE, 6); final AddToList repairAgainst1 = new AddToList(SOME_LIST, SOME_CHANGE, SOME_VALUE, 3); final ReplaceInList repaired1 = cut.repairCommand(toRepair1, repairAgainst1); assertThat(repaired1.getPosition()).isEqualTo(7); final ReplaceInList toRepair2 = new ReplaceInList(SOME_LIST, SOME_CHANGE, SOME_VALUE, 9); final AddToList repairAgainst2 = new AddToList(SOME_LIST, SOME_CHANGE, SOME_VALUE, 9); final ReplaceInList repaired2 = cut.repairCommand(toRepair2, repairAgainst2); assertThat(repaired2.getPosition()).isEqualTo(10); }
public ReplaceInList repairCommand(final ReplaceInList toRepair, final AddToList repairAgainst) { if (repairAgainst.getPosition() > toRepair.getPosition()) { return toRepair; } return new ReplaceInList(toRepair.getListId(), toRepair.getListVersionChange(), toRepair.getValue(), toRepair.getPosition() + 1); }
ReplaceInListRepairer { public ReplaceInList repairCommand(final ReplaceInList toRepair, final AddToList repairAgainst) { if (repairAgainst.getPosition() > toRepair.getPosition()) { return toRepair; } return new ReplaceInList(toRepair.getListId(), toRepair.getListVersionChange(), toRepair.getValue(), toRepair.getPosition() + 1); } }
ReplaceInListRepairer { public ReplaceInList repairCommand(final ReplaceInList toRepair, final AddToList repairAgainst) { if (repairAgainst.getPosition() > toRepair.getPosition()) { return toRepair; } return new ReplaceInList(toRepair.getListId(), toRepair.getListVersionChange(), toRepair.getValue(), toRepair.getPosition() + 1); }  }
ReplaceInListRepairer { public ReplaceInList repairCommand(final ReplaceInList toRepair, final AddToList repairAgainst) { if (repairAgainst.getPosition() > toRepair.getPosition()) { return toRepair; } return new ReplaceInList(toRepair.getListId(), toRepair.getListVersionChange(), toRepair.getValue(), toRepair.getPosition() + 1); }  ReplaceInList repairCommand(final ReplaceInList toRepair, final AddToList repairAgainst); ListCommand repairCommand(final ReplaceInList toRepair, final RemoveFromList repairAgainst); Optional<ReplaceInList> repairLocalCommand(final ReplaceInList toRepair, final ReplaceInList repairAgainst); ReplaceInList repairRemoteCommand(final ReplaceInList toRepair, final ReplaceInList repairAgainst); }
ReplaceInListRepairer { public ReplaceInList repairCommand(final ReplaceInList toRepair, final AddToList repairAgainst) { if (repairAgainst.getPosition() > toRepair.getPosition()) { return toRepair; } return new ReplaceInList(toRepair.getListId(), toRepair.getListVersionChange(), toRepair.getValue(), toRepair.getPosition() + 1); }  ReplaceInList repairCommand(final ReplaceInList toRepair, final AddToList repairAgainst); ListCommand repairCommand(final ReplaceInList toRepair, final RemoveFromList repairAgainst); Optional<ReplaceInList> repairLocalCommand(final ReplaceInList toRepair, final ReplaceInList repairAgainst); ReplaceInList repairRemoteCommand(final ReplaceInList toRepair, final ReplaceInList repairAgainst);  }