Search in sources :

Example 1 with UpgradeListener

use of com.enonic.xp.upgrade.UpgradeListener 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());
}
Also used : UpgradeListener(com.enonic.xp.upgrade.UpgradeListener) UpgradeListenerImpl(com.enonic.xp.impl.server.rest.task.listener.UpgradeListenerImpl) SystemDumpUpgradeParams(com.enonic.xp.dump.SystemDumpUpgradeParams) DumpUpgradeResult(com.enonic.xp.dump.DumpUpgradeResult)

Example 2 with UpgradeListener

use of com.enonic.xp.upgrade.UpgradeListener 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());
    });
}
Also used : DumpMeta(com.enonic.xp.repo.impl.dump.model.DumpMeta) UpgradeListener(com.enonic.xp.upgrade.UpgradeListener) Version(com.enonic.xp.util.Version) NodeVersion(com.enonic.xp.node.NodeVersion) SystemDumpUpgradeParams(com.enonic.xp.dump.SystemDumpUpgradeParams) DumpUpgradeResult(com.enonic.xp.dump.DumpUpgradeResult) FileDumpReader(com.enonic.xp.repo.impl.dump.reader.FileDumpReader) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

DumpUpgradeResult (com.enonic.xp.dump.DumpUpgradeResult)2 SystemDumpUpgradeParams (com.enonic.xp.dump.SystemDumpUpgradeParams)2 UpgradeListener (com.enonic.xp.upgrade.UpgradeListener)2 UpgradeListenerImpl (com.enonic.xp.impl.server.rest.task.listener.UpgradeListenerImpl)1 NodeVersion (com.enonic.xp.node.NodeVersion)1 DumpMeta (com.enonic.xp.repo.impl.dump.model.DumpMeta)1 FileDumpReader (com.enonic.xp.repo.impl.dump.reader.FileDumpReader)1 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)1 Version (com.enonic.xp.util.Version)1 Test (org.junit.jupiter.api.Test)1