use of com.enonic.xp.dump.SystemDumpUpgradeParams in project xp by enonic.
the class UpgradeRunnableTask method run.
@Override
public void run(final TaskId id, final ProgressReporter progressReporter) {
final UpgradeListener upgradeListener = new UpgradeListenerImpl(progressReporter);
final SystemDumpUpgradeParams upgradeParams = SystemDumpUpgradeParams.create().dumpName(params.getName()).upgradeListener(upgradeListener).build();
final DumpUpgradeResult result = this.dumpService.upgrade(upgradeParams);
upgradeListener.finished();
progressReporter.info(SystemDumpUpgradeResultJson.from(result).toString());
}
use of com.enonic.xp.dump.SystemDumpUpgradeParams 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.dump.SystemDumpUpgradeParams in project xp by enonic.
the class DumpServiceImplTest method upgrade_up_to_date.
@Test
public void upgrade_up_to_date() {
NodeHelper.runAsAdmin(() -> {
doDump(SystemDumpParams.create().dumpName("testDump").build());
final SystemDumpUpgradeParams params = SystemDumpUpgradeParams.create().dumpName("testDump").build();
final DumpUpgradeResult result = this.dumpService.upgrade(params);
assertEquals(DumpConstants.MODEL_VERSION, result.getInitialVersion());
assertEquals(DumpConstants.MODEL_VERSION, result.getUpgradedVersion());
});
}
Aggregations