use of io.lumeer.api.model.Project 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.model.Project in project engine by Lumeer.
the class ViewServiceIT method configureProject.
@Before
public void configureProject() {
MorphiaOrganization organization = new MorphiaOrganization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new MorphiaPermissions());
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
User user = new User(USER);
userDao.createUser(user);
MorphiaProject project = new MorphiaProject();
project.setCode(PROJECT_CODE);
project.setPermissions(new MorphiaPermissions());
Project storedProject = projectDao.createProject(project);
viewDao.setProject(storedProject);
}
use of io.lumeer.api.model.Project 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.model.Project 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);
}
use of io.lumeer.api.model.Project in project engine by Lumeer.
the class ProjectServicePermissionsIT method testGetProjectsSomeReadRoles.
@Test
public void testGetProjectsSomeReadRoles() {
String projectCode1 = "ProjectServiceTestProject_code1";
String projectName1 = "ProjectServiceTestProject1";
String projectCode2 = "ProjectServiceTestProject_code2";
String projectName2 = "ProjectServiceTestProject2";
String projectCode3 = "ProjectServiceTestProject_code3";
String projectName3 = "ProjectServiceTestProject3";
String projectCode4 = "ProjectServiceTestProject_code4";
String projectName4 = "ProjectServiceTestProject4";
List<String> projectCodes = Arrays.asList(projectCode1, projectCode2, projectCode3, projectCode4);
List<String> projectNames = Arrays.asList(projectName1, projectName2, projectName3, projectName4);
for (int i = 0; i < projectCodes.size(); i++) {
createProject(projectCodes.get(i), projectNames.get(i));
if (i % 2 == 0) {
projectFacade.removeUserPermission(projectCodes.get(i), userEmail);
} else {
projectFacade.updateUserPermissions(projectCodes.get(i), new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ)))));
}
}
Response response = client.target(TARGET_URI).path(PATH_PREFIX).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<Project> projects = response.readEntity(new GenericType<List<Project>>(List.class) {
});
assertThat(projects).extracting("code").containsOnly(projectCode2, projectCode4);
assertThat(projects).extracting("name").containsOnly(projectName2, projectName4);
}
Aggregations