EquivalenceClassTransformer implements DataTransformer { private void alpha(StringBuilder b, int len) { while (len > 0) { int word = random.nextInt(WORDS.length); int letter = random.nextInt(WORDS[word].length()); b.append(WORDS[word].charAt(letter)); len--; } } 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 alphaTest() { DataPipe pipeToTransform = new DataPipe(); EquivalenceClassTransformer eqTransformer = new EquivalenceClassTransformer(); pipeToTransform.getDataMap().put("TEST", "%alpha(1)"); eqTransformer.transform(pipeToTransform); Pattern alphaPattern = Pattern.compile("^[a-z0-9A-Z]{1}$"); Matcher didItMatch = alphaPattern.matcher(pipeToTransform.getDataMap().get("TEST")); Assert.assertTrue(didItMatch.matches()); pipeToTransform.getDataMap().put("TEST", "%alpha(100)"); eqTransformer.transform(pipeToTransform); alphaPattern = Pattern.compile("^[a-z0-9A-Z]{100}$"); didItMatch = alphaPattern.matcher(pipeToTransform.getDataMap().get("TEST")); Assert.assertTrue(didItMatch.matches()); pipeToTransform.getDataMap().put("TEST", "%alpha(0)"); eqTransformer.transform(pipeToTransform); Assert.assertEquals("", pipeToTransform.getDataMap().get("TEST")); }