Class MockNeat
public class MockNeat
extends java.lang.Object
-
Constructor Summary
Constructors Modifier Constructor Description protectedMockNeat()MockNeat(RandomType randomTypeType)MockNeat(RandomType randomTypeType, java.lang.Long seed) -
Method Summary
Modifier and Type Method Description Actorsactors()Returns aActorsobject that can be used to generate arbitrary actor names (e.g.: Michael Douglas)Actressesactresses()Returns aActressesobject that can be used to generate arbitrary actresses names (e.g.: Elizabeth Taylor)Boolsbools()Returns aBoolsobject that can be used to generate arbitraryBooleanvalues.Carscars()Returns aCarsobject that can be used to generate arbitrary car namesCelebritiescelebrities()Charschars()Returns aCharsobject that can be used to generate arbitraryCharactervalues.Citiescities()Returns aCitiesobject that can be used to generate arbitrary city names from around the world.<T> Constant<T>constant(T object)Returns a newConstantobject.<T> Constructor<T>constructor(java.lang.Class<T> cls)Returns a newConstructorobject.Countriescountries()Returns aCountriesobject that can be used to generate country names or country ISO2 codes.Creaturescreatures()Returns aCreaturesobject that can be used to generate arbitrary creature names.CreditCardscreditCards()Returns aCreditCardsobject that can be used to generate valid Credit Card numbers.CSVscsvs()Returns aCSVsobject that can be used to generate CSV lines or files.Currenciescurrencies()Returns aCurrenciesobject that can be used to generate currencies-related information:CVVScvvs()Returns aCVVSobject that can be used to generate credit card cvv codes.Daysdays()Returns aDaysobject that can be used to generate a randomjava.time.DayOfWeekobject.Departmentsdepartments()Returns aDepartmentsobject that can be used to generate arbitrary names representing department names from a company.Dictsdicts()Returns aDictsobject that can be used to generate data from the library existing dictionaries.Domainsdomains()Returns aDomainsobjectDoublesdoubles()Returns aDoublesobject that can be used to generate arbitrarydoublevalues.Emailsemails()Returns anEmailobject that can be used to generate arbitrary email address.<T, FT> Factory<T,FT>factory(java.lang.Class<T> targetCls, java.lang.Class<FT> factoryCls)Returns a newFactoryobject that can be used to instantiate Java Objects by calling a static factory method and supplying it with arbitrary data.FromFilesfiles()Returns aFromFilesobject that can used to generate random strings from a given text file.<T> Filler<T>filler(java.util.function.Supplier<T> supplier)Floatsfloats()Returns aFloatsobject than can be used to generate random float numbers.Formatterfmt(java.lang.String fmt)Returns aFormatterobject than can be used to generate arbitrary patterns based on a given format.<T extends java.lang.Enum<?>>
MockUnit<T>from(java.lang.Class<T> enumClass)<T> MockUnit<T>from(java.util.List<T> alphabet)<T> MockUnit<T>from(T[] alphabet)MockUnitDoublefromDoubles(double[] alphabet)MockUnitDoublefromDoubles(java.lang.Double[] alphabet)MockUnitDoublefromDoubles(java.util.List<java.lang.Double> alphabet)MockUnitDoublefromDoublesKeys(java.util.Map<java.lang.Double,?> map)MockUnitDoublefromDoublesValues(java.util.Map<?,java.lang.Double> map)MockUnitIntfromInts(int[] alphabet)MockUnitIntfromInts(java.lang.Integer[] alphabet)MockUnitIntfromInts(java.util.List<java.lang.Integer> alphabet)MockUnitIntfromIntsKeys(java.util.Map<java.lang.Integer,?> map)MockUnitIntfromIntsValues(java.util.Map<?,java.lang.Integer> map)<T> MockUnit<T>fromKeys(java.util.Map<T,?> map)MockUnitLongfromLongs(long[] alphabet)MockUnitLongfromLongs(java.lang.Long[] alphabet)MockUnitLongfromLongs(java.util.List<java.lang.Long> alphabet)MockUnitLongfromLongsKeys(java.util.Map<java.lang.Long,?> map)MockUnitLongfromLongsValues(java.util.Map<?,java.lang.Long> map)MockUnitStringfromStrings(java.lang.String[] alphabet)MockUnitStringfromStrings(java.util.List<java.lang.String> alphabet)MockUnitStringfromStringsKeys(java.util.Map<java.lang.String,?> map)MockUnitStringfromStringsValues(java.util.Map<?,java.lang.String> map)<T> MockUnit<T>fromValues(java.util.Map<?,T> map)Gendersgenders()Returns aGendersobject that can be used to generate "gender" data.java.util.RandomgetRandom()Hasheshashes()ReturnsHashesobject that can be used to generate "hash" strings.IBANsibans()Returns aIBANsobject that can be used to generate valid IBANs codes.Industriesindustries()Returns aIndustriesobject that can be used to generate valid Industry names (Eg.: "Education and Health Services")Intsints()Returns aIntsobject that can be used to generate arbitraryIntegernumbers.IntSeqintSeq()Returns aIntSeqobject that can be used to generate arbitraryIntegernumbers in a sequence.IPv4sipv4s()Returns aIPv4sobject that can be used to generate arbitrary IPv4 addresses.IPv6siPv6s()Returns aIPv6sobject that can be used to generate arbitrary IPv6 addresses.ISSNSissns()Returns aISSNSobject that can be used to generate arbitrary ISSN codes.JazzArtistsjazzArtists()Returns aJazzArtistsobject that can be used to generate arbitrary jazz artists namesLocalDateslocalDates()Returns aLocalDatesobject that can be used to generate arbitraryLocalDateobjects.Longslongs()Returns aLongsobject that can be used to generate arbitraryLongnumbers.LongSeqlongSeq()Returns aLongSeqobject that can be used to generate arbitraryLongnumbers in a sequence.Macsmacs()Returns aMacsobject that can be used to generate arbitrary physical addresses (MAC).Markovsmarkovs()Returns aMarkovsobject that can be used to generate arbitrary text that can pass as almost valid using Markov ChainsMimesmimes()Returns aMimesobject that can be used to generate arbitrary Mime Types (Eg.: "text/html", "image/x-icon", "text/calendar")Moneymoney()Returns aMoneyobject that can be used to generate arbitrary "money" information.Monthsmonths()Returns aMonthsobject that can be used to generate arbitraryMonthobjects.Namesnames()Returns aNamesobject that can be used to generate "names" (full names, first names or last names).NaughtyStringsnaughtyStrings()Returns aNaughtyStringsobject that can be used to generate "naughty strings".ObjectMapobjectMap()Returns a newObjectMapobject that can be used to easily generate json files.static MockNeatold()Re-use the default instance of aMockNeatclass that internally uses the old Random class from the Java Standard Library.Passwordspasswords()Returns aPasswordsobject that can be used to generate arbitrary user passwords.Primesprimes()Returns aPrimesobject that can be used to generate prime numbers (small)<T> Probabilities<T>probabilites(java.lang.Class<T> cls)Returns aProbabilitiesobject that can be used to generate arbitrary data with a given probability.<T> Reflect<T>reflect(java.lang.Class<T> cls)Returns a newReflect<T>object that can be used to fill-up objects through reflectionRegexregex(java.lang.String regex)Returns a newRegexobject that can be used to generate arbitrary text bassed on a certain regex pattern.static MockNeatsecure()Re-use the default instance of aMockNeatclass that internally uses a SecureRandom implementation from the Java Standard Library.<T> Seq<T>seq(java.lang.Iterable<T> iterable)Returns a newSeq<T>object that can be used to generate values by iterating trough the givenIterable<T>in order.Seq<java.lang.String>seq(DictType dictType)Returns a newSeq<String>object that can be used to generate values by iterating through all the lines associated with aDictTypein order.<T> Seq<T>seq(T[] array)Returns aSeq<T>object that can be used to generate values by iterating through all the elements of an arrayShufflersshufflers()Returns aShufflersobject than gets the arbitrary permutations of the source.Spacespace()SQLInsertssqlInserts()Returns aSQLInsertsobject that can be used to generate SQL InsertsSSCssscs()Stringsstrings()static MockNeatthreadLocal()Re-use the default instance of aMockNeatclass that internally uses aThreadLocalRandomimplementation from the Java Standard Library.URLsurls()Usersusers()USStatesusStates()UUIDsuuids()Wordswords()
-
Constructor Details
-
Method Details
-
threadLocal
Re-use the default instance of a
MockNeatclass that internally uses aThreadLocalRandomimplementation from the Java Standard Library.Note: This is the recommended way to obtain a new MockUnit.
- Returns:
- An already instantiated
MockNeatinstance that can be reused.
-
secure
Re-use the default instance of a
MockNeatclass that internally uses a SecureRandom implementation from the Java Standard Library.- Returns:
- An already instantiated
MockNeatinstance that can be reused.
-
old
Re-use the default instance of a
MockNeatclass that internally uses the old Random class from the Java Standard Library.- Returns:
- An already instantiated
MockNeatinstance that can be reused.
-
actors
Returns a
Actorsobject that can be used to generate arbitrary actor names (e.g.: Michael Douglas)- Returns:
- a re-usable
Actorsinstance. This class implementsMockUnitString
-
actresses
Returns a
Actressesobject that can be used to generate arbitrary actresses names (e.g.: Elizabeth Taylor)- Returns:
- a re-usable
Actressesinstance. This class implementsMockUnitString
-
bools
Returns a
Boolsobject that can be used to generate arbitraryBooleanvalues.- Returns:
- A re-usable
Boolsinstance. The class implementsMockUnit<Boolean>.
-
celebrities
-
chars
Returns a
Charsobject that can be used to generate arbitraryCharactervalues.Note: Without any additional constraint, the
Charsobject will generate alphanumeric characters.- Returns:
- A re-usable
Charsinstance. The class implementsMockUnit<Character>.
-
cars
Returns a
Carsobject that can be used to generate arbitrary car names- Returns:
- A re-usable
Carsinstance. The class implementsMockUnitString.
-
cities
Returns a
Citiesobject that can be used to generate arbitrary city names from around the world.- Returns:
- A re-usable
Cititesobject.
-
creatures
Returns a
Creaturesobject that can be used to generate arbitrary creature names.- Returns:
- A re-usable
Creaturesinstance. The class implementsMockUnitString.
-
creditCards
Returns a
CreditCardsobject that can be used to generate valid Credit Card numbers.Note: By default it generates AMERICAN_EXPRESS valid credit card numbers.
Note: Credit card numbers are financial information. The values are generated at random so don't use them in real-life scenarios.
- Returns:
- A re-usable
CreditCardsinstance. The class implementsMockUnitString.
-
constructor
Returns a new
Constructorobject.This method can be used to generate
MockUnit<T>from a Java Bean<T>by accessing it's constructor and supply it with arbitrary input.- Type Parameters:
T- The type ofMockUnit<T>. This is the wrapped type.- Parameters:
cls- The class for type<T>. (Eg.: Student.class)- Returns:
- A new
Constructorobject. TheConstructorclass implementsMockUnit<T>.
-
constant
Returns a new
Constantobject.This method is a
MockUnit<T>used to generate constant values- Type Parameters:
T- The type of the object- Parameters:
object- The constant object to return- Returns:
- The constant object to return
-
countries
Returns a
Countriesobject that can be used to generate country names or country ISO2 codes.- Returns:
- A re-usable
Countriesobject.
-
currencies
Returns a
Currenciesobject that can be used to generate currencies-related information:- Forex pairs. (Eg.: "USD/CAD")
- Currency codes. (Eg.: "USD", "GBP")
- Currency symbols. (Eg.: "$", "¥")
- Currency names. (Eg.: "Boliviano", "Dollar")
- Returns:
- A re-usable
Currenciesobject.
-
csvs
Returns a
CSVsobject that can be used to generate CSV lines or files.- Returns:
- A new CSVs object.
-
cvvs
Returns a
CVVSobject that can be used to generate credit card cvv codes.Note: By default the values generated are 3-digits CVV codes.
- Returns:
- A re-usable
CVVSobject. TheCVVSclass implements theMockUnitStringinterface.
-
dicts
Returns a
Dictsobject that can be used to generate data from the library existing dictionaries.A dictionary is an
enummapping a text file containing a set of dataThe file contents are loaded in memory after the first call.
Check
DictTypeto see the comprehensive list.- Returns:
- A re-usable
Dictsobject.
-
days
Returns a
Daysobject that can be used to generate a randomjava.time.DayOfWeekobject.Note: By default the
Daysobject returns a random day of the week.- Returns:
- A re-usable
Daysobject. TheDaysclass implementsMockUnitDaysinterface.
-
departments
Returns a
Departmentsobject that can be used to generate arbitrary names representing department names from a company.- Returns:
- A re-usable
Departmentsobject. TheDepartmentsclass is implementingMockUnitString.
-
domains
Returns a
that can be used to generate domain names. (eg.: "www", "info")DomainsobjectNote: By default "popular" domains will be generated (like: "com", "org", "net", "edu", "gov", "info", "io")
- Returns:
- A re-usable
Domainsobject. TheDomainsclass implementsMockUnitString
-
doubles
Returns a
Doublesobject that can be used to generate arbitrarydoublevalues.Note: By default the
Doublesobject returns a random double in the [0.0, 1.0) interval.- Returns:
- A re-usable
Doublesobject. TheDoublesclass implementsMockUnitDouble.
-
emails
Returns an
Emailobject that can be used to generate arbitrary email address.- Returns:
- A re-usable
Emailsobject. TheEmailsclass implementsMockUnitString.
-
factory
public <T, FT> Factory<T,FT> factory(java.lang.Class<T> targetCls, java.lang.Class<FT> factoryCls)Returns a new
Factoryobject that can be used to instantiate Java Objects by calling a static factory method and supplying it with arbitrary data.The
Factoryclass implementsMockUnit<T>.- Type Parameters:
T- The type of the target classFT- The type of the factory class- Parameters:
targetCls- The Java class we want to create instances of.factoryCls- The Java class that contains the static-factory method we want to invoke.- Returns:
- The factory MockUnit
-
filler
-
files
Returns a
FromFilesobject that can used to generate random strings from a given text file.Note: The file is loaded in memory. For the moment there is no functionality to "unload" it.
- Returns:
- A re-usable
FromFilesobject.
-
floats
Returns a
Floatsobject than can be used to generate random float numbers.Note: By default it generates float numbers in the [0.0f, 1.0f) range.
- Returns:
- A re-usable
Floatsobject. TheFloatsclass implementsMockUnitFloats.
-
fmt
Returns a
Formatterobject than can be used to generate arbitrary patterns based on a given format.- Parameters:
fmt- The template of the desired pattern.- Returns:
- A new
Formatterobject. TheFormatterclass implementsMockUnitString.
-
genders
Returns a
Gendersobject that can be used to generate "gender" data. (Eg.: "Male", "Female")- Returns:
- A re-usable
Gendersobject. TheGendersclass implementsMockUnitString.
-
hashes
Returns
Hashesobject that can be used to generate "hash" strings.The values are actually computed from arbitrary strings of length 128.
- Returns:
- A re-usable
Hashesobject. TheHashesclass implementsMockUnitString.
-
ibans
Returns a
IBANsobject that can be used to generate valid IBANs codes.- Returns:
- A re-usable
IBANsobject. TheIBANsclass implementsMockUnitString.
-
industries
Returns a
Industriesobject that can be used to generate valid Industry names (Eg.: "Education and Health Services")- Returns:
- A re-usable
Industriesobject. TheIndustriesclass implementsMockUnitString.
-
ints
Returns a
Intsobject that can be used to generate arbitraryIntegernumbers.Internally the method uses the
Random::nextIntimplementation.- Returns:
- A re-usable
Intsobject. TheIntsclass implementsMockUnitInt.
-
intSeq
Returns a
IntSeqobject that can be used to generate arbitraryIntegernumbers in a sequence.- Returns:
- A re-usable
IntSeqobject. TheIntSeqclass implementsMockUnitInt.
-
ipv4s
Returns a
IPv4sobject that can be used to generate arbitrary IPv4 addresses.- Returns:
- A re-usable
IPv4sobject. TheIPv4sclass implementsMockUnitString.
-
iPv6s
Returns a
IPv6sobject that can be used to generate arbitrary IPv6 addresses.- Returns:
- A re-usable
IPv6sobject. TheIPv6sclass implementsMockUnitString.
-
issns
Returns a
ISSNSobject that can be used to generate arbitrary ISSN codes.- Returns:
- A re-usable
ISSNSobject. TheISSNSclass implementsMockUnitString.
-
jazzArtists
Returns a
JazzArtistsobject that can be used to generate arbitrary jazz artists names- Returns:
- a re-usable
JazzArtistsobject. TheJazzArtistsclass implementsMockUnitString
-
localDates
Returns a
LocalDatesobject that can be used to generate arbitraryLocalDateobjects.- Returns:
- A re-usable
LocalDatesobject. TheLocalDatesimplementsMockUnitLocalDate.
-
longs
Returns a
Longsobject that can be used to generate arbitraryLongnumbers.Note:By default the internal
Random.nextLong()will be called.- Returns:
- A re-usable
Longsobject. TheLongsclass extends theMockUnitLongclass.
-
longSeq
Returns a
LongSeqobject that can be used to generate arbitraryLongnumbers in a sequence.- Returns:
- A re-usable
LongSeqobject. TheLongSeqclass implementsMockUnitLong.
-
macs
Returns a
Macsobject that can be used to generate arbitrary physical addresses (MAC).- Returns:
- A re-usable
Macsobject. TheMacsclass implementsMockUnitString.
-
markovs
Returns a
Markovsobject that can be used to generate arbitrary text that can pass as almost valid using Markov ChainsIt can also be used to generate Lorem Ipsum text that is different each time the ending method is invoked
- Returns:
- A re-usable
Markovsobject. TheMarkovsclass implementsMockUnitString
-
mimes
Returns a
Mimesobject that can be used to generate arbitrary Mime Types (Eg.: "text/html", "image/x-icon", "text/calendar")- Returns:
- A re-usable
Mimesobject. TheMimesclass implementsMockUnitString.
-
months
Returns a
Monthsobject that can be used to generate arbitraryMonthobjects.- Returns:
- A re-usable
Monthsobject. TheMonthsclass implementsMockUnitMonth.
-
money
Returns a
Moneyobject that can be used to generate arbitrary "money" information.The generated text represents sums of money generated using
NumberFormat.getCurrencyInstance().format(...).Note:By default it returns a random sum of money
- Returns:
- A re-usable
Moneyobject. TheMoneyclass implementsMockUnitString.
-
names
Returns a
Namesobject that can be used to generate "names" (full names, first names or last names).Note:By default it can be used to generate people full names.
Note: The names are the most common names that appear in the US.
- Returns:
- A re-usable
Namesobject. TheNamesclass implementsMockUnitString.
-
naughtyStrings
Returns a
NaughtyStringsobject that can be used to generate "naughty strings".Please check this URL for more info about the naughty strings:
https://github.com/minimaxir/big-list-of-naughty-strings/blob/master/blns.txt
- Returns:
- A re-usable
NaughtyStringsobject. TheNaughtStringsclass implementsMockUnitString.
-
passwords
Returns a
Passwordsobject that can be used to generate arbitrary user passwords.- Returns:
- A re-usable
Passwordsobject. ThePasswordsclass implementsMockUnitString.
-
primes
Returns a
Primesobject that can be used to generate prime numbers (small)The primes are only generated in this interval [0, 7919]
- Returns:
- A re-usable
Primesobject. ThePrimesclass implementsMockUnitInt
-
regex
Returns a new
Regexobject that can be used to generate arbitrary text bassed on a certain regex pattern.- Parameters:
regex- The regex pattern that the generated string needs to comply.- Returns:
- A new
Regexobject. TheRegexclass implementsMockUnitString.
-
objectMap
Returns a new
ObjectMapobject that can be used to easily generate json files.- Returns:
- An objectMap object used to easily generate json files
-
probabilites
Returns a
Probabilitiesobject that can be used to generate arbitrary data with a given probability.- Type Parameters:
T- The type of the class for returning probabilities- Parameters:
cls- The type we are going to generate.- Returns:
- A re-usable
Probabilitiesobject. The class implementsMockUnit<T>.
-
reflect
Returns a new
Reflect<T>object that can be used to fill-up objects through reflectionCheck
filler(Supplier)as an alternative that doesn't use reflection.- Type Parameters:
T- The generic type of the class- Parameters:
cls- The type of the class you want to construct- Returns:
- A re-usable
Reflect<T>instance. The class implementsMockUnit<T>
-
seq
Returns a new
Seq<T>object that can be used to generate values by iterating trough the givenIterable<T>in order.- Type Parameters:
T- The type of both the resultingSeq<T>and theIterable<T>- Parameters:
iterable- TheIterable<T>values.- Returns:
- A re-usable
Seq<T>object. The class implementsMockUnit<T>
-
seq
Returns a new
Seq<String>object that can be used to generate values by iterating through all the lines associated with aDictTypein order.- Parameters:
dictType- TheDictTypeto iterate over- Returns:
- A re-usable
Seq<String>object. The class implementsMockUnitString
-
seq
Returns a
in order.Seq<T>object that can be used to generate values by iterating through all the elements of an array- Type Parameters:
T- The type of the array- Parameters:
array- The array to iterate over- Returns:
- A re-usable
Seq<T>. The class implementMockUnit<T>
-
sqlInserts
Returns a
SQLInsertsobject that can be used to generate SQL Inserts- Returns:
- A re-usable
SQLInsertsobject. This class implementsMockUnit<SQLInsert>.
-
shufflers
Returns a
Shufflersobject than gets the arbitrary permutations of the source.- Returns:
- A re-usable
Shufflersobject.
-
strings
-
space
-
sscs
-
urls
-
uuids
-
users
-
usStates
-
words
-
getRandom
public java.util.Random getRandom() -
from
-
from
-
from
-
fromKeys
-
fromValues
-
fromInts
-
fromInts
-
fromInts
-
fromIntsValues
-
fromIntsKeys
-
fromDoubles
-
fromDoubles
-
fromDoubles
-
fromDoublesValues
-
fromDoublesKeys
-
fromLongs
-
fromLongs
-
fromLongs
-
fromLongsValues
-
fromLongsKeys
-
fromStrings
-
fromStrings
-
fromStringsValues
-
fromStringsKeys
-