public static void verifySameIndexContents(Repository local, Repository remote,
IndexInfo indexInfo, Optional<String> localRef, Optional<String> remoteRef) {
Set<IndexTreeMapping> remoteIndexMappings = getIndexMappings(indexInfo, remote, remoteRef);
Set<IndexTreeMapping> localIndexMappings = getIndexMappings(indexInfo, local, localRef);
Map<ObjectId, ObjectId> remoteByCanonical = remoteIndexMappings.stream()
.collect(Collectors.toMap(m -> m.featureTree, m -> m.indexTree));
Map<ObjectId, ObjectId> localByCanonical = localIndexMappings.stream()
.collect(Collectors.toMap(m -> m.featureTree, m -> m.indexTree));
assertEquals(remoteByCanonical.size(), localByCanonical.size());
assertEquals(remoteByCanonical, localByCanonical);
localByCanonical.forEach((canonicalId, indexId) -> {
Set<RevTree> allRemoteIndexContents = RevObjectTestSupport
.getAllTrees(remote.indexDatabase(), indexId);
Set<RevTree> allLocalIndexContents = RevObjectTestSupport
.getAllTrees(local.indexDatabase(), indexId);
assertEquals(allRemoteIndexContents.size(), allLocalIndexContents.size());
if (!allRemoteIndexContents.equals(allLocalIndexContents)) {
System.err.println("wtf: " + allRemoteIndexContents.equals(allLocalIndexContents));
}
assertEquals(allRemoteIndexContents, allLocalIndexContents);
});
log.info("Index {} cloned correctly", indexInfo);
}