@Test public void canRepairRemoteRemoveFromListCommands() { final RemoveFromList remote = mock(RemoveFromList.class); final RemoveFromList repairedRemote = mock(RemoveFromList.class); final RemoveFromList local = mock(RemoveFromList.class); final RemoveFromList repairedLocal = mock(RemoveFromList.class); final Queue<ListCommand> localQueue = queue(local); when(removeFromListRepairer.repairCommand(remote, local)).thenReturn(asList(repairedRemote)); when(removeFromListRepairer.repairCommand(local, remote)).thenReturn(asList(repairedLocal)); final List<? extends ListCommand> repairCommands = cut.repairCommands(localQueue, remote); assertThat(repairCommands).hasSize(1); assertThat(repairCommands.get(0)).isSameAs(repairedRemote); assertThat(localQueue).containsExactly(repairedLocal); }
public List<? extends ListCommand> repairCommands(final Queue<ListCommand> localCommands, final ListCommand remoteCommand) { this.localCommands = localCommands; if (remoteCommand instanceof AddToList) { return repairCommands((AddToList) remoteCommand); } else if (remoteCommand instanceof RemoveFromList) { return repairCommands((RemoveFromList) remoteCommand); } else if (remoteCommand instanceof ReplaceInList) { return repairCommands((ReplaceInList) remoteCommand); } else { throw failUnknownTyp(remoteCommand); } }
ListCommandIndexRepairer { public List<? extends ListCommand> repairCommands(final Queue<ListCommand> localCommands, final ListCommand remoteCommand) { this.localCommands = localCommands; if (remoteCommand instanceof AddToList) { return repairCommands((AddToList) remoteCommand); } else if (remoteCommand instanceof RemoveFromList) { return repairCommands((RemoveFromList) remoteCommand); } else if (remoteCommand instanceof ReplaceInList) { return repairCommands((ReplaceInList) remoteCommand); } else { throw failUnknownTyp(remoteCommand); } } }
ListCommandIndexRepairer { public List<? extends ListCommand> repairCommands(final Queue<ListCommand> localCommands, final ListCommand remoteCommand) { this.localCommands = localCommands; if (remoteCommand instanceof AddToList) { return repairCommands((AddToList) remoteCommand); } else if (remoteCommand instanceof RemoveFromList) { return repairCommands((RemoveFromList) remoteCommand); } else if (remoteCommand instanceof ReplaceInList) { return repairCommands((ReplaceInList) remoteCommand); } else { throw failUnknownTyp(remoteCommand); } } ListCommandIndexRepairer(final AddToListRepairer addToListRepairer,
            final RemoveFromListRepairer removeFromListRepairer, final ReplaceInListRepairer replaceInListRepairer); }
ListCommandIndexRepairer { public List<? extends ListCommand> repairCommands(final Queue<ListCommand> localCommands, final ListCommand remoteCommand) { this.localCommands = localCommands; if (remoteCommand instanceof AddToList) { return repairCommands((AddToList) remoteCommand); } else if (remoteCommand instanceof RemoveFromList) { return repairCommands((RemoveFromList) remoteCommand); } else if (remoteCommand instanceof ReplaceInList) { return repairCommands((ReplaceInList) remoteCommand); } else { throw failUnknownTyp(remoteCommand); } } ListCommandIndexRepairer(final AddToListRepairer addToListRepairer,
            final RemoveFromListRepairer removeFromListRepairer, final ReplaceInListRepairer replaceInListRepairer); List<? extends ListCommand> repairCommands(final Queue<ListCommand> localCommands,
            final ListCommand remoteCommand); }
ListCommandIndexRepairer { public List<? extends ListCommand> repairCommands(final Queue<ListCommand> localCommands, final ListCommand remoteCommand) { this.localCommands = localCommands; if (remoteCommand instanceof AddToList) { return repairCommands((AddToList) remoteCommand); } else if (remoteCommand instanceof RemoveFromList) { return repairCommands((RemoveFromList) remoteCommand); } else if (remoteCommand instanceof ReplaceInList) { return repairCommands((ReplaceInList) remoteCommand); } else { throw failUnknownTyp(remoteCommand); } } ListCommandIndexRepairer(final AddToListRepairer addToListRepairer,
            final RemoveFromListRepairer removeFromListRepairer, final ReplaceInListRepairer replaceInListRepairer); List<? extends ListCommand> repairCommands(final Queue<ListCommand> localCommands,
            final ListCommand remoteCommand);  }