@Test public void testRegexMapperEmailKeep() { Roles roles = createRoles("user@gmail.com", "joe", "user@customerApp.com"); RegexRoleMapper roleMapper = new RegexRoleMapper.Builder().setPattern(".*@([a-zA-Z]*)\\..*").setReplacement("$1-role").setKeepNonMapped(true).build(); Roles mappedRoles = roleMapper.mapRoles(roles); assertFalse(mappedRoles.contains("user@gmail.com")); assertFalse(mappedRoles.contains("user@customerApp.com")); assertTrue(mappedRoles.contains("gmail-role")); assertTrue(mappedRoles.contains("customerApp-role")); 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);  }