*
*/
public void test_ReplaceAllVersions1() {
Clock origClock = _cfgMaster.getClock();
try {
Instant now = Instant.now();
ObjectId baseOid = setupTestData(now);
_cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
ConfigDocument latestDoc = _cfgMaster.get(baseOid, VersionCorrection.LATEST);
List<ConfigDocument> replacement = newArrayList();
for (int i = 1; i <= 4; i++) {
String val = "replace_" + i;
ConfigDocument doc = new ConfigDocument(ConfigItem.of(val, "some_name_"+i));
doc.setVersionFromInstant(now.plus(2, MINUTES).plus(i * 20, SECONDS));
replacement.add(doc);
}
_cfgMaster.replaceAllVersions(latestDoc, replacement);
ConfigHistoryRequest<String> historyRequest = new ConfigHistoryRequest<String>();
historyRequest.setObjectId(baseOid);
historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
ConfigHistoryResult<String> result = _cfgMaster.history(historyRequest);
List<ConfigDocument> values = result.getDocuments();
assertEquals(4, values.size());
assertEquals(now.plus(2, MINUTES).plus(20, SECONDS), values.get(3).getVersionFromInstant());
assertEquals(now.plus(2, MINUTES).plus(40, SECONDS), values.get(3).getVersionToInstant());
//
assertEquals(now.plus(2, MINUTES).plus(40, SECONDS), values.get(2).getVersionFromInstant());
assertEquals(now.plus(3, MINUTES).plus(0, SECONDS), values.get(2).getVersionToInstant());
//
assertEquals(now.plus(3, MINUTES).plus(0, SECONDS), values.get(1).getVersionFromInstant());
assertEquals(now.plus(3, MINUTES).plus(20, SECONDS), values.get(1).getVersionToInstant());
//
assertEquals(now.plus(3, MINUTES).plus(20, SECONDS), values.get(0).getVersionFromInstant());
assertEquals(null, values.get(0).getVersionToInstant());
//
} finally {
_cfgMaster.setClock(origClock);
}