*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_ReplaceVersion_inTimeBounds() {
Clock origClock = _exgMaster.getClock();
try {
Instant now = Instant.now();
ObjectId baseOid = setupTestData(now);
_exgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
ExchangeDocument latestDoc = _exgMaster.get(baseOid, VersionCorrection.LATEST);
assertNotNull(latestDoc);
final ExternalIdBundle bundle = ExternalIdBundle.of("B", "B0");
final ExternalIdBundle region = ExternalIdBundle.of("R", "R0");
List<ExchangeDocument> replacement = newArrayList();
for (int i = 1; i <= 3; i++) {
ManageableExchange ex = new ManageableExchange(bundle, "replace_" + i, region, null);
ExchangeDocument doc = new ExchangeDocument(ex);
doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 10, SECONDS));
replacement.add(doc);
}
replacement.get(replacement.size() - 1).setVersionToInstant(now.plus(1, MINUTES).plus(40, SECONDS));
ExchangeHistoryRequest historyRequest = new ExchangeHistoryRequest();
historyRequest.setObjectId(baseOid);
historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
ExchangeHistoryResult result = _exgMaster.history(historyRequest);
List<ExchangeDocument> exchanges = result.getDocuments();
ExchangeDocument secondVersionDoc = exchanges.get(exchanges.size() - 2);