Search in sources :

Example 6 with Group

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

the class LinkInstanceFacadeIT method configureLinkInstances.

@Before
public void configureLinkInstances() {
    user = userDao.createUser(new User(USER));
    Organization organization = new Organization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new Permissions());
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    groupDao.setOrganization(storedOrganization);
    group = groupDao.createGroup(new Group("testGroup", Collections.singletonList(user.getId())));
    user.setOrganizations(Collections.singleton(storedOrganization.getId()));
    user = userDao.updateUser(user.getId(), user);
    Permissions organizationPermissions = new Permissions();
    Permission userPermission = Permission.buildWithRoles(user.getId(), Collections.singleton(new Role(RoleType.Read)));
    organizationPermissions.updateUserPermissions(userPermission);
    storedOrganization.setPermissions(organizationPermissions);
    organizationDao.updateOrganization(storedOrganization.getId(), storedOrganization);
    Project project = new Project();
    project.setPermissions(new Permissions());
    project.setCode(PROJECT_CODE);
    Project storedProject = projectDao.createProject(project);
    Permissions projectPermissions = new Permissions();
    Permission userProjectPermission = Permission.buildWithRoles(user.getId(), Collections.singleton(new Role(RoleType.Read)));
    projectPermissions.updateUserPermissions(userProjectPermission);
    storedProject.setPermissions(projectPermissions);
    storedProject = projectDao.updateProject(storedProject.getId(), storedProject);
    workspaceKeeper.setWorkspaceIds(storedOrganization.getId(), storedProject.getId());
    collectionDao.setProject(storedProject);
    Permissions collectionPermissions = new Permissions();
    collectionPermissions.updateUserPermissions(new Permission(user.getId(), Collections.singleton(new Role(RoleType.Read))));
    Collection collection = new Collection("col1", "col1", "icon", "color", collectionPermissions);
    collection1Id = collectionDao.createCollection(collection).getId();
    Collection collection2 = new Collection("col2", "col2", "icon", "color", collectionPermissions);
    collection2Id = collectionDao.createCollection(collection2).getId();
    LinkType linkType = new LinkType(NAME, Arrays.asList(collection1Id, collection2Id), ATTRIBUTES, null, null, null);
    linkTypeId1 = linkTypeDao.createLinkType(linkType).getId();
    LinkType linkType2 = new LinkType(NAME2, Arrays.asList(collection1Id, collection2Id), ATTRIBUTES, null, null, null);
    linkTypeId2 = linkTypeDao.createLinkType(linkType2).getId();
    documentIdsColl1.clear();
    for (int i = 0; i < 3; i++) {
        documentIdsColl1.add(createDocument(collection1Id).getId());
    }
    documentIdsColl2.clear();
    for (int i = 0; i < 3; i++) {
        documentIdsColl2.add(createDocument(collection2Id).getId());
    }
    permissionsChecker.getPermissionAdapter().invalidateUserCache();
}
Also used : Role(io.lumeer.api.model.Role) Group(io.lumeer.api.model.Group) Project(io.lumeer.api.model.Project) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.auth.AuthenticatedUser) Organization(io.lumeer.api.model.Organization) Permissions(io.lumeer.api.model.Permissions) Permission(io.lumeer.api.model.Permission) Collection(io.lumeer.api.model.Collection) LinkType(io.lumeer.api.model.LinkType) Before(org.junit.Before)

Example 7 with Group

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

the class GroupServiceIT method testUpdateGroup.

@Test
public void testUpdateGroup() {
    groupDao.createGroup(new Group(GROUP1));
    Group storedGroup = getGroup(GROUP1);
    assertThat(storedGroup).isNotNull();
    Group updateGroup = new Group(GROUP2);
    Entity<Group> entity = Entity.json(updateGroup);
    Response response = client.target(urlPrefix).path(storedGroup.getId()).request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    storedGroup = getGroup(GROUP1);
    assertThat(storedGroup).isNull();
    storedGroup = getGroup(GROUP2);
    assertThat(storedGroup).isNotNull();
}
Also used : Response(javax.ws.rs.core.Response) Group(io.lumeer.api.model.Group) Test(org.junit.Test)

Example 8 with Group

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

the class GroupServiceIT method testCreateGroup.

@Test
public void testCreateGroup() {
    Group group = new Group(GROUP1);
    Entity<Group> entity = Entity.json(group);
    Response response = client.target(urlPrefix).request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    Group returnedGroup = response.readEntity(Group.class);
    assertThat(returnedGroup).isNotNull();
    Group storedGroup = getGroup(GROUP1);
    assertThat(storedGroup).isNotNull();
    assertThat(storedGroup.getId()).isEqualTo(returnedGroup.getId());
    assertThat(returnedGroup.getName()).isEqualTo(GROUP1);
    assertThat(storedGroup.getName()).isEqualTo(GROUP1);
}
Also used : Response(javax.ws.rs.core.Response) Group(io.lumeer.api.model.Group) Test(org.junit.Test)

Example 9 with Group

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

the class GroupServiceIT method testGetGroups.

@Test
public void testGetGroups() {
    groupDao.createGroup(new Group(GROUP1));
    groupDao.createGroup(new Group(GROUP3));
    Response response = client.target(urlPrefix).request(MediaType.APPLICATION_JSON).buildGet().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    List<Group> groups = response.readEntity(new GenericType<List<Group>>() {
    });
    assertThat(groups).extracting(Group::getName).containsOnly(GROUP1, GROUP3);
}
Also used : Response(javax.ws.rs.core.Response) Group(io.lumeer.api.model.Group) List(java.util.List) Test(org.junit.Test)

Example 10 with Group

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

the class SequenceFacadeIT method configureProject.

@Before
public void configureProject() {
    user = userDao.createUser(new User(USER));
    Organization organization = new Organization();
    organization.setCode(ORGANIZATION_CODE);
    Permissions organizationPermissions = new Permissions();
    userPermission = Permission.buildWithRoles(user.getId(), Set.of(new Role(RoleType.Read)));
    organizationPermissions.updateUserPermissions(userPermission);
    organization.setPermissions(organizationPermissions);
    organization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(organization);
    groupDao.setOrganization(organization);
    Group group = groupDao.createGroup(new Group(GROUP));
    userPermission = Permission.buildWithRoles(user.getId(), Collection.ROLES);
    groupPermission = Permission.buildWithRoles(group.getId(), Collections.singleton(new Role(RoleType.Read)));
    Project project = new Project();
    project.setCode(PROJECT_CODE);
    Permissions projectPermissions = new Permissions();
    projectPermissions.updateUserPermissions(Permission.buildWithRoles(user.getId(), Set.of(new Role(RoleType.Read))));
    project.setPermissions(projectPermissions);
    this.project = projectDao.createProject(project);
    workspaceKeeper.setWorkspaceIds(organization.getId(), this.project.getId());
}
Also used : Role(io.lumeer.api.model.Role) Group(io.lumeer.api.model.Group) Project(io.lumeer.api.model.Project) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.auth.AuthenticatedUser) Organization(io.lumeer.api.model.Organization) Permissions(io.lumeer.api.model.Permissions) Before(org.junit.Before)

Aggregations

Group (io.lumeer.api.model.Group)44 Test (org.junit.Test)22 Organization (io.lumeer.api.model.Organization)19 Permissions (io.lumeer.api.model.Permissions)16 Project (io.lumeer.api.model.Project)16 Role (io.lumeer.api.model.Role)16 User (io.lumeer.api.model.User)16 Before (org.junit.Before)15 AuthenticatedUser (io.lumeer.core.auth.AuthenticatedUser)14 Permission (io.lumeer.api.model.Permission)10 Response (javax.ws.rs.core.Response)9 Collection (io.lumeer.api.model.Collection)7 LumeerAssertions.assertPermissions (io.lumeer.test.util.LumeerAssertions.assertPermissions)6 List (java.util.List)4 LinkType (io.lumeer.api.model.LinkType)2 Query (io.lumeer.api.model.Query)2 QueryStem (io.lumeer.api.model.QueryStem)2 ResourceType (io.lumeer.api.model.ResourceType)2 RoleType (io.lumeer.api.model.RoleType)2 Resource (io.lumeer.api.model.common.Resource)2