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();
}
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();
}
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);
}
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);
}
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());
}
Aggregations