### Question:
RegEx extends AbstractMapper { @Override public String transform (String attrValue) { String result = attrValue; try { if (replacementPattern != null && !replacementPattern.isEmpty()) { for (String matchPattern : replacementPattern.keySet()) { Pattern p = Pattern.compile(matchPattern); Matcher m = p.matcher(result); if (m.find()) { String replacement = replacementPattern.get(matchPattern); if (replacement != null) { result = m.replaceAll(replacement); } } } } } catch (Throwable t) { logger.error("Failed to transform " + attrValue, t.fillInStackTrace()); } return result; }  LinkedHashMap<String, String> getReplacementPattern(); @Override void init(String baseProperty); @Override String transform(String attrValue);  }### Answer:
@Test public void testTransform() throws Throwable { userRegexPatterns.add("s/\\s/_/g"); userNameRegEx.populateReplacementPatterns(userNameBaseProperty, userRegexPatterns); assertEquals("test_user", userNameRegEx.transform("test user")); assertEquals("ldap grp", groupNameRegEx.transform("ldap grp")); }