use of io.lumeer.api.model.Project in project engine by Lumeer.
the class ViewFacadeIT 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);
workspaceKeeper.setWorkspace(ORGANIZATION_CODE, PROJECT_CODE);
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);
}
use of io.lumeer.api.model.Project in project engine by Lumeer.
the class ProjectFacade method removeUserPermission.
public void removeUserPermission(final String projectCode, final String user) {
Project project = projectDao.getProjectByCode(projectCode);
permissionsChecker.checkRole(project, Role.MANAGE);
project.getPermissions().removeUserPermission(user);
projectDao.updateProject(project.getId(), project);
}
use of io.lumeer.api.model.Project in project engine by Lumeer.
the class MorphiaProjectDaoTest method testCreateProject.
@Test
public void testCreateProject() {
Project project = prepareProject(CODE1);
String id = projectDao.createProject(project).getId();
assertThat(id).isNotNull().isNotEmpty();
assertThat(ObjectId.isValid(id)).isTrue();
MorphiaProject storedProject = datastore.get(projectDao.databaseCollection(), MorphiaProject.class, new ObjectId(id));
assertThat(storedProject).isNotNull();
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(storedProject.getCode()).isEqualTo(CODE1);
assertions.assertThat(storedProject.getName()).isEqualTo(NAME);
assertions.assertThat(storedProject.getColor()).isEqualTo(COLOR);
assertions.assertThat(storedProject.getIcon()).isEqualTo(ICON);
assertions.assertThat(storedProject.getPermissions()).isEqualTo(PERMISSIONS);
assertions.assertAll();
}
use of io.lumeer.api.model.Project 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.api.model.Project in project engine by Lumeer.
the class MorphiaCollectionDaoTest method initCollectionDao.
@Before
public void initCollectionDao() {
Project project = Mockito.mock(Project.class);
Mockito.when(project.getId()).thenReturn(PROJECT_ID);
collectionDao = new MorphiaCollectionDao();
collectionDao.setDatabase(database);
collectionDao.setDatastore(datastore);
collectionDao.setProject(project);
collectionDao.createCollectionsRepository(project);
}
Aggregations