@Test public void shouldNotChangeIndexOfAddToListIfIndexIsLesserThanToTheIndicesOfRemoveFromListCommand() { final ReplaceInList toRepair1 = new ReplaceInList(SOME_LIST, SOME_CHANGE, SOME_VALUE, 5); final RemoveFromList repairAgainst1 = new RemoveFromList(SOME_LIST, SOME_CHANGE, 8, 92); final ListCommand repaired1 = cut.repairCommand(toRepair1, repairAgainst1); assertThat(repaired1).isInstanceOf(ReplaceInList.class); assertThat(((ReplaceInList) repaired1).getPosition()).isEqualTo(5); }
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);  }