@Test public void byPattern1() { assertThat(generator.byPattern("A"), ContainsPattern.matchesPattern("[A-Z]")); assertThat(generator.byPattern("a"), ContainsPattern.matchesPattern("[a-z]")); assertThat(generator.byPattern("0"), ContainsPattern.matchesPattern("[0-9]")); assertThat(generator.byPattern("0Aa"), ContainsPattern.matchesPattern(Pattern.compile("[0-9][A-Z][a-z]"))); }
@Override public String byPattern(String pattern) { if (StringUtils.isEmpty(pattern)) throw new CukesRuntimeException("Invalid password pattern, should contain symbols like a,A,0"); return pattern .chars() .map(this::mapPatternCharacter) .collect( producer(), accumulator(), resultMerger() ) .toString(); }
RandomGeneratorFacadeImpl implements RandomGeneratorFacade { @Override public String byPattern(String pattern) { if (StringUtils.isEmpty(pattern)) throw new CukesRuntimeException("Invalid password pattern, should contain symbols like a,A,0"); return pattern .chars() .map(this::mapPatternCharacter) .collect( producer(), accumulator(), resultMerger() ) .toString(); } }
RandomGeneratorFacadeImpl implements RandomGeneratorFacade { @Override public String byPattern(String pattern) { if (StringUtils.isEmpty(pattern)) throw new CukesRuntimeException("Invalid password pattern, should contain symbols like a,A,0"); return pattern .chars() .map(this::mapPatternCharacter) .collect( producer(), accumulator(), resultMerger() ) .toString(); } RandomGeneratorFacadeImpl(); }
RandomGeneratorFacadeImpl implements RandomGeneratorFacade { @Override public String byPattern(String pattern) { if (StringUtils.isEmpty(pattern)) throw new CukesRuntimeException("Invalid password pattern, should contain symbols like a,A,0"); return pattern .chars() .map(this::mapPatternCharacter) .collect( producer(), accumulator(), resultMerger() ) .toString(); } RandomGeneratorFacadeImpl(); @Override String byPattern(String pattern); @Override String withLength(int length); }
RandomGeneratorFacadeImpl implements RandomGeneratorFacade { @Override public String byPattern(String pattern) { if (StringUtils.isEmpty(pattern)) throw new CukesRuntimeException("Invalid password pattern, should contain symbols like a,A,0"); return pattern .chars() .map(this::mapPatternCharacter) .collect( producer(), accumulator(), resultMerger() ) .toString(); } RandomGeneratorFacadeImpl(); @Override String byPattern(String pattern); @Override String withLength(int length);  }