use of com.enonic.xp.dump.SystemDumpParams 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));
}
use of com.enonic.xp.dump.SystemDumpParams in project xp by enonic.
the class DumpRunnableTask method run.
@Override
public void run(final TaskId id, final ProgressReporter progressReporter) {
final SystemDumpParams systemDumpParams = SystemDumpParams.create().dumpName(params.getName()).includeBinaries(true).includeVersions(params.isIncludeVersions()).maxAge(params.getMaxAge()).archive(params.isArchive()).maxVersions(params.getMaxVersions()).listener(new SystemDumpListenerImpl(progressReporter)).build();
final SystemDumpResult result = this.dumpService.dump(systemDumpParams);
progressReporter.info(SystemDumpResultJson.from(result).toString());
}
Aggregations