Search in sources :

Example 16 with Project

use of io.lumeer.api.model.Project in project engine by Lumeer.

the class ProjectServiceIT method testUpdateProject.

@Test
public void testUpdateProject() {
    createProject(CODE1);
    Project updatedProject = new JsonProject(CODE2, NAME, ICON, COLOR, null, null);
    Entity entity = Entity.json(updatedProject);
    Response response = client.target(PROJECT_URL).path(CODE1).request(MediaType.APPLICATION_JSON).buildPut(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(CODE2);
    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();
    Project storedProject = projectDao.getProjectByCode(CODE2);
    assertThat(storedProject).isNotNull();
    assertions = new SoftAssertions();
    assertions.assertThat(storedProject.getCode()).isEqualTo(CODE2);
    assertions.assertThat(storedProject.getName()).isEqualTo(NAME);
    assertions.assertThat(storedProject.getIcon()).isEqualTo(ICON);
    assertions.assertThat(storedProject.getColor()).isEqualTo(COLOR);
    assertions.assertThat(storedProject.getPermissions().getUserPermissions()).containsOnly(USER_PERMISSION);
    assertions.assertThat(storedProject.getPermissions().getGroupPermissions()).containsOnly(GROUP_PERMISSION);
    assertions.assertAll();
}
Also used : Response(javax.ws.rs.core.Response) JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) Entity(javax.ws.rs.client.Entity) SoftAssertions(org.assertj.core.api.SoftAssertions) JsonProject(io.lumeer.api.dto.JsonProject) Test(org.junit.Test)

Example 17 with Project

use of io.lumeer.api.model.Project in project engine by Lumeer.

the class ProjectServiceIT method testGetProject.

@Test
public void testGetProject() {
    createProject(CODE1);
    Response response = client.target(PROJECT_URL).path(CODE1).request(MediaType.APPLICATION_JSON).buildGet().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();
}
Also used : Response(javax.ws.rs.core.Response) JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) SoftAssertions(org.assertj.core.api.SoftAssertions) Test(org.junit.Test)

Example 18 with Project

use of io.lumeer.api.model.Project 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 19 with Project

use of io.lumeer.api.model.Project 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 20 with Project

use of io.lumeer.api.model.Project 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)

Aggregations

Project (io.lumeer.api.model.Project)46 JsonProject (io.lumeer.api.dto.JsonProject)28 Test (org.junit.Test)17 Organization (io.lumeer.api.model.Organization)16 Before (org.junit.Before)16 JsonPermission (io.lumeer.api.dto.JsonPermission)14 User (io.lumeer.api.model.User)14 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)14 JsonOrganization (io.lumeer.api.dto.JsonOrganization)13 JsonPermissions (io.lumeer.api.dto.JsonPermissions)12 Response (javax.ws.rs.core.Response)9 JsonCollection (io.lumeer.api.dto.JsonCollection)8 MorphiaProject (io.lumeer.storage.mongodb.model.MorphiaProject)7 SoftAssertions (org.assertj.core.api.SoftAssertions)7 SimplePermission (io.lumeer.core.model.SimplePermission)4 Permission (io.lumeer.api.model.Permission)3 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)3 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)3 Entity (javax.ws.rs.client.Entity)3 LinkType (io.lumeer.api.model.LinkType)2