Search in sources :

Example 1 with SystemDumpRequestJson

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

the class DumpRunnableTaskTest method dump.

@Test
public void dump() {
    final SystemDumpResult systemDumpResult = SystemDumpResult.create().add(RepoDumpResult.create(RepositoryId.from("my-repo")).versions(3L).add(BranchDumpResult.create(Branch.create().value("branch-value").build()).addedNodes(3).error(DumpError.error("error-message")).build()).build()).build();
    final SystemDumpParams params = SystemDumpParams.create().dumpName("dump").includeBinaries(true).includeVersions(true).maxAge(10).maxVersions(20).listener(new SystemDumpListenerImpl(progressReporter)).build();
    Mockito.when(this.dumpService.dump(Mockito.isA(SystemDumpParams.class))).thenReturn(systemDumpResult);
    final DumpRunnableTask task = createAndRunTask(new SystemDumpRequestJson(params.getDumpName(), params.isIncludeVersions(), params.getMaxAge(), params.getMaxVersions(), params.isArchive()));
    task.createTaskResult();
    Mockito.verify(progressReporter, Mockito.times(1)).info(contentQueryArgumentCaptor.capture());
    Mockito.verify(taskService, Mockito.times(1)).submitTask(Mockito.isA(RunnableTask.class), Mockito.eq("dump"));
    final String result = contentQueryArgumentCaptor.getAllValues().get(0);
    jsonTestHelper.assertJsonEquals(jsonTestHelper.loadTestJson("dump_result.json"), jsonTestHelper.stringToJson(result));
}
Also used : SystemDumpParams(com.enonic.xp.dump.SystemDumpParams) SystemDumpRequestJson(com.enonic.xp.impl.server.rest.model.SystemDumpRequestJson) RunnableTask(com.enonic.xp.task.RunnableTask) SystemDumpResult(com.enonic.xp.dump.SystemDumpResult) SystemDumpListenerImpl(com.enonic.xp.impl.server.rest.task.listener.SystemDumpListenerImpl) Test(org.junit.jupiter.api.Test) AbstractRunnableTaskTest(com.enonic.xp.task.AbstractRunnableTaskTest)

Example 2 with SystemDumpRequestJson

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

the class SystemResourceTest method dumpTask.

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

Aggregations

SystemDumpRequestJson (com.enonic.xp.impl.server.rest.model.SystemDumpRequestJson)2 Test (org.junit.jupiter.api.Test)2 SystemDumpParams (com.enonic.xp.dump.SystemDumpParams)1 SystemDumpResult (com.enonic.xp.dump.SystemDumpResult)1 DumpRunnableTask (com.enonic.xp.impl.server.rest.task.DumpRunnableTask)1 SystemDumpListenerImpl (com.enonic.xp.impl.server.rest.task.listener.SystemDumpListenerImpl)1 AbstractRunnableTaskTest (com.enonic.xp.task.AbstractRunnableTaskTest)1 RunnableTask (com.enonic.xp.task.RunnableTask)1 TaskResultJson (com.enonic.xp.task.TaskResultJson)1