try {
Instant now = Instant.now();
ObjectId baseOid = setupTestData(now);
_cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
@SuppressWarnings("unused")
ConfigDocument latestDoc = _cfgMaster.get(baseOid, VersionCorrection.LATEST);
List<ConfigDocument> replacement = newArrayList();
for (int i = 1; i <= 3; i++) {
String val = "replace_" + i;
ConfigDocument doc = new ConfigDocument(ConfigItem.of(val));
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));
ConfigHistoryRequest<String> historyRequest = new ConfigHistoryRequest<String>();
historyRequest.setObjectId(baseOid);
historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
ConfigHistoryResult<String> result = _cfgMaster.history(historyRequest);
List<ConfigDocument> confDocs = result.getDocuments();
ConfigDocument secondVersionDoc = confDocs.get(confDocs.size() - 2);
_cfgMaster.replaceVersion(secondVersionDoc.getUniqueId(), replacement);
} finally {
_cfgMaster.setClock(origClock);
}
}