| 1 | 
    
            
    
     | 
    
           | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
           | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
           | 
  
            
  
    | 6 | 
    
            
    
     | 
    
           | 
  
            
  
    | 7 | 
    
            
    
     | 
    
           | 
  
            
  
    | 8 | 
    
            
    
     | 
    
           | 
  
            
  
    | 9 | 
    
            
    
     | 
    
           | 
  
            
  
    | 10 | 
    
            
    
     | 
    
           | 
  
            
  
    | 11 | 
    
            
    
     | 
    
           | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
            
  
    | 13 | 
    
            
    
     | 
    
           | 
  
            
  
    | 14 | 
    
            
    
     | 
    
           | 
  
            
  
    | 15 | 
    
            
    
     | 
    
           | 
  
            
  
    | 16 | 
    
            
    
     | 
    
      package org.kuali.rice.kew.rule;     | 
  
            
  
    | 17 | 
    
            
    
     | 
    
           | 
  
            
  
    | 18 | 
    
            
    
     | 
    
      import java.util.ArrayList;     | 
  
            
  
    | 19 | 
    
            
    
     | 
    
      import java.util.Collections;     | 
  
            
  
    | 20 | 
    
            
    
     | 
    
      import java.util.List;     | 
  
            
  
    | 21 | 
    
            
    
     | 
    
           | 
  
            
  
    | 22 | 
    
            
    
     | 
    
      import org.apache.commons.lang.StringUtils;     | 
  
            
  
    | 23 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.engine.RouteContext;     | 
  
            
  
    | 24 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.identity.Id;     | 
  
            
  
    | 25 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.rule.ResolvedQualifiedRole;     | 
  
            
  
    | 26 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.rule.Role;     | 
  
            
  
    | 27 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.rule.UnqualifiedRoleAttribute;     | 
  
            
  
    | 28 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.identity.PrincipalName;     | 
  
            
  
    | 29 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.workgroup.GroupNameId;     | 
  
            
  
    | 30 | 
    
            
    
     | 
    
           | 
  
            
  
    | 31 | 
    
            
    
     | 
    
           | 
  
            
  
    | 32 | 
    
            
    
     | 
    
           | 
  
            
  
    | 33 | 
    
            
    
     | 
    
           | 
  
            
  
    | 34 | 
    
            
    
     | 
    
           | 
  
            
  
    | 35 | 
    
            
    
     | 
    
           | 
  
            
  
    | 36 | 
    
            
    
     | 
    
           | 
  
            
  
    | 37 | 
    
            
    
     | 
    
           | 
  
            
  
    | 38 | 
    
            
    
     | 
    
           | 
  
            
  
    | 39 | 
    
            
    
     | 
    
           | 
  
            
  
    | 40 | 
    
            
    
     | 
    
           | 
  
            
  
    | 41 | 
    
            
    
     | 
    
           | 
  
            
  
    | 42 | 
    
            
    
     | 
    
           | 
  
            
  
    | 43 | 
    
            
    
     | 
    
      @author     | 
  
            
  
    | 44 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 32 (32) | 
           Complexity: 8 | 
           Complexity Density: 0.36 | 
                        
            
        | 
    
  
  
    | 45 | 
    
            
    
     | 
    
      public class MockRole extends UnqualifiedRoleAttribute {     | 
  
            
  
    | 46 | 
    
            
    
     | 
    
          private static final Role ROLE = new Role(MockRole.class, "List of authentication ids", "List of authentication ids");     | 
  
            
  
    | 47 | 
    
            
    
     | 
    
          private static final List<Role> ROLES;     | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 3 (3) | 
           Complexity: 1 | 
           Complexity Density: 0.33 | 
                        
            
        | 
    
  
  
    | 48 | 
    
           0
    
     | 
    
           static {...     | 
  
            
  
    | 49 | 
    
           0
    
     | 
    
              ArrayList<Role> roles = new ArrayList<Role>(1);     | 
  
            
  
    | 50 | 
    
           0
    
     | 
    
              roles.add(ROLE);     | 
  
            
  
    | 51 | 
    
           0
    
     | 
    
              ROLES = Collections.unmodifiableList(roles);     | 
  
            
  
    | 52 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 53 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 54 | 
    
           0
    
     | 
    
           public MockRole() {...     | 
  
            
  
    | 55 | 
    
           0
    
     | 
    
              super(ROLES);     | 
  
            
  
    | 56 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 57 | 
    
            
    
     | 
    
           | 
  
            
  
    | 58 | 
    
            
    
     | 
    
               | 
  
            
  
    | 59 | 
    
            
    
     | 
    
           | 
  
            
  
    | 60 | 
    
            
    
     | 
    
      @see     | 
  
            
  
    | 61 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 62 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 63 | 
    
            
    
     | 
    
          protected boolean isValidRoleName(String roleName) {     | 
  
            
  
    | 64 | 
    
           0
    
     | 
    
              return true;     | 
  
            
  
    | 65 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 66 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 23 (23) | 
           Complexity: 5 | 
           Complexity Density: 0.29 | 
                        
            
        | 
    
  
  
    | 67 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 68 | 
    
            
    
     | 
    
          protected ResolvedQualifiedRole resolveRole(RouteContext routeContext, String roleName) {     | 
  
            
  
    | 69 | 
    
           0
    
     | 
    
              String[] ids = roleName.split("[,\\s+]");     | 
  
            
  
    | 70 | 
    
           0
    
     | 
    
              ResolvedQualifiedRole rqr = new ResolvedQualifiedRole();     | 
  
            
  
    | 71 | 
    
           0
    
     | 
    
              for (String id: ids) {     | 
  
            
  
    | 72 | 
    
           0
    
     | 
    
                  String type = "user";     | 
  
            
  
    | 73 | 
    
           0
    
     | 
    
                  String[] components = id.split(":", 2);     | 
  
            
  
    | 74 | 
    
           0
    
     | 
    
                  if (components.length > 1 && !StringUtils.isEmpty(components[0])) {     | 
  
            
  
    | 75 | 
    
           0
    
     | 
    
                      type = components[0].trim();     | 
  
            
  
    | 76 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 77 | 
    
           0
    
     | 
    
                  Id recipientId;     | 
  
            
  
    | 78 | 
    
           0
    
     | 
    
                  if ("user".equals(type)) {     | 
  
            
  
    | 79 | 
    
           0
    
     | 
    
                      recipientId = new PrincipalName(id);     | 
  
            
  
    | 80 | 
    
           0
    
     | 
    
                  } else if ("group".equals(type)) {     | 
  
            
  
    | 81 | 
    
           0
    
     | 
    
                      recipientId = new GroupNameId(id);     | 
  
            
  
    | 82 | 
    
            
    
     | 
    
                  } else {     | 
  
            
  
    | 83 | 
    
           0
    
     | 
    
                      throw new RuntimeException("Unknown role recipient type: '" + type + "'. Must be 'user' or 'group'.");     | 
  
            
  
    | 84 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 85 | 
    
           0
    
     | 
    
                  rqr.getRecipients().add(recipientId);     | 
  
            
  
    | 86 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 87 | 
    
           0
    
     | 
    
              rqr.setQualifiedRoleLabel("Recipients from parsing mock role: " + roleName);     | 
  
            
  
    | 88 | 
    
           0
    
     | 
    
              rqr.setAnnotation("Recipients from parsing mock role: " + roleName);     | 
  
            
  
    | 89 | 
    
           0
    
     | 
    
              return rqr;     | 
  
            
  
    | 90 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 91 | 
    
            
    
     | 
    
      }     |