Search in sources :

Example 6 with MorphiaProject

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

the class MorphiaProjectDaoTest method testGetProjects.

@Test
public void testGetProjects() {
    MorphiaProject project = prepareProject(CODE1);
    datastore.save(projectDao.databaseCollection(), project);
    MorphiaProject project2 = prepareProject(CODE2);
    datastore.save(projectDao.databaseCollection(), project2);
    DatabaseQuery query = DatabaseQuery.createBuilder(USER).build();
    List<MorphiaProject> projects = (List<MorphiaProject>) (List<?>) projectDao.getProjects(query);
    assertThat(projects).extracting(Project::getCode).containsOnly(CODE1, CODE2);
}
Also used : DatabaseQuery(io.lumeer.storage.api.query.DatabaseQuery) MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) List(java.util.List) Test(org.junit.Test)

Example 7 with MorphiaProject

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

the class MorphiaProjectDao method createProject.

@Override
public Project createProject(final Project project) {
    ensureIndexes();
    MorphiaProject morphiaProject = new MorphiaProject(project);
    datastore.insert(databaseCollection(), morphiaProject);
    return morphiaProject;
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject)

Example 8 with MorphiaProject

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

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

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

the class MorphiaProjectDaoTest method prepareProject.

private MorphiaProject prepareProject(String code) {
    MorphiaProject project = new MorphiaProject();
    project.setCode(code);
    project.setName(NAME);
    project.setColor(COLOR);
    project.setIcon(ICON);
    project.setPermissions(new MorphiaPermissions(PERMISSIONS));
    return project;
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)

Aggregations

MorphiaProject (io.lumeer.storage.mongodb.model.MorphiaProject)15 Test (org.junit.Test)9 Project (io.lumeer.api.model.Project)6 ObjectId (org.bson.types.ObjectId)4 DatabaseQuery (io.lumeer.storage.api.query.DatabaseQuery)3 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)3 Organization (io.lumeer.api.model.Organization)2 User (io.lumeer.api.model.User)2 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)2 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)2 SoftAssertions (org.assertj.core.api.SoftAssertions)2 Before (org.junit.Before)2 Permission (io.lumeer.api.model.Permission)1 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 FindOptions (org.mongodb.morphia.query.FindOptions)1