use of com.enonic.xp.export.NodeImportResult in project xp by enonic.
the class LoadRunnableTask method importSystemRepo.
private RepoLoadResult importSystemRepo(final Path rootDir) {
final RepoLoadResult.Builder builder = RepoLoadResult.create(SystemConstants.SYSTEM_REPO_ID);
final NodeImportResult systemRepoImport = importRepoBranch(SystemConstants.SYSTEM_REPO_ID.toString(), SystemConstants.BRANCH_SYSTEM.toString(), rootDir);
final BranchLoadResult branchLoadResult = NodeImportResultTranslator.translate(systemRepoImport, SystemConstants.BRANCH_SYSTEM);
builder.add(branchLoadResult);
return builder.build();
}
use of com.enonic.xp.export.NodeImportResult in project xp by enonic.
the class LoadRunnableTask method importRepoBranches.
private RepoLoadResult importRepoBranches(final Path rootDir, final Repository repository) {
final RepoLoadResult.Builder builder = RepoLoadResult.create(repository.getId());
for (Branch branch : repository.getBranches()) {
if (isSystemRepoMaster(repository, branch)) {
continue;
}
final NodeImportResult nodeImportResult = importRepoBranch(repository.getId().toString(), branch.getValue(), rootDir);
builder.add(NodeImportResultTranslator.translate(nodeImportResult, branch));
}
return builder.build();
}
use of com.enonic.xp.export.NodeImportResult 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