use of net.andreinc.mockneat.types.enums.DictType in project mockneat by nomemory.
the class Passwords method nextWeakPassword.
private String nextWeakPassword() {
Integer minLength = WEAK.getLength().getLowerBound();
Integer maxLength = WEAK.getLength().getUpperBound();
DictType dictType = mockNeat.from(new DictType[] { EN_NOUN_2SYLL, EN_NOUN_1SYLL }).val();
String noun = mockNeat.dicts().type(dictType).val();
if (noun.length() > maxLength) {
noun = noun.substring(0, maxLength);
}
StringBuilder resultBuff = new StringBuilder(noun);
if (noun.length() < minLength) {
// Add some objs numbers in the case the noun
// is shorted than the minLength
int diff = minLength - noun.length();
while (diff-- > 0) resultBuff.append(mockNeat.ints().range(0, 10).val());
}
return resultBuff.toString();
}
use of net.andreinc.mockneat.types.enums.DictType in project mockneat by nomemory.
the class Users method generateUserName.
private String generateUserName(UserNameType type) {
Pair<DictType, DictType> pair = mockNeat.from(type.getDictCombos()).val();
String part1 = mockNeat.dicts().type(pair.getFirst()).format(LOWER_CASE).val();
String part2 = mockNeat.dicts().type(pair.getSecond()).format(LOWER_CASE).val();
if (mockNeat.bools().probability(UNDERSCORE).val()) {
part1 += "_";
}
return part1 + part2;
}
use of net.andreinc.mockneat.types.enums.DictType in project mockneat by nomemory.
the class Celebrities method type.
/**
* The method returns a random celebrity object of the specified {@code CelebrityType} celebrity type.
* @param celebrityType The type of the celebrity (e.g.: {@code CelebrityType.ACTORS}, {@code CelebrityType.ROCK_STARS}, etc.)
* @return The {@code MockUnitString} capable of generating celebrity names based on the specified type.
*/
public MockUnitString type(CelebrityType celebrityType) {
notNull(celebrityType, "celebrityType");
DictType dictType = mockNeat.from(celebrityType.getDictionaries()).val();
return () -> mockNeat.dicts().type(dictType)::get;
}
use of net.andreinc.mockneat.types.enums.DictType in project mockneat by nomemory.
the class Names method type.
/**
* <p>Returns a new {@code MockUnitString} that can be used to generate names of the given type.</p>
*
* @param type The type of name we want to generate.
*
* @return A new {@code MockUnitString}.
*/
public MockUnitString type(NameType type) {
notNull(type, "type");
DictType dictType = mockNeat.from(type.getDictionaries()).val();
return () -> mockNeat.dicts().type(dictType)::val;
}
Aggregations