use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepositoryServiceImplTest method delete_branch_deletes_from_repo.
@Test
void delete_branch_deletes_from_repo() {
doCreateRepo("fisk");
Branch branch = Branch.from("myBranch");
NodeHelper.runAsAdmin(() -> repositoryService.createBranch(CreateBranchParams.from(branch)));
NodeHelper.runAsAdmin(() -> repositoryService.deleteBranch(DeleteBranchParams.from(branch)));
final Repository persistedRepo = getPersistedRepoWithoutCache("fisk");
assertFalse(persistedRepo.getBranches().contains(branch));
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepositoryServiceImplTest method update_attachment.
@Test
void update_attachment() throws Exception {
final String repoId = "repo-with-attachment";
doCreateRepo(repoId);
final BinaryReference binaryRef = BinaryReference.from("image1.jpg");
ByteSource binarySource = ByteSource.wrap("this-is-the-binary-data-for-image1".getBytes());
Context mockCurrentContext = ContextBuilder.create().branch("master").repositoryId(repoId).authInfo(REPO_TEST_DEFAULT_USER_AUTHINFO).build();
PropertyTree data = new PropertyTree();
data.setBinaryReference("someIcon", binaryRef);
mockCurrentContext.runWith(() -> repositoryService.updateRepository(UpdateRepositoryParams.create().repositoryId(RepositoryId.from(repoId)).editor(edit -> {
edit.data = data;
edit.binaryAttachments = ImmutableList.of(new BinaryAttachment(binaryRef, binarySource));
}).build()));
createAdminContext().runWith(() -> {
repositoryService.invalidateAll();
});
ByteSource persistedAttachment = mockCurrentContext.callWith(() -> repositoryService.getBinary(RepositoryId.from(repoId), BinaryReference.from("image1.jpg")));
assertTrue(binarySource.contentEquals(persistedAttachment));
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepositoryServiceImplTest method create_branch_creates_in_repo.
@Test
void create_branch_creates_in_repo() {
doCreateRepo("fisk");
Branch branch = Branch.from("myBranch");
Context mockCurrentContext = ContextBuilder.create().branch("master").repositoryId("fisk").authInfo(REPO_TEST_DEFAULT_USER_AUTHINFO).build();
mockCurrentContext.callWith(() -> repositoryService.createBranch(CreateBranchParams.from(branch)));
final Repository persistedRepo = getPersistedRepoWithoutCache("fisk");
assertTrue(persistedRepo.getBranches().contains(branch));
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class AbstractNodeTest method createTestRepository.
private void createTestRepository() {
final AccessControlList rootPermissions = AccessControlList.of(AccessControlEntry.create().principal(TEST_DEFAULT_USER.getKey()).allowAll().build());
ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.create().principals(RoleKeys.ADMIN).user(User.ANONYMOUS).build()).build().callWith(() -> {
this.repositoryService.createRepository(CreateRepositoryParams.create().repositoryId(TEST_REPO_ID).rootPermissions(rootPermissions).build());
TEST_REPO_BRANCHES.stream().filter(branch -> !RepositoryConstants.MASTER_BRANCH.equals(branch)).forEach(branch -> {
final CreateBranchParams createBranchParams = CreateBranchParams.from(branch.toString());
this.repositoryService.createBranch(createBranchParams);
});
refresh();
return null;
});
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class AbstractContentServiceTest method doPrintContentTree.
private void doPrintContentTree(final ContentId rootId) {
final Content root = this.contentService.getById(rootId);
final Branch branch = ContextAccessor.current().getBranch();
System.out.println("** Content-tree in branch [" + branch.getValue() + "], starting with path [" + root.getPath() + "]");
doPrintChildren(0, root);
}
Aggregations