final ExternalIdBundle bundle = ExternalIdBundle.of("B", "B0");
final ExternalIdBundle region = ExternalIdBundle.of("R", "R0");
List<ExchangeDocument> replacement = newArrayList();
for (int i = 0; i <= 10; i++) {
ManageableExchange ex = new ManageableExchange(bundle, "test" + i, region, null);
ExchangeDocument doc = new ExchangeDocument(ex);
doc.setVersionFromInstant(latestFrom.plus(i, MINUTES));
replacement.add(doc);
}
_exgMaster.replaceVersion(latestDoc.getUniqueId(), replacement);
ExchangeSearchRequest searchRequest = new ExchangeSearchRequest();
searchRequest.addExternalIds(bundle.getExternalIds());
searchRequest.setVersionCorrection(VersionCorrection.LATEST);
ExchangeSearchResult result = _exgMaster.search(searchRequest);
List<ManageableExchange> exchanges = result.getExchanges();
assertEquals(1, exchanges.size());
ManageableExchange ex = exchanges.get(0);
assertEquals("test10", ex.getName());
} finally {
_exgMaster.setClock(origClock);
}
}