@Test void generateRandomValuesRestrictedMin() { final int length = 9; StringRestrictions restrictions = StringRestrictionsFactory.forMinLength(length); RegexStringGenerator regex = (RegexStringGenerator) restrictions.createGenerator(); FakerGenerator generator = new FakerGenerator(regex, "name.firstName"); final int size = 10; Stream<String> results = generator.generateRandomValues(new JavaUtilRandomNumberGenerator()) .limit(size); assertTrue(results.allMatch(str -> str.length() >= length)); }
@Override public Stream<String> generateRandomValues(RandomNumberGenerator randomNumberGenerator) { return Stream.generate(() -> getFakerValue(randomFaker)) .filter(underlyingRegexGenerator::validate); }
FakerGenerator implements StringGenerator { @Override public Stream<String> generateRandomValues(RandomNumberGenerator randomNumberGenerator) { return Stream.generate(() -> getFakerValue(randomFaker)) .filter(underlyingRegexGenerator::validate); } }
FakerGenerator implements StringGenerator { @Override public Stream<String> generateRandomValues(RandomNumberGenerator randomNumberGenerator) { return Stream.generate(() -> getFakerValue(randomFaker)) .filter(underlyingRegexGenerator::validate); } FakerGenerator(StringGenerator underlyingRegexGenerator, String fakerSpec); }
FakerGenerator implements StringGenerator { @Override public Stream<String> generateRandomValues(RandomNumberGenerator randomNumberGenerator) { return Stream.generate(() -> getFakerValue(randomFaker)) .filter(underlyingRegexGenerator::validate); } FakerGenerator(StringGenerator underlyingRegexGenerator, String fakerSpec); @Override boolean matches(String string); @Override StringGenerator intersect(StringGenerator stringGenerator); @Override boolean validate(String string); @Override Stream<String> generateAllValues(); @Override Stream<String> generateRandomValues(RandomNumberGenerator randomNumberGenerator); }
FakerGenerator implements StringGenerator { @Override public Stream<String> generateRandomValues(RandomNumberGenerator randomNumberGenerator) { return Stream.generate(() -> getFakerValue(randomFaker)) .filter(underlyingRegexGenerator::validate); } FakerGenerator(StringGenerator underlyingRegexGenerator, String fakerSpec); @Override boolean matches(String string); @Override StringGenerator intersect(StringGenerator stringGenerator); @Override boolean validate(String string); @Override Stream<String> generateAllValues(); @Override Stream<String> generateRandomValues(RandomNumberGenerator randomNumberGenerator);  }