Search in sources :

Example 6 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization 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 7 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization in project engine by Lumeer.

the class MorphiaOrganizationDaoTest method testUpdateOrganizationExistingCode.

@Test
public void testUpdateOrganizationExistingCode() {
    MorphiaOrganization organization = prepareOrganization(CODE1);
    datastore.save(organization);
    MorphiaOrganization organization2 = prepareOrganization(CODE2);
    datastore.save(organization2);
    organization2.setCode(CODE1);
    assertThatThrownBy(() -> organizationDao.updateOrganization(organization2.getId(), organization2)).isInstanceOf(DuplicateKeyException.class);
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) Test(org.junit.Test)

Example 8 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization in project engine by Lumeer.

the class MorphiaOrganizationDaoTest method testUpdateOrganizationCode.

@Test
public void testUpdateOrganizationCode() {
    MorphiaOrganization organization = prepareOrganization(CODE1);
    String id = datastore.save(organization).getId().toString();
    assertThat(id).isNotNull().isNotEmpty();
    MorphiaOrganization organization2 = prepareOrganization(CODE2);
    organizationDao.updateOrganization(id, organization2);
    MorphiaOrganization storedOrganization = datastore.get(MorphiaOrganization.class, new ObjectId(id));
    assertThat(storedOrganization).isNotNull();
    assertThat(storedOrganization.getCode()).isEqualTo(CODE2);
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) ObjectId(org.bson.types.ObjectId) Test(org.junit.Test)

Example 9 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization 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);
}
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 10 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization in project engine by Lumeer.

the class ProjectServicePermissionsIT method configureProject.

@Before
public void configureProject() {
    MorphiaOrganization organization = new MorphiaOrganization();
    organization.setCode(organizationCode);
    organization.setName(organizationName);
    organization.setPermissions(new MorphiaPermissions());
    organization.getPermissions().updateUserPermissions(new MorphiaPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    workspaceKeeper.setOrganization(organizationCode);
    User user = new User(userEmail);
    userDao.createUser(user);
}
Also used : Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Aggregations

MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)12 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)6 Organization (io.lumeer.api.model.Organization)5 User (io.lumeer.api.model.User)5 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)5 Before (org.junit.Before)5 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)3 Test (org.junit.Test)3 Project (io.lumeer.api.model.Project)2 MorphiaProject (io.lumeer.storage.mongodb.model.MorphiaProject)2 ObjectId (org.bson.types.ObjectId)2 JsonOrganization (io.lumeer.api.dto.JsonOrganization)1 ArrayList (java.util.ArrayList)1 FindOptions (org.mongodb.morphia.query.FindOptions)1