use of com.enonic.xp.dump.SystemLoadResult 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.dump.SystemLoadResult 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.dump.SystemLoadResult in project xp by enonic.
the class DumpServiceImplTest method dumpDeleteAndLoad.
private SystemLoadResult dumpDeleteAndLoad(final boolean clearBlobStore, final SystemDumpParams params) {
doDump(params);
doListRepositories().stream().map(Repository::getId).filter(Predicate.isEqual(SystemConstants.SYSTEM_REPO_ID).or(Predicate.isEqual(AUDIT_LOG_REPO_ID)).or(Predicate.isEqual(SCHEDULER_REPO_ID)).negate()).forEach(this::doDeleteRepository);
// Then delete all system repositories
doDeleteRepository(AUDIT_LOG_REPO_ID);
doDeleteRepository(SCHEDULER_REPO_ID);
// system-repo must be deleted last
doDeleteRepository(SystemConstants.SYSTEM_REPO_ID);
if (clearBlobStore) {
this.blobStore.clear();
}
bootstrap();
final SystemLoadResult result = doLoad();
refresh();
return result;
}
use of com.enonic.xp.dump.SystemLoadResult in project xp by enonic.
the class DumpServiceImplTest method number_of_versions_in_other_repo.
@Test
public void number_of_versions_in_other_repo() {
final Repository myRepo = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("myrepo"), AccessControlList.create().add(AccessControlEntry.create().principal(ctxDefault().getAuthInfo().getUser().getKey()).allowAll().build()).build(), null));
final Context myRepoContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(myRepo.getId()).branch(RepositoryConstants.MASTER_BRANCH).build();
final Node myNode = myRepoContext.callWith(() -> createNode(NodePath.ROOT, "myNode"));
myRepoContext.runWith(() -> updateNode(myNode));
myRepoContext.runWith(() -> updateNode(myNode));
myRepoContext.runWith(() -> updateNode(myNode));
final SystemLoadResult dumpResult = NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true, SystemDumpParams.create().dumpName("myTestDump").build()));
final RepoLoadResult repoLoadResult = getRepoLoadResult(dumpResult, myRepo.getId());
final VersionsLoadResult versionsLoadResult = repoLoadResult.getVersionsLoadResult();
assertNotNull(versionsLoadResult);
// One for root, 4 for myNode
assertEquals(5, versionsLoadResult.getSuccessful());
}
use of com.enonic.xp.dump.SystemLoadResult in project xp by enonic.
the class SystemRepoLoadResultJsonTest method create.
@Test
public void create() throws Exception {
final SystemLoadResult results = SystemLoadResult.create().add(RepoLoadResult.create(RepositoryId.from("my-repo")).add(BranchLoadResult.create(Branch.from("myBranch")).successful(100L).build()).add(BranchLoadResult.create(Branch.from("myOtherBranch")).successful(100L).build()).build()).add(RepoLoadResult.create(RepositoryId.from("my-other-repo")).add(BranchLoadResult.create(Branch.from("myBranch2")).successful(100L).error(LoadError.error("this is an error")).error(LoadError.error("this is another error")).build()).versions(VersionsLoadResult.create().successful(10L).error(LoadError.error("fisk")).build()).build()).build();
final SystemLoadResultJson json = SystemLoadResultJson.from(results);
assertEquals(2, json.getRepositories().size());
assertEquals(2, json.getRepositories().get(0).getBranches().size());
}
Aggregations