@Test public void testRegexMapper() { Roles roles = createRoles("123-user", "joe", "abc-admin"); RegexRoleMapper roleMapper = new RegexRoleMapper.Builder().setPattern(".*-([a-z]*)").setReplacement("$1").setKeepNonMapped(true).build(); Roles mappedRoles = roleMapper.mapRoles(roles); assertTrue(mappedRoles.contains("user")); assertTrue(mappedRoles.contains("admin")); assertFalse(mappedRoles.contains("abc-admin")); assertFalse(mappedRoles.contains("123-user")); assertTrue(mappedRoles.contains("joe")); Iterator<String> iterator = mappedRoles.iterator(); int count = 0; while (iterator.hasNext()) { iterator.next(); count++; } assertEquals(count, 3); }
@Override public Roles mapRoles(Roles rolesToMap) { return new RegexRoles(rolesToMap, this.pattern, this.replacement, this.keepNonMapped, this.replaceAll); }
RegexRoleMapper implements RoleMapper { @Override public Roles mapRoles(Roles rolesToMap) { return new RegexRoles(rolesToMap, this.pattern, this.replacement, this.keepNonMapped, this.replaceAll); } }
RegexRoleMapper implements RoleMapper { @Override public Roles mapRoles(Roles rolesToMap) { return new RegexRoles(rolesToMap, this.pattern, this.replacement, this.keepNonMapped, this.replaceAll); } private  RegexRoleMapper(Builder builder); }
RegexRoleMapper implements RoleMapper { @Override public Roles mapRoles(Roles rolesToMap) { return new RegexRoles(rolesToMap, this.pattern, this.replacement, this.keepNonMapped, this.replaceAll); } private  RegexRoleMapper(Builder builder); @Override Roles mapRoles(Roles rolesToMap); }
RegexRoleMapper implements RoleMapper { @Override public Roles mapRoles(Roles rolesToMap) { return new RegexRoles(rolesToMap, this.pattern, this.replacement, this.keepNonMapped, this.replaceAll); } private  RegexRoleMapper(Builder builder); @Override Roles mapRoles(Roles rolesToMap);  }