Search in sources :

Example 21 with Project

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);
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Project(io.lumeer.api.model.Project) Organization(io.lumeer.api.model.Organization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Example 22 with Project

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);
}
Also used : Project(io.lumeer.api.model.Project)

Example 23 with 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();
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Project(io.lumeer.api.model.Project) ObjectId(org.bson.types.ObjectId) SoftAssertions(org.assertj.core.api.SoftAssertions) MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Test(org.junit.Test)

Example 24 with Project

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();
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Project(io.lumeer.api.model.Project) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) DatabaseQuery(io.lumeer.storage.api.query.DatabaseQuery) MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Permission(io.lumeer.api.model.Permission) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) Test(org.junit.Test)

Example 25 with Project

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);
}
Also used : Project(io.lumeer.api.model.Project) Before(org.junit.Before)

Aggregations

Project (io.lumeer.api.model.Project)46 JsonProject (io.lumeer.api.dto.JsonProject)28 Test (org.junit.Test)17 Organization (io.lumeer.api.model.Organization)16 Before (org.junit.Before)16 JsonPermission (io.lumeer.api.dto.JsonPermission)14 User (io.lumeer.api.model.User)14 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)14 JsonOrganization (io.lumeer.api.dto.JsonOrganization)13 JsonPermissions (io.lumeer.api.dto.JsonPermissions)12 Response (javax.ws.rs.core.Response)9 JsonCollection (io.lumeer.api.dto.JsonCollection)8 MorphiaProject (io.lumeer.storage.mongodb.model.MorphiaProject)7 SoftAssertions (org.assertj.core.api.SoftAssertions)7 SimplePermission (io.lumeer.core.model.SimplePermission)4 Permission (io.lumeer.api.model.Permission)3 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)3 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)3 Entity (javax.ws.rs.client.Entity)3 LinkType (io.lumeer.api.model.LinkType)2