Search in sources :

Example 6 with JsonProject

use of io.lumeer.api.dto.JsonProject in project engine by Lumeer.

the class OrganizationServicePermissionsIT method testCreateProjectInOrganizationManageRole.

@Test
public void testCreateProjectInOrganizationManageRole() {
    String name = "testCreateProjectInOrganizationManageRole";
    String code = "testCreateProjectInOrganizationManageRole_code";
    Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
    organizationFacade.createOrganization(organization);
    String projectCode = "proj2";
    String projectName = "proj2_code";
    Project project = new JsonProject(projectCode, projectName, "a", "b", null, null);
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/projects").request(MediaType.APPLICATION_JSON).buildPost(Entity.json(project)).invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
Also used : Response(javax.ws.rs.core.Response) JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonProject(io.lumeer.api.dto.JsonProject) Test(org.junit.Test)

Example 7 with JsonProject

use of io.lumeer.api.dto.JsonProject in project engine by Lumeer.

the class ProjectServicePermissionsIT method testUpdateProjectNoRole.

@Test
public void testUpdateProjectNoRole() {
    String projectCode = "testUpdateProjectNoRole_id";
    String projectName = "testUpdateProjectNoRole";
    createProject(projectCode, projectName);
    projectFacade.removeUserPermission(projectCode, userEmail);
    String newProjectName = "NewName2";
    Project newProject = new JsonProject(projectCode, newProjectName, "a", "b", null, null);
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode).request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newProject)).invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
Also used : Response(javax.ws.rs.core.Response) JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) JsonProject(io.lumeer.api.dto.JsonProject) Test(org.junit.Test)

Example 8 with JsonProject

use of io.lumeer.api.dto.JsonProject in project engine by Lumeer.

the class ProjectFacadeIT method testCreateProject.

@Test
public void testCreateProject() {
    Project project = new JsonProject(CODE1, NAME, ICON, COLOR, null, null);
    Project returnedProject = projectFacade.createProject(project);
    assertThat(returnedProject).isNotNull();
    assertThat(returnedProject.getId()).isNotNull();
    Project storedProject = projectDao.getProjectByCode(CODE1);
    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().getUserPermissions()).containsOnly(USER_PERMISSION);
    assertions.assertThat(storedProject.getPermissions().getGroupPermissions()).isEmpty();
    assertions.assertAll();
}
Also used : JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) SoftAssertions(org.assertj.core.api.SoftAssertions) JsonProject(io.lumeer.api.dto.JsonProject) Test(org.junit.Test)

Example 9 with JsonProject

use of io.lumeer.api.dto.JsonProject 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());
    }
}
Also used : JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) LinkType(io.lumeer.api.model.LinkType) JsonCollection(io.lumeer.api.dto.JsonCollection) JsonProject(io.lumeer.api.dto.JsonProject) Before(org.junit.Before)

Example 10 with JsonProject

use of io.lumeer.api.dto.JsonProject 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());
    }
}
Also used : JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) JsonCollection(io.lumeer.api.dto.JsonCollection) JsonProject(io.lumeer.api.dto.JsonProject) Before(org.junit.Before)

Aggregations

JsonProject (io.lumeer.api.dto.JsonProject)26 Project (io.lumeer.api.model.Project)25 Organization (io.lumeer.api.model.Organization)15 JsonOrganization (io.lumeer.api.dto.JsonOrganization)14 JsonPermission (io.lumeer.api.dto.JsonPermission)14 JsonPermissions (io.lumeer.api.dto.JsonPermissions)13 User (io.lumeer.api.model.User)13 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)13 Before (org.junit.Before)13 Test (org.junit.Test)9 JsonCollection (io.lumeer.api.dto.JsonCollection)8 Response (javax.ws.rs.core.Response)7 SoftAssertions (org.assertj.core.api.SoftAssertions)4 SimplePermission (io.lumeer.core.model.SimplePermission)3 Entity (javax.ws.rs.client.Entity)3 LinkType (io.lumeer.api.model.LinkType)2 Permission (io.lumeer.api.model.Permission)1 Permissions (io.lumeer.api.model.Permissions)1 Resource (io.lumeer.api.model.Resource)1 Role (io.lumeer.api.model.Role)1