EquivalenceClassTransformer implements DataTransformer { private void ssn(StringBuilder b) { generateFromRegex(b, "^((?!000)(?!666)(?:[0-6]\\d{2}|7[0-2][0-9]|73[0-3]|7[5-6][0-9]|77[0-2]))" + "-((?!00)\\d{2})-((?!0000)\\d{4})$"); } EquivalenceClassTransformer(); @Override void transform(DataPipe cr); static final String[] CURRENCY_CODES; static final String[] STATE_LONG; static final String[] STATES_SHORT; static final Holiday[] HOLIDAYS; static final String[] COUNTRIES; static final int COUNT_NASDAQ_SECURITIES; static final String[] SYMBOLS_NASDAQ; static final String[] SECURITY_NAMES_NASDAQ; static final int COUNT_NOT_NASDAQ_SECURITIES; static final String[] SYMBOLS_NOT_NASDAQ; static final String[] SECURITY_NAMES_NOT_NASDAQ; }
@Test public void ssnTest() { DataPipe pipeToTransform = new DataPipe(); EquivalenceClassTransformer eqTransformer = new EquivalenceClassTransformer(); for (int i = 0; i < 500; i++) { pipeToTransform.getDataMap().put("TEST", "%ssn"); eqTransformer.transform(pipeToTransform); Pattern alphaWithSpacesPattern = Pattern.compile("^((?!000)(?!666)(?:[0-6]\\d{2}|7[0-2][0-9]|73[0-3]|7[5-6][0-9]|77[0-2]))" + "-((?!00)\\d{2})-((?!0000)\\d{4})$"); Matcher didItMatch = alphaWithSpacesPattern.matcher(pipeToTransform.getDataMap().get("TEST")); Assert.assertTrue(didItMatch.matches()); } }