Search in sources :

Example 1 with DumpUpgradeResult

use of com.enonic.xp.dump.DumpUpgradeResult 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 DumpUpgradeResult

use of com.enonic.xp.dump.DumpUpgradeResult 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)

Example 3 with DumpUpgradeResult

use of com.enonic.xp.dump.DumpUpgradeResult 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());
    });
}
Also used : SystemDumpUpgradeParams(com.enonic.xp.dump.SystemDumpUpgradeParams) DumpUpgradeResult(com.enonic.xp.dump.DumpUpgradeResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 4 with DumpUpgradeResult

use of com.enonic.xp.dump.DumpUpgradeResult 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));
}
Also used : SystemDumpUpgradeRequestJson(com.enonic.xp.impl.server.rest.model.SystemDumpUpgradeRequestJson) Version(com.enonic.xp.util.Version) RunnableTask(com.enonic.xp.task.RunnableTask) SystemDumpUpgradeParams(com.enonic.xp.dump.SystemDumpUpgradeParams) DumpUpgradeResult(com.enonic.xp.dump.DumpUpgradeResult) Test(org.junit.jupiter.api.Test) AbstractRunnableTaskTest(com.enonic.xp.task.AbstractRunnableTaskTest)

Aggregations

DumpUpgradeResult (com.enonic.xp.dump.DumpUpgradeResult)4 SystemDumpUpgradeParams (com.enonic.xp.dump.SystemDumpUpgradeParams)4 Test (org.junit.jupiter.api.Test)3 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)2 UpgradeListener (com.enonic.xp.upgrade.UpgradeListener)2 Version (com.enonic.xp.util.Version)2 SystemDumpUpgradeRequestJson (com.enonic.xp.impl.server.rest.model.SystemDumpUpgradeRequestJson)1 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 AbstractRunnableTaskTest (com.enonic.xp.task.AbstractRunnableTaskTest)1 RunnableTask (com.enonic.xp.task.RunnableTask)1