use of io.lumeer.api.dto.JsonProject 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.dto.JsonProject 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);
}
use of io.lumeer.api.dto.JsonProject in project engine by Lumeer.
the class ProjectServiceIT method testGetProjects.
@Test
public void testGetProjects() {
createProject(CODE1);
createProject(CODE2);
Response response = client.target(PROJECT_URL).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<JsonProject> projects = response.readEntity(new GenericType<List<JsonProject>>() {
});
assertThat(projects).extracting(Resource::getCode).containsOnly(CODE1, CODE2);
Project project1 = projects.get(0);
assertThat(project1.getName()).isEqualTo(NAME);
assertThat(project1.getIcon()).isEqualTo(ICON);
assertThat(project1.getColor()).isEqualTo(COLOR);
Permissions permissions1 = project1.getPermissions();
assertThat(permissions1).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions1).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions1).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
Project project2 = projects.get(1);
assertThat(project2.getName()).isEqualTo(NAME);
assertThat(project2.getIcon()).isEqualTo(ICON);
assertThat(project2.getColor()).isEqualTo(COLOR);
Permissions permissions2 = project2.getPermissions();
assertThat(permissions2).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions2).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions2).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
}
use of io.lumeer.api.dto.JsonProject in project engine by Lumeer.
the class OrganizationServicePermissionsIT method testCreateProjectInOrganizationNoRole.
@Test
public void testCreateProjectInOrganizationNoRole() {
String name = "testRemoveGroupPermissionNoRole";
String code = "testRemoveGroupPermissionNoRole_code";
Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
organizationFacade.createOrganization(organization);
organizationFacade.removeUserPermission(code, userEmail);
String projectCode = "proj1";
String projectName = "proj1_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.UNAUTHORIZED);
}
use of io.lumeer.api.dto.JsonProject in project engine by Lumeer.
the class ProjectServicePermissionsIT method createProject.
private Project createProject(String code, String name) {
Project project = new JsonProject(code, name, "a", "b", null, null);
project.getPermissions().updateUserPermissions(new SimplePermission(userEmail, Project.ROLES));
return projectDao.createProject(project);
}
Aggregations