use of com.enonic.xp.impl.server.rest.model.ImportNodesRequestJson in project xp by enonic.
the class RepositoryResourceTest method importNodes.
@Test
public void importNodes() throws Exception {
Mockito.when(taskService.submitTask(Mockito.isA(ImportRunnableTask.class), eq("import"))).thenReturn(TaskId.from("task-id"));
final ImportNodesRequestJson json = Mockito.mock(ImportNodesRequestJson.class);
final TaskResultJson result = resource.importNodes(json);
assertEquals("task-id", result.getTaskId());
}
use of com.enonic.xp.impl.server.rest.model.ImportNodesRequestJson in project xp by enonic.
the class ImportRunnableTaskTest method importNodes.
@Test
public void importNodes() {
NodeImportResult nodeImportResult = NodeImportResult.create().added(NodePath.create().addElement("node").addElement("path").build()).addBinary("binary", BinaryReference.from("binaryRef")).updated(NodePath.create().addElement("node2").addElement("path2").build()).build();
Mockito.when(this.exportService.importNodes(isA(ImportNodesParams.class))).thenReturn(nodeImportResult);
final PropertyTree repoData = new PropertyTree();
repoData.addString("key", "value");
Mockito.when(this.repositoryService.list()).thenReturn(Repositories.from(Repository.create().branches(Branch.from("master")).id(RepositoryId.from("system-repo")).data(repoData).build()));
final ImportRunnableTask task = createAndRunTask(new ImportNodesRequestJson("export", "system-repo:master:a", true, true, true, "", null));
task.createTaskResult();
Mockito.verify(repositoryService, Mockito.times(1)).invalidateAll();
Mockito.verify(nodeRepositoryService, Mockito.times(1)).isInitialized(RepositoryId.from("system-repo"));
Mockito.verify(nodeRepositoryService, Mockito.times(1)).create(CreateRepositoryParams.create().repositoryId(RepositoryId.from("system-repo")).data(repoData).repositorySettings(RepositorySettings.create().build()).build());
Mockito.verify(progressReporter, Mockito.times(1)).info(contentQueryArgumentCaptor.capture());
Mockito.verify(taskService, Mockito.times(1)).submitTask(Mockito.isA(RunnableTask.class), Mockito.eq("import"));
final String result = contentQueryArgumentCaptor.getAllValues().get(0);
jsonTestHelper.assertJsonEquals(jsonTestHelper.loadTestJson("importNodes_result.json"), jsonTestHelper.stringToJson(result));
}
Aggregations