Class RoleInheritanceTestUtils


  • public class RoleInheritanceTestUtils
    extends Object
    This class provides some utility methods used to test the Role Inheritance functionality
    • Constructor Detail

      • RoleInheritanceTestUtils

        public RoleInheritanceTestUtils()
    • Method Detail

      • createRole

        public static Role createRole​(String name,
                                      String clientId,
                                      String organizationId,
                                      String userLevel,
                                      boolean isManual,
                                      boolean isTemplate)
        Creates a new role
        Parameters:
        name - the name of the role
        clientId - role client id
        organizationId - role organization id
        userLevel - user level of the role's organization
        isManual - defines if the role is manual (true) or automatic (false)
        isTemplate - defines if the role is template (true) or not (false)
        Returns:
        the new created role
      • deleteRole

        public static void deleteRole​(Role role)
        Deletes a role
        Parameters:
        role - A Role object which will be deleted
      • addInheritance

        public static void addInheritance​(Role role,
                                          Role template,
                                          Long sequenceNumber)
        Adds a new inheritance between two roles
        Parameters:
        role - The role owner of the inheritance
        template - The template role whose permissions will be inherited
        sequenceNumber - Sequence number to assign to the inheritance
      • removeInheritance

        public static void removeInheritance​(Role role,
                                             Role template)
        Removes an existing inheritance
        Parameters:
        role - The role owner of the inheritance
        template - The template role whose permissions are being inherited
      • addAccess

        public static void addAccess​(String type,
                                     Role role,
                                     String accessName)
        Creates a new permission and assigns it to a role
        Parameters:
        type - A String which represents the type of the access
        role - The role to assign the permission
        accessName - The name of the particular permission to assign
      • removeAccesses

        public static void removeAccesses​(String type,
                                          Role role)
        Removes a permission assigned to a role
        Parameters:
        type - A String which represents the type of the access
        role - The role owner of the permission
      • updateAccess

        public static void updateAccess​(String type,
                                        Role role,
                                        String accessName,
                                        boolean editedValue,
                                        boolean isActive)
        Updates an existing permission assigned to a role
        Parameters:
        type - A String which represents the type of the access
        role - The role owner of the permission
        accessName - The name of the particular permission to update
        editedValue - The edited value to assign to the permission
        isActive - a flag to activate (true) or deactivate (false) the permission
      • getAccessInfo

        public static String[] getAccessInfo​(String type,
                                             Role role,
                                             String accessName)
        Retrieves the information of a permission assigned to a role
        Parameters:
        type - A String which represents the type of the access
        role - The role owner of the permission
        accessName - The name of the particular permission to retrieve
        Returns:
        An array of Strings with the permission information
      • getOrderedAccessNames

        public static String[] getOrderedAccessNames​(String type,
                                                     Role role)
        Retrieves an array with permissions information assigned to a role, ordered by name
        Parameters:
        type - A String which represents the type of the access
        role - The role to assign the permission
        Returns:
        an array of Strings with the permissions information
      • createDummyView

        public static void createDummyView()
        Workaround to be able to test role inheritance of view implementations as core only have one view available
      • removeDummyView

        public static void removeDummyView()
        Workaround to be able to test role inheritance of view implementations as core only have one view available