use of io.lumeer.api.model.Project in project engine by Lumeer.
the class MorphiaDocumentDaoTest method initDocumentDao.
@Before
public void initDocumentDao() {
Project project = Mockito.mock(Project.class);
Mockito.when(project.getId()).thenReturn(PROJECT_ID);
documentDao = new MorphiaDocumentDao();
documentDao.setDatabase(database);
documentDao.setDatastore(datastore);
documentDao.setProject(project);
documentDao.createDocumentsRepository(project);
}
use of io.lumeer.api.model.Project in project engine by Lumeer.
the class LinkInstanceServiceIT method configureLinkInstances.
@Before
public void configureLinkInstances() {
JsonOrganization organization = new JsonOrganization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new JsonPermissions());
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
User user = new User(USER);
userDao.createUser(user);
JsonProject project = new JsonProject();
project.setPermissions(new JsonPermissions());
project.setCode(PROJECT_CODE);
Project storedProject = projectDao.createProject(project);
collectionDao.setProject(storedProject);
linkTypeDao.setProject(storedProject);
linkInstanceDao.setProject(storedProject);
documentDao.setProject(storedProject);
JsonPermissions collectionPermissions = new JsonPermissions();
collectionPermissions.updateUserPermissions(new JsonPermission(USER, Project.ROLES.stream().map(Role::toString).collect(Collectors.toSet())));
JsonCollection jsonCollection = new JsonCollection("col1", "col1", "icon", "color", collectionPermissions);
jsonCollection.setDocumentsCount(0);
String collection1 = collectionDao.createCollection(jsonCollection).getId();
JsonCollection jsonCollection2 = new JsonCollection("col2", "col2", "icon", "color", collectionPermissions);
jsonCollection.setDocumentsCount(0);
String collection2 = collectionDao.createCollection(jsonCollection2).getId();
LinkType linkType = new LinkType(null, NAME, Arrays.asList(collection1, collection2), ATTRIBUTES);
linkTypeId1 = linkTypeDao.createLinkType(linkType).getId();
LinkType linkType2 = new LinkType(null, NAME2, Arrays.asList(collection1, collection2), ATTRIBUTES);
linkTypeId2 = linkTypeDao.createLinkType(linkType2).getId();
documentIdsColl1.clear();
for (int i = 0; i < 3; i++) {
documentIdsColl1.add(createDocument(collection1).getId());
}
documentIdsColl2.clear();
for (int i = 0; i < 3; i++) {
documentIdsColl2.add(createDocument(collection2).getId());
}
}
use of io.lumeer.api.model.Project in project engine by Lumeer.
the class LinkTypeServiceIT method configureLinkTypes.
@Before
public void configureLinkTypes() {
JsonOrganization organization = new JsonOrganization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new JsonPermissions());
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
User user = new User(USER);
userDao.createUser(user);
JsonProject project = new JsonProject();
project.setPermissions(new JsonPermissions());
project.setCode(PROJECT_CODE);
Project storedProject = projectDao.createProject(project);
collectionDao.setProject(storedProject);
linkTypeDao.setProject(storedProject);
collectionIds.clear();
for (String name : COLLECTION_NAMES) {
JsonPermissions collectionPermissions = new JsonPermissions();
collectionPermissions.updateUserPermissions(new JsonPermission(USER, Project.ROLES.stream().map(Role::toString).collect(Collectors.toSet())));
JsonCollection jsonCollection = new JsonCollection(name, name, COLLECTION_ICON, COLLECTION_COLOR, collectionPermissions);
jsonCollection.setDocumentsCount(0);
collectionIds.add(collectionDao.createCollection(jsonCollection).getId());
}
}
use of io.lumeer.api.model.Project in project engine by Lumeer.
the class ProjectServiceIT method testCreateProject.
@Test
public void testCreateProject() {
Project project = new JsonProject(CODE1, NAME, ICON, COLOR, null, null);
Entity entity = Entity.json(project);
Response response = client.target(PROJECT_URL).request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
Project returnedProject = response.readEntity(JsonProject.class);
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(returnedProject.getCode()).isEqualTo(CODE1);
assertions.assertThat(returnedProject.getName()).isEqualTo(NAME);
assertions.assertThat(returnedProject.getIcon()).isEqualTo(ICON);
assertions.assertThat(returnedProject.getColor()).isEqualTo(COLOR);
assertions.assertThat(returnedProject.getPermissions().getUserPermissions()).containsOnly(USER_PERMISSION);
assertions.assertThat(returnedProject.getPermissions().getGroupPermissions()).isEmpty();
assertions.assertAll();
}
use of io.lumeer.api.model.Project in project engine by Lumeer.
the class ProjectServiceIT method createProject.
private Project createProject(String code) {
Project project = new JsonProject(code, NAME, ICON, COLOR, null, null);
project.getPermissions().updateUserPermissions(USER_PERMISSION);
project.getPermissions().updateGroupPermissions(GROUP_PERMISSION);
return projectDao.createProject(project);
}
Aggregations