Search in sources :

Example 1 with SystemDumpUpgradeRequestJson

use of com.enonic.xp.impl.server.rest.model.SystemDumpUpgradeRequestJson in project xp by enonic.

the class SystemResourceTest method upgrade.

@Test
public void upgrade() throws Exception {
    Mockito.when(taskService.submitTask(Mockito.isA(UpgradeRunnableTask.class), eq("upgrade"))).thenReturn(TaskId.from("task-id"));
    final SystemDumpUpgradeRequestJson json = Mockito.mock(SystemDumpUpgradeRequestJson.class);
    final TaskResultJson result = resource.upgrade(json);
    assertEquals("task-id", result.getTaskId());
}
Also used : SystemDumpUpgradeRequestJson(com.enonic.xp.impl.server.rest.model.SystemDumpUpgradeRequestJson) UpgradeRunnableTask(com.enonic.xp.impl.server.rest.task.UpgradeRunnableTask) TaskResultJson(com.enonic.xp.task.TaskResultJson) Test(org.junit.jupiter.api.Test)

Example 2 with SystemDumpUpgradeRequestJson

use of com.enonic.xp.impl.server.rest.model.SystemDumpUpgradeRequestJson 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

SystemDumpUpgradeRequestJson (com.enonic.xp.impl.server.rest.model.SystemDumpUpgradeRequestJson)2 Test (org.junit.jupiter.api.Test)2 DumpUpgradeResult (com.enonic.xp.dump.DumpUpgradeResult)1 SystemDumpUpgradeParams (com.enonic.xp.dump.SystemDumpUpgradeParams)1 UpgradeRunnableTask (com.enonic.xp.impl.server.rest.task.UpgradeRunnableTask)1 AbstractRunnableTaskTest (com.enonic.xp.task.AbstractRunnableTaskTest)1 RunnableTask (com.enonic.xp.task.RunnableTask)1 TaskResultJson (com.enonic.xp.task.TaskResultJson)1 Version (com.enonic.xp.util.Version)1