@Test public void alphaWithSpacesTest() { DataPipe pipeToTransform = new DataPipe(); EquivalenceClassTransformer eqTransformer = new EquivalenceClassTransformer(); pipeToTransform.getDataMap().put("TEST", "%alphaWithSpaces(1)"); eqTransformer.transform(pipeToTransform); Pattern alphaWithSpacesPattern = Pattern.compile("^[a-z0-9A-Z\\s]{1}$"); Matcher didItMatch = alphaWithSpacesPattern.matcher(pipeToTransform.getDataMap().get("TEST")); Assert.assertTrue(didItMatch.matches()); pipeToTransform.getDataMap().put("TEST", "%alphaWithSpaces(100)"); eqTransformer.transform(pipeToTransform); alphaWithSpacesPattern = Pattern.compile("^[a-z0-9A-Z\\s]{100}$"); didItMatch = alphaWithSpacesPattern.matcher(pipeToTransform.getDataMap().get("TEST")); Assert.assertTrue(didItMatch.matches()); pipeToTransform.getDataMap().put("TEST", "%alphaWithSpaces(0)"); eqTransformer.transform(pipeToTransform); Assert.assertEquals("", pipeToTransform.getDataMap().get("TEST")); }
private void alphaWithSpaces(StringBuilder b, int len) { int nextSpacePos = len - random.nextInt(9); while (len > 0) { if (len != nextSpacePos) { int word = random.nextInt(WORDS.length); int letter = random.nextInt(WORDS[word].length()); b.append(WORDS[word].charAt(letter)); } else { b.append(" "); nextSpacePos = len - random.nextInt(9); } len--; } }
EquivalenceClassTransformer implements DataTransformer { private void alphaWithSpaces(StringBuilder b, int len) { int nextSpacePos = len - random.nextInt(9); while (len > 0) { if (len != nextSpacePos) { int word = random.nextInt(WORDS.length); int letter = random.nextInt(WORDS[word].length()); b.append(WORDS[word].charAt(letter)); } else { b.append(" "); nextSpacePos = len - random.nextInt(9); } len--; } } }
EquivalenceClassTransformer implements DataTransformer { private void alphaWithSpaces(StringBuilder b, int len) { int nextSpacePos = len - random.nextInt(9); while (len > 0) { if (len != nextSpacePos) { int word = random.nextInt(WORDS.length); int letter = random.nextInt(WORDS[word].length()); b.append(WORDS[word].charAt(letter)); } else { b.append(" "); nextSpacePos = len - random.nextInt(9); } len--; } } EquivalenceClassTransformer(); }
EquivalenceClassTransformer implements DataTransformer { private void alphaWithSpaces(StringBuilder b, int len) { int nextSpacePos = len - random.nextInt(9); while (len > 0) { if (len != nextSpacePos) { int word = random.nextInt(WORDS.length); int letter = random.nextInt(WORDS[word].length()); b.append(WORDS[word].charAt(letter)); } else { b.append(" "); nextSpacePos = len - random.nextInt(9); } len--; } } EquivalenceClassTransformer(); @Override void transform(DataPipe cr); }
EquivalenceClassTransformer implements DataTransformer { private void alphaWithSpaces(StringBuilder b, int len) { int nextSpacePos = len - random.nextInt(9); while (len > 0) { if (len != nextSpacePos) { int word = random.nextInt(WORDS.length); int letter = random.nextInt(WORDS[word].length()); b.append(WORDS[word].charAt(letter)); } else { b.append(" "); nextSpacePos = len - random.nextInt(9); } 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; }