### Question:
SyncService { Set<Integer> calculateAncestorNrs(Snapshot snapshot, VersionHistory versionHistory, TreeSet<Integer> availableCloneSources) { Set<Integer> result = new HashSet<>(); TreeMap<Integer, HistoryNode> nodes = versionHistory.calculateNodes(); HistoryNode node = nodes.get(snapshot.nr); fillAvailableAncestors(node, result, availableCloneSources); return result; }  StreamState calculateStreamState(Stream stream, boolean isNew); List<SendFileSpec> determineSendFiles(Stream sourceStream,
            StreamState stateOfTarget);  }### Answer:
@Test public void testCalculateAncestorNrs() throws Exception { Snapshot snapshot = new Snapshot(3, null, null); VersionHistory versionHistory = new VersionHistory(); UUID id = UUID.randomUUID(); TreeSet<Integer> available = new TreeSet<>(); versionHistory.addVersion(id); versionHistory.addVersion(id); versionHistory.addRestore(id, 0); versionHistory.addVersion(id); available.add(0); available.add(2); snapshot.nr = 0; Set<Integer> ancestors = service.calculateAncestorNrs(snapshot, versionHistory, available); assertThat(ancestors, empty()); snapshot.nr = 1; ancestors = service.calculateAncestorNrs(snapshot, versionHistory, available); assertThat(ancestors, hasSize(1)); assertThat(ancestors, hasItem(0)); snapshot.nr = 2; ancestors = service.calculateAncestorNrs(snapshot, versionHistory, available); assertThat(ancestors, hasSize(1)); assertThat(ancestors, hasItem(0)); }