use of com.enonic.xp.impl.server.rest.model.SystemLoadRequestJson in project xp by enonic.
the class LoadRunnableTaskTest method load_system.
@Test
public void load_system() throws Exception {
Files.createDirectory(dumpDir.resolve("name"));
SystemLoadParams params = SystemLoadParams.create().dumpName("name").includeVersions(true).build();
SystemLoadResult systemLoadResult = SystemLoadResult.create().add(RepoLoadResult.create(RepositoryId.from("my-repo")).add(BranchLoadResult.create(Branch.create().value("branch-value").build()).error(LoadError.error("error-message")).successful(2L).build()).versions(VersionsLoadResult.create().error(LoadError.error("version-load-error-message")).successful(1L).build()).build()).build();
Mockito.when(this.dumpService.load(Mockito.isA(SystemLoadParams.class))).thenReturn(systemLoadResult);
final LoadRunnableTask task = createAndRunTask(new SystemLoadRequestJson(params.getDumpName(), params.isUpgrade(), 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("load_system_result.json"), jsonTestHelper.stringToJson(result));
}
use of com.enonic.xp.impl.server.rest.model.SystemLoadRequestJson in project xp by enonic.
the class LoadRunnableTaskTest method load.
@Test
public void load() throws Exception {
Path nameDir = Files.createDirectory(dumpDir.resolve("name"));
final NodeImportResult importResult = NodeImportResult.create().added(NodePath.create("/path/to/node1").build()).updated(NodePath.create("/path/to/node2").build()).dryRun(true).build();
final PropertyTree repoData = new PropertyTree();
repoData.addString("key", "value");
Mockito.when(this.exportService.importNodes(Mockito.isA(ImportNodesParams.class))).thenReturn(importResult);
Mockito.when(this.repositoryService.list()).thenReturn(Repositories.from(Repository.create().branches(Branch.from("master")).id(RepositoryId.from("my-repo")).data(repoData).build()));
Files.writeString(nameDir.resolve("export.properties"), "a=b");
SystemLoadParams params = SystemLoadParams.create().dumpName("name").includeVersions(true).build();
SystemLoadResult systemLoadResult = SystemLoadResult.create().add(RepoLoadResult.create(RepositoryId.from("my-repo")).add(BranchLoadResult.create(Branch.create().value("branch-value").build()).error(LoadError.error("error-message")).successful(2L).build()).versions(VersionsLoadResult.create().error(LoadError.error("version-load-error-message")).successful(1L).build()).build()).build();
Mockito.when(this.dumpService.load(Mockito.isA(SystemLoadParams.class))).thenReturn(systemLoadResult);
final LoadRunnableTask task = createAndRunTask(new SystemLoadRequestJson(params.getDumpName(), params.isUpgrade(), 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"));
Mockito.verify(nodeRepositoryService, Mockito.times(1)).create(CreateRepositoryParams.create().repositoryId(RepositoryId.from("my-repo")).data(repoData).repositorySettings(RepositorySettings.create().build()).build());
final String result = contentQueryArgumentCaptor.getAllValues().get(0);
jsonTestHelper.assertJsonEquals(jsonTestHelper.loadTestJson("load_result.json"), jsonTestHelper.stringToJson(result));
}
use of com.enonic.xp.impl.server.rest.model.SystemLoadRequestJson in project xp by enonic.
the class SystemResourceTest method load.
@Test
public void load() throws Exception {
Mockito.when(taskService.submitTask(Mockito.isA(LoadRunnableTask.class), eq("load"))).thenReturn(TaskId.from("task-id"));
final SystemLoadRequestJson json = Mockito.mock(SystemLoadRequestJson.class);
final TaskResultJson result = resource.load(json);
assertEquals("task-id", result.getTaskId());
}
Aggregations