@Test public void testRegexMapperReplaceAllSubstrings() { Roles roles = createRoles("app-guest", "joe", "app-guest-first-time-guest"); RegexRoleMapper roleMapper = new RegexRoleMapper.Builder().setPattern("guest").setReplacement("user").setKeepNonMapped(false).setReplaceAll(true).build(); Roles mappedRoles = roleMapper.mapRoles(roles); assertFalse(mappedRoles.contains("app-guest")); assertFalse(mappedRoles.contains("app-guest-first-time-guest")); assertFalse(mappedRoles.contains("app-user-first-time-guest")); assertFalse(mappedRoles.contains("app-guest-first-time-user")); assertTrue(mappedRoles.contains("app-user")); assertTrue(mappedRoles.contains("app-user-first-time-user")); assertFalse(mappedRoles.contains("joe")); Iterator<String> iterator = mappedRoles.iterator(); int count = 0; while (iterator.hasNext()) { iterator.next(); count++; } assertEquals(count, 2); }
@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);  }