use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class MorphiaProjectDaoTest method testUpdateProjectCode.
@Test
public void testUpdateProjectCode() {
MorphiaProject project = prepareProject(CODE1);
String id = datastore.save(projectDao.databaseCollection(), project).getId().toString();
assertThat(id).isNotNull().isNotEmpty();
project.setCode(CODE2);
projectDao.updateProject(id, project);
MorphiaProject storedProject = datastore.get(projectDao.databaseCollection(), MorphiaProject.class, new ObjectId(id));
assertThat(storedProject).isNotNull();
assertThat(storedProject.getCode()).isEqualTo(CODE2);
}
use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class MorphiaProjectDaoTest method testGetProjectsGroupRole.
@Test
public void testGetProjectsGroupRole() {
MorphiaProject project = prepareProject(CODE1);
datastore.save(projectDao.databaseCollection(), project);
MorphiaProject project2 = prepareProject(CODE2);
datastore.save(projectDao.databaseCollection(), project2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP)).build();
List<Project> projects = projectDao.getProjects(query);
assertThat(projects).extracting(Project::getCode).containsOnly(CODE1, CODE2);
}
use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class MorphiaProjectDaoTest method testUpdateProjectExistingCode.
@Test
public void testUpdateProjectExistingCode() {
MorphiaProject project = prepareProject(CODE1);
datastore.save(projectDao.databaseCollection(), project);
MorphiaProject project2 = prepareProject(CODE2);
datastore.save(projectDao.databaseCollection(), project2);
project2.setCode(CODE1);
assertThatThrownBy(() -> projectDao.updateProject(project2.getId(), project2)).isInstanceOf(DuplicateKeyException.class);
}
use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class MorphiaProjectDaoTest method testDeleteProject.
@Test
public void testDeleteProject() {
MorphiaProject project = prepareProject(CODE1);
datastore.save(projectDao.databaseCollection(), project);
assertThat(project.getId()).isNotNull();
projectDao.deleteProject(project.getId());
Project storedProject = datastore.get(projectDao.databaseCollection(), MorphiaProject.class, new ObjectId(project.getId()));
assertThat(storedProject).isNull();
}
use of io.lumeer.storage.mongodb.model.MorphiaProject in project engine by Lumeer.
the class MorphiaProjectDaoTest method testGetProjectByCode.
@Test
public void testGetProjectByCode() {
MorphiaProject project = prepareProject(CODE1);
datastore.save(projectDao.databaseCollection(), project);
MorphiaProject storedProject = (MorphiaProject) projectDao.getProjectByCode(CODE1);
assertThat(storedProject).isNotNull();
assertThat(storedProject.getId()).isNotNull().isNotEmpty();
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();
}
Aggregations