@Test public void testRegexMapper3() { Roles roles = createRoles("USER_ABC_DEF", "joe", "ADMIN_123"); RegexRoleMapper roleMapper = new RegexRoleMapper.Builder().setPattern("^([a-zA-Z]*)_.*").setReplacement("APP-$1").setKeepNonMapped(true).build(); Roles mappedRoles = roleMapper.mapRoles(roles); assertFalse(mappedRoles.contains("USER_ABC_DEF")); assertFalse(mappedRoles.contains("ADMIN_123")); assertTrue(mappedRoles.contains("APP-USER")); assertTrue(mappedRoles.contains("APP-ADMIN")); 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);  }