use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class SnapshotServiceImplTest method restore_all_no_orphan_indices_left.
@Test
public void restore_all_no_orphan_indices_left() {
NodeHelper.runAsAdmin(() -> {
this.snapshotService.snapshot(SnapshotParams.create().snapshotName("my-snapshot").build());
final RepositoryId newRepoId = RepositoryId.from("new-repo");
this.repositoryService.createRepository(CreateRepositoryParams.create().repositoryId(newRepoId).build());
assertNotNull(this.repositoryService.get(newRepoId));
this.snapshotService.restore(RestoreParams.create().snapshotName("my-snapshot").build());
assertAll(() -> assertFalse(this.repositoryService.isInitialized(newRepoId)), () -> assertFalse(indexServiceInternal.indicesExists(IndexNameResolver.resolveStorageIndexName(newRepoId))), () -> assertFalse(indexServiceInternal.indicesExists(IndexNameResolver.resolveSearchIndexName(newRepoId))));
});
}
use of com.enonic.xp.repository.RepositoryId 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.repository.RepositoryId 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.repository.RepositoryId in project xp by enonic.
the class ProjectServiceImplTest method create_in_non_master_node.
@Test
void create_in_non_master_node() {
IndexServiceInternal indexServiceInternalMock = Mockito.mock(IndexServiceInternal.class);
when(indexServiceInternalMock.waitForYellowStatus()).thenReturn(true);
indexService.setIndexServiceInternal(indexServiceInternalMock);
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final Project project = adminContext().callWith(() -> doCreateProject(ProjectName.from(projectRepoId), null, true, null));
assertNotNull(project);
assertEquals("test-project", project.getName().toString());
final NodeBranchEntry nodeBranchEntry = this.branchService.get(Node.ROOT_UUID, InternalContext.create(adminContext()).repositoryId(projectRepoId).build());
assertNotNull(nodeBranchEntry);
adminContext().runWith(() -> {
final Repository pro = repositoryService.get(projectRepoId);
assertNotNull(pro);
});
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class ProjectServiceImplTest method create_with_role_members.
@Test
void create_with_role_members() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
adminContext().runWith(() -> {
final User user1 = securityService.createUser(CreateUserParams.create().userKey(PrincipalKey.ofUser(IdProviderKey.system(), "user1")).displayName("user1").login("user1").build());
final User user2 = securityService.createUser(CreateUserParams.create().userKey(PrincipalKey.ofUser(IdProviderKey.system(), "user2")).displayName("user2").login("user2").build());
doCreateProjectAsAdmin(ProjectName.from(projectRepoId), ProjectPermissions.create().addOwner(user1.getKey()).addOwner(user2.getKey()).build());
final Set<PrincipalKey> members = securityService.getRelationships(PrincipalKey.ofRole("cms.project.test-project.owner")).stream().map(PrincipalRelationship::getTo).collect(Collectors.toSet());
assertTrue(members.contains(user1.getKey()));
assertTrue(members.contains(user2.getKey()));
});
}
Aggregations