use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class MorphiaProjectDaoTest method testUpdateProjectPermissions.
@Test
public void testUpdateProjectPermissions() {
MorphiaProject project = prepareProject(CODE1);
String id = datastore.save(projectDao.databaseCollection(), project).getId().toString();
assertThat(id).isNotNull().isNotEmpty();
project.getPermissions().removeUserPermission(USER);
project.getPermissions().updateGroupPermissions(GROUP_PERMISSION);
projectDao.updateProject(id, project);
MorphiaProject storedProject = datastore.get(projectDao.databaseCollection(), MorphiaProject.class, new ObjectId(id));
assertThat(storedProject).isNotNull();
assertThat(storedProject.getPermissions().getUserPermissions()).isEmpty();
assertThat(storedProject.getPermissions().getGroupPermissions()).containsExactly(GROUP_PERMISSION);
}
use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class MorphiaProjectDaoTest method testGetProjectsNoReadRole.
@Test
public void testGetProjectsNoReadRole() {
MorphiaProject project = prepareProject(CODE1);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
project.getPermissions().updateUserPermissions(userPermission);
datastore.save(projectDao.databaseCollection(), project);
MorphiaProject project2 = prepareProject(CODE2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
project2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(projectDao.databaseCollection(), project2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<Project> projects = projectDao.getProjects(query);
assertThat(projects).isEmpty();
}
use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class MorphiaProjectDao method updateProject.
@Override
public Project updateProject(final String projectId, final Project project) {
MorphiaProject morphiaProject = new MorphiaProject(project);
morphiaProject.setId(projectId);
datastore.save(databaseCollection(), morphiaProject);
return morphiaProject;
}
use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class MorphiaProjectDao method getProjects.
@Override
public List<Project> getProjects(final DatabaseQuery query) {
Query<MorphiaProject> projectQuery = createProjectQuery(query);
FindOptions findOptions = createFindOptions(query);
return new ArrayList<>(projectQuery.asList(findOptions));
}
use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class ViewServiceIT method configureProject.
@Before
public void configureProject() {
MorphiaOrganization organization = new MorphiaOrganization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new MorphiaPermissions());
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
User user = new User(USER);
userDao.createUser(user);
MorphiaProject project = new MorphiaProject();
project.setCode(PROJECT_CODE);
project.setPermissions(new MorphiaPermissions());
Project storedProject = projectDao.createProject(project);
viewDao.setProject(storedProject);
}
Aggregations