Search in sources :

Example 6 with NodeImportResult

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();
}
Also used : BranchLoadResult(com.enonic.xp.dump.BranchLoadResult) RepoLoadResult(com.enonic.xp.dump.RepoLoadResult) NodeImportResult(com.enonic.xp.export.NodeImportResult)

Example 7 with NodeImportResult

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();
}
Also used : Branch(com.enonic.xp.branch.Branch) RepoLoadResult(com.enonic.xp.dump.RepoLoadResult) NodeImportResult(com.enonic.xp.export.NodeImportResult)

Example 8 with NodeImportResult

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));
}
Also used : ImportNodesParams(com.enonic.xp.export.ImportNodesParams) ImportNodesRequestJson(com.enonic.xp.impl.server.rest.model.ImportNodesRequestJson) PropertyTree(com.enonic.xp.data.PropertyTree) RunnableTask(com.enonic.xp.task.RunnableTask) NodeImportResult(com.enonic.xp.export.NodeImportResult) Test(org.junit.jupiter.api.Test) AbstractRunnableTaskTest(com.enonic.xp.task.AbstractRunnableTaskTest)

Aggregations

NodeImportResult (com.enonic.xp.export.NodeImportResult)8 ImportNodesParams (com.enonic.xp.export.ImportNodesParams)4 Test (org.junit.jupiter.api.Test)3 PropertyTree (com.enonic.xp.data.PropertyTree)2 RepoLoadResult (com.enonic.xp.dump.RepoLoadResult)2 NodePath (com.enonic.xp.node.NodePath)2 AbstractRunnableTaskTest (com.enonic.xp.task.AbstractRunnableTaskTest)2 RunnableTask (com.enonic.xp.task.RunnableTask)2 Application (com.enonic.xp.app.Application)1 Branch (com.enonic.xp.branch.Branch)1 BranchLoadResult (com.enonic.xp.dump.BranchLoadResult)1 SystemLoadParams (com.enonic.xp.dump.SystemLoadParams)1 SystemLoadResult (com.enonic.xp.dump.SystemLoadResult)1 ImportNodesRequestJson (com.enonic.xp.impl.server.rest.model.ImportNodesRequestJson)1 RepoPath (com.enonic.xp.impl.server.rest.model.RepoPath)1 SystemLoadRequestJson (com.enonic.xp.impl.server.rest.model.SystemLoadRequestJson)1 ImportListenerImpl (com.enonic.xp.impl.server.rest.task.listener.ImportListenerImpl)1 ResourceKey (com.enonic.xp.resource.ResourceKey)1 Path (java.nio.file.Path)1