@Test public void shouldNotChangeIndexOfAddToListIfIndexIsLesserThanOrEqualToTheIndicesOfRemoveFromListCommand() { final AddToList toRepair1 = new AddToList(SOME_LIST, SOME_CHANGE, SOME_VALUE, 5); final RemoveFromList repairAgainst1 = new RemoveFromList(SOME_LIST, SOME_CHANGE, 8, 92); final AddToList repaired1 = cut.repairCommand(toRepair1, repairAgainst1); assertThat(repaired1.getPosition()).isEqualTo(5); final AddToList toRepair2 = new AddToList(SOME_LIST, SOME_CHANGE, SOME_VALUE, 20); final RemoveFromList repairAgainst2 = new RemoveFromList(SOME_LIST, SOME_CHANGE, 20, 1); final AddToList repaired2 = cut.repairCommand(toRepair2, repairAgainst2); assertThat(repaired2.getPosition()).isEqualTo(20); }
public AddToList repairCommand(final AddToList toRepair, final RemoveFromList repairAgainst) { final int indicesBefore = toRepair.getPosition() - repairAgainst.getStartPosition(); if (indicesBefore <= 0) { return toRepair; } final int indicesToDecrese = indicesBefore < repairAgainst.getRemoveCount() ? indicesBefore : repairAgainst .getRemoveCount(); return createCommand(toRepair, toRepair.getPosition() - indicesToDecrese); }
AddToListRepairer { public AddToList repairCommand(final AddToList toRepair, final RemoveFromList repairAgainst) { final int indicesBefore = toRepair.getPosition() - repairAgainst.getStartPosition(); if (indicesBefore <= 0) { return toRepair; } final int indicesToDecrese = indicesBefore < repairAgainst.getRemoveCount() ? indicesBefore : repairAgainst .getRemoveCount(); return createCommand(toRepair, toRepair.getPosition() - indicesToDecrese); } }
AddToListRepairer { public AddToList repairCommand(final AddToList toRepair, final RemoveFromList repairAgainst) { final int indicesBefore = toRepair.getPosition() - repairAgainst.getStartPosition(); if (indicesBefore <= 0) { return toRepair; } final int indicesToDecrese = indicesBefore < repairAgainst.getRemoveCount() ? indicesBefore : repairAgainst .getRemoveCount(); return createCommand(toRepair, toRepair.getPosition() - indicesToDecrese); }  }
AddToListRepairer { public AddToList repairCommand(final AddToList toRepair, final RemoveFromList repairAgainst) { final int indicesBefore = toRepair.getPosition() - repairAgainst.getStartPosition(); if (indicesBefore <= 0) { return toRepair; } final int indicesToDecrese = indicesBefore < repairAgainst.getRemoveCount() ? indicesBefore : repairAgainst .getRemoveCount(); return createCommand(toRepair, toRepair.getPosition() - indicesToDecrese); }  AddToList repairLocalCommand(final AddToList toRepair, final AddToList repairAgainst); AddToList repairRemoteCommand(final AddToList toRepair, final AddToList repairAgainst); AddToList repairCommand(final AddToList toRepair, final RemoveFromList repairAgainst); AddToList repairCommand(final AddToList toRepair, final ReplaceInList repairAgainst); }
AddToListRepairer { public AddToList repairCommand(final AddToList toRepair, final RemoveFromList repairAgainst) { final int indicesBefore = toRepair.getPosition() - repairAgainst.getStartPosition(); if (indicesBefore <= 0) { return toRepair; } final int indicesToDecrese = indicesBefore < repairAgainst.getRemoveCount() ? indicesBefore : repairAgainst .getRemoveCount(); return createCommand(toRepair, toRepair.getPosition() - indicesToDecrese); }  AddToList repairLocalCommand(final AddToList toRepair, final AddToList repairAgainst); AddToList repairRemoteCommand(final AddToList toRepair, final AddToList repairAgainst); AddToList repairCommand(final AddToList toRepair, final RemoveFromList repairAgainst); AddToList repairCommand(final AddToList toRepair, final ReplaceInList repairAgainst);  }