@Test public void testRegexMapper2() { Roles roles = createRoles("APP-123_XY_ZX_ABCD-Batch_Admin", "joe", "APP-ABC_EF_GH_IJKL-Batch_Operator"); RegexRoleMapper roleMapper = new RegexRoleMapper.Builder().setPattern(".*_([a-zA-Z]*)$").setReplacement("$1").setKeepNonMapped(false).build(); Roles mappedRoles = roleMapper.mapRoles(roles); assertTrue(mappedRoles.contains("Admin")); assertTrue(mappedRoles.contains("Operator")); assertFalse(mappedRoles.contains("APP-123_XY_ZX_ABCD-Batch_Admin")); assertFalse(mappedRoles.contains("APP-ABC_EF_GH_IJKL-Batch_Operator")); 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);  }