use of com.enonic.xp.util.Version in project xp by enonic.
the class DumpServiceImplTest method upgrade.
@Test
public void upgrade() throws Exception {
final String dumpName = "testDump";
createIncompatibleDump(dumpName);
NodeHelper.runAsAdmin(() -> {
final UpgradeListener upgradeListener = mock(UpgradeListener.class);
final SystemDumpUpgradeParams params = SystemDumpUpgradeParams.create().dumpName(dumpName).upgradeListener(upgradeListener).build();
final DumpUpgradeResult result = this.dumpService.upgrade(params);
assertEquals(new Version(0, 0, 0), result.getInitialVersion());
assertEquals(DumpConstants.MODEL_VERSION, result.getUpgradedVersion());
Mockito.verify(upgradeListener, Mockito.times(8)).upgraded();
Mockito.verify(upgradeListener, Mockito.times(1)).total(8);
FileDumpReader reader = FileDumpReader.create(null, temporaryFolder, dumpName);
final DumpMeta updatedMeta = reader.getDumpMeta();
assertEquals(DumpConstants.MODEL_VERSION, updatedMeta.getModelVersion());
});
}
use of com.enonic.xp.util.Version in project xp by enonic.
the class DumpMetaJson method fromJson.
public static DumpMeta fromJson(final DumpMetaJson dumpMetaJson) {
final DumpMeta.Builder dumpMeta = DumpMeta.create().xpVersion(dumpMetaJson.getXpVersion()).timestamp(Instant.parse(dumpMetaJson.getTimestamp()));
if (dumpMetaJson.getResult() != null) {
SystemDumpResult.Builder systemDumpResult = SystemDumpResult.create();
dumpMetaJson.getResult().forEach((key, value) -> systemDumpResult.add(RepoDumpResultJson.fromJson(key, value)));
dumpMeta.systemDumpResult(systemDumpResult.build());
}
if (!isNullOrEmpty(dumpMetaJson.getModelVersion())) {
final Version modelVersion = Version.valueOf(dumpMetaJson.getModelVersion());
dumpMeta.modelVersion(modelVersion);
}
return dumpMeta.build();
}
use of com.enonic.xp.util.Version in project xp by enonic.
the class CommitDumpUpgrader method upgradeVersionEntry.
@Override
protected byte[] upgradeVersionEntry(final RepositoryId repositoryId, final String entryContent) {
final Pre6VersionsDumpEntryJson sourceEntry = deserializeValue(entryContent, Pre6VersionsDumpEntryJson.class);
final VersionsDumpEntryJson.Builder upgradedEntry = VersionsDumpEntryJson.create().nodeId(sourceEntry.getNodeId());
sourceEntry.getVersions().stream().map(version -> {
final boolean commit = commitedVersionIds.contains(version.getVersion());
return upgradeVersionDumpEntry(version, commit);
}).forEach(upgradedEntry::version);
return serialize(upgradedEntry.build());
}
use of com.enonic.xp.util.Version in project xp by enonic.
the class UpgradeRunnableTaskTest method upgrade.
@Test
public void upgrade() {
final DumpUpgradeResult upgradeResult = DumpUpgradeResult.create().initialVersion(Version.emptyVersion).upgradedVersion(new Version(1)).stepResult(DumpUpgradeStepResult.create().stepName("Step1").initialVersion(Version.emptyVersion).upgradedVersion(new Version(1)).build()).build();
Mockito.when(this.dumpService.upgrade(Mockito.isA(SystemDumpUpgradeParams.class))).thenReturn(upgradeResult);
final UpgradeRunnableTask task = createAndRunTask(new SystemDumpUpgradeRequestJson("dump-name"));
task.createTaskResult();
Mockito.verify(progressReporter, Mockito.times(1)).info(contentQueryArgumentCaptor.capture());
Mockito.verify(taskService, Mockito.times(1)).submitTask(Mockito.isA(RunnableTask.class), Mockito.eq("upgrade"));
final String result = contentQueryArgumentCaptor.getAllValues().get(0);
jsonTestHelper.assertJsonEquals(jsonTestHelper.loadTestJson("upgrade_result.json"), jsonTestHelper.stringToJson(result));
}
Aggregations