@Test(expectedExceptions = IllegalArgumentException.class)
public void test_ReplaceVersion_which_is_not_in_the_time_bounds_of_the_replaced_doc() {
Clock origClock = _cfgMaster.getClock();
try {
Instant now = Instant.now();
ObjectId baseOid = setupTestData(now);
_cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
ConfigHistoryRequest<String> historyRequest = new ConfigHistoryRequest<String>();
historyRequest.setObjectId(baseOid);
historyRequest.setCorrectionsToInstant(null);
ConfigHistoryResult<String> result = _cfgMaster.history(historyRequest);
List<ConfigDocument> confDocs = result.getDocuments();
ConfigDocument lastButOneDoc = confDocs.get(confDocs.size() - 3);
Instant lastButOneDocVersionFrom = lastButOneDoc.getVersionFromInstant();
List<ConfigDocument> replacement = newArrayList();
for (int i = 1; i <= 10; i++) {
String val = "test" + i;
ConfigDocument doc = new ConfigDocument(ConfigItem.of(val));
doc.setVersionFromInstant(lastButOneDocVersionFrom.plus(i, MINUTES));
replacement.add(doc);
}
_cfgMaster.replaceVersion(lastButOneDoc.getUniqueId(), replacement);