Search in sources :

Example 1 with Resource

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

the class OrganizationCodec method generateIdIfAbsentFromDocument.

@Override
public Organization generateIdIfAbsentFromDocument(final Organization jsonOrganization) {
    Resource resource = generateIdIfAbsentFromDocument((Resource) jsonOrganization);
    jsonOrganization.setId(resource.getId());
    return jsonOrganization;
}
Also used : Resource(io.lumeer.api.model.common.Resource) SimpleResource(io.lumeer.api.model.common.SimpleResource)

Example 2 with Resource

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

the class PermissionsCheckerTest method testCheckGroupRole.

@Test
public void testCheckGroupRole() {
    Resource resource = prepareResource(Collections.emptySet(), Collections.singleton(new Role(RoleType.Read)));
    permissionsChecker.checkRole(resource, RoleType.Read);
}
Also used : Role(io.lumeer.api.model.Role) Resource(io.lumeer.api.model.common.Resource) Test(org.junit.Test)

Example 3 with Resource

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

the class PermissionsCheckerTest method testCheckUserRole.

@Test
public void testCheckUserRole() {
    Resource resource = prepareResource(Collections.singleton(new Role(RoleType.Read)), Collections.emptySet());
    permissionsChecker.checkRole(resource, RoleType.Read);
}
Also used : Role(io.lumeer.api.model.Role) Resource(io.lumeer.api.model.common.Resource) Test(org.junit.Test)

Example 4 with Resource

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

the class PermissionsCheckerTest method testGetActualRolesUserOnly.

@Test
public void testGetActualRolesUserOnly() {
    Resource resource = prepareResource(Sets.newLinkedHashSet(new Role(RoleType.Read), new Role(RoleType.DataWrite)), Collections.emptySet());
    Set<RoleType> roles = permissionsChecker.getActualRoles(resource);
    assertThat(roles).containsOnly(RoleType.Read, RoleType.DataWrite);
}
Also used : Role(io.lumeer.api.model.Role) RoleType(io.lumeer.api.model.RoleType) Resource(io.lumeer.api.model.common.Resource) Test(org.junit.Test)

Example 5 with Resource

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

the class PermissionsCheckerTest method testCheckNoRole.

@Test
public void testCheckNoRole() {
    Resource resource = prepareResource(Collections.emptySet(), Collections.emptySet());
    assertThatThrownBy(() -> permissionsChecker.checkRole(resource, RoleType.Read)).isInstanceOf(NoResourcePermissionException.class).hasFieldOrPropertyWithValue("resource", resource);
}
Also used : NoResourcePermissionException(io.lumeer.core.exception.NoResourcePermissionException) Resource(io.lumeer.api.model.common.Resource) Test(org.junit.Test)

Aggregations

Resource (io.lumeer.api.model.common.Resource)16 Test (org.junit.Test)8 Role (io.lumeer.api.model.Role)6 RoleType (io.lumeer.api.model.RoleType)4 SimpleResource (io.lumeer.api.model.common.SimpleResource)4 Utils (io.lumeer.core.util.Utils)3 DataDocument (io.lumeer.engine.api.data.DataDocument)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 Collection (io.lumeer.api.model.Collection)2 Document (io.lumeer.api.model.Document)2 LinkInstance (io.lumeer.api.model.LinkInstance)2 LinkType (io.lumeer.api.model.LinkType)2 Project (io.lumeer.api.model.Project)2 ResourceType (io.lumeer.api.model.ResourceType)2 ResourceUtils (io.lumeer.api.util.ResourceUtils)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2