├── .github ├── FUNDING.yml └── dependabot.yml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SPECIAL_THANKS.md ├── VERSIONS ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── logo ├── facebook_cover_photo_1.png ├── facebook_cover_photo_2.png ├── facebook_profile_image.png ├── favicon.png ├── instagram_profile_image.png ├── linkedin_banner_image_1.png ├── linkedin_banner_image_2.png ├── linkedin_profile_image.png ├── logo.png ├── logo_transparent.png ├── pinterest_board_photo.png ├── pinterest_profile_image.png ├── twitter_header_photo_1.png ├── twitter_header_photo_2.png ├── twitter_profile_image.png └── youtube_profile_image.png ├── scripts └── capitalize-awk ├── settings.gradle └── src ├── main ├── java │ └── net │ │ └── andreinc │ │ └── mockneat │ │ ├── MockNeat.java │ │ ├── abstraction │ │ ├── MockConstValue.java │ │ ├── MockUnit.java │ │ ├── MockUnitBase.java │ │ ├── MockUnitDays.java │ │ ├── MockUnitDouble.java │ │ ├── MockUnitFloat.java │ │ ├── MockUnitInt.java │ │ ├── MockUnitLocalDate.java │ │ ├── MockUnitLong.java │ │ ├── MockUnitMonth.java │ │ ├── MockUnitString.java │ │ ├── MockUnitValue.java │ │ └── MockValue.java │ │ ├── alphabets │ │ ├── Alphabets.java │ │ └── Colors.java │ │ ├── types │ │ ├── CallBack.java │ │ ├── Pair.java │ │ ├── Range.java │ │ ├── TriConsumer.java │ │ └── enums │ │ │ ├── CVVType.java │ │ │ ├── CelebrityType.java │ │ │ ├── CharsType.java │ │ │ ├── CreditCardType.java │ │ │ ├── CurrencySymbolType.java │ │ │ ├── DictType.java │ │ │ ├── DomainSuffixType.java │ │ │ ├── HostNameType.java │ │ │ ├── IBANType.java │ │ │ ├── IPv4Type.java │ │ │ ├── MACAddressFormatType.java │ │ │ ├── MarkovChainType.java │ │ │ ├── NameType.java │ │ │ ├── PassStrengthType.java │ │ │ ├── RandomType.java │ │ │ ├── SpaceType.java │ │ │ ├── StringFormatType.java │ │ │ ├── StringType.java │ │ │ ├── URLSchemeType.java │ │ │ ├── UserNameType.java │ │ │ └── WordsType.java │ │ ├── unit │ │ ├── address │ │ │ ├── Addresses.java │ │ │ ├── Cities.java │ │ │ ├── Countries.java │ │ │ └── USStates.java │ │ ├── celebrities │ │ │ ├── Actors.java │ │ │ ├── Actresses.java │ │ │ ├── Celebrities.java │ │ │ ├── JazzArtists.java │ │ │ ├── RockStars.java │ │ │ ├── UKPrimeMinisters.java │ │ │ └── USPresidents.java │ │ ├── companies │ │ │ ├── Companies.java │ │ │ ├── Departments.java │ │ │ └── Industries.java │ │ ├── financial │ │ │ ├── CVVS.java │ │ │ ├── CreditCards.java │ │ │ ├── Currencies.java │ │ │ ├── IBANs.java │ │ │ └── Money.java │ │ ├── hashes │ │ │ └── Hashes.java │ │ ├── id │ │ │ └── UUIDs.java │ │ ├── misc │ │ │ ├── Cars.java │ │ │ ├── Creatures.java │ │ │ ├── ISSNS.java │ │ │ ├── Mimes.java │ │ │ └── SSCs.java │ │ ├── networking │ │ │ ├── Domains.java │ │ │ ├── IPv4s.java │ │ │ ├── IPv6s.java │ │ │ ├── Macs.java │ │ │ └── URLs.java │ │ ├── objects │ │ │ ├── Constant.java │ │ │ ├── Constructor.java │ │ │ ├── Factory.java │ │ │ ├── Filler.java │ │ │ ├── From.java │ │ │ ├── Froms.java │ │ │ ├── ObjectMap.java │ │ │ ├── Probabilities.java │ │ │ ├── Reflect.java │ │ │ └── Shufflers.java │ │ ├── regex │ │ │ └── Regex.java │ │ ├── seq │ │ │ ├── IntSeq.java │ │ │ ├── LongSeq.java │ │ │ └── Seq.java │ │ ├── text │ │ │ ├── CSVs.java │ │ │ ├── Dicts.java │ │ │ ├── Formatter.java │ │ │ ├── FromFiles.java │ │ │ ├── Markovs.java │ │ │ ├── NaughtyStrings.java │ │ │ ├── SQLInserts.java │ │ │ ├── Space.java │ │ │ ├── Strings.java │ │ │ ├── Words.java │ │ │ └── sql │ │ │ │ ├── SQLEscaper.java │ │ │ │ ├── SQLInsert.java │ │ │ │ ├── SQLTable.java │ │ │ │ └── escapers │ │ │ │ ├── Generic.java │ │ │ │ ├── MySQL.java │ │ │ │ └── PostgreSQL.java │ │ ├── time │ │ │ ├── Days.java │ │ │ ├── LocalDates.java │ │ │ └── Months.java │ │ ├── types │ │ │ ├── Bools.java │ │ │ ├── Chars.java │ │ │ ├── Doubles.java │ │ │ ├── Floats.java │ │ │ ├── Ints.java │ │ │ ├── Longs.java │ │ │ └── Primes.java │ │ └── user │ │ │ ├── Emails.java │ │ │ ├── Genders.java │ │ │ ├── Names.java │ │ │ ├── NonBinaryGenders.java │ │ │ ├── Passwords.java │ │ │ └── Users.java │ │ └── utils │ │ ├── DateUtils.java │ │ ├── FormatUtils.java │ │ ├── LoopsUtils.java │ │ ├── MockUnitUtils.java │ │ ├── SqlEscapeUtils.java │ │ ├── ValidationUtils.java │ │ └── file │ │ └── FileManager.java ├── main.iml └── resources │ ├── capitalize-awk │ ├── dicts │ ├── actors │ ├── actresses │ ├── american-presidents │ ├── car-brands │ ├── cities │ │ ├── cities-capitals │ │ ├── cities-capitals-africa │ │ ├── cities-capitals-america │ │ ├── cities-capitals-asia │ │ ├── cities-capitals-australia-and-oceania │ │ ├── cities-capitals-europe │ │ └── cities-us │ ├── companies-sp500 │ ├── country-iso-code-2 │ ├── country-name │ ├── creatures │ ├── credit-card-names │ ├── departments │ ├── domain-email │ ├── domain-top-level-all │ ├── domain-top-level-popular │ ├── first-names-american-female │ ├── first-names-american-male │ ├── forex-pairs │ ├── industries │ ├── jazz-artists │ ├── last-names-american │ ├── mimetypes │ ├── naughtystrings │ │ ├── cvevulnerabilities │ │ ├── emoji │ │ ├── fileinclusions │ │ ├── inconousstrings │ │ ├── japaneseemoji │ │ ├── msdosspecialfilenames │ │ ├── numeric │ │ ├── quotations │ │ ├── regionalindicators │ │ ├── reservedkeywords │ │ ├── righttoleftstrings │ │ ├── rubyinjection │ │ ├── scriptinjection │ │ ├── servercodeinjection │ │ ├── specialchars │ │ ├── sqlinjection │ │ ├── trickunicode │ │ ├── twobytechars │ │ ├── unicodefont │ │ ├── unicodenumbers │ │ ├── unicodesubsuperscript │ │ ├── unicodesymbols │ │ ├── unicodeupsidedown │ │ ├── unwantedinterpolation │ │ ├── xmlinjection │ │ └── zalgotext │ ├── non-binary-genders │ ├── rock-stars │ ├── space │ │ ├── constellations │ │ ├── galaxies │ │ ├── moons │ │ ├── nebulas │ │ ├── planets │ │ └── stars │ ├── uk-primeministers │ ├── us-states │ ├── us-states-iso2 │ └── words │ │ ├── en-adjective-1syll │ │ ├── en-adjective-2syll │ │ ├── en-adjective-3syll │ │ ├── en-adjective-4syll │ │ ├── en-adverb-1syll │ │ ├── en-adverb-2syll │ │ ├── en-adverb-3syll │ │ ├── en-adverb-4syll │ │ ├── en-noun-1syll │ │ ├── en-noun-2syll │ │ ├── en-noun-3syll │ │ ├── en-noun-4syll │ │ ├── en-verb-1syll │ │ ├── en-verb-2syll │ │ ├── en-verb-3syll │ │ └── en-verb-4syll │ └── markov │ ├── kafka │ └── loremipsum └── test ├── java └── net │ └── andreinc │ └── mockneat │ ├── Constants.java │ ├── abstraction │ ├── MockConstValueTest.java │ ├── MockFromFunctionsTest.java │ ├── MockUnitArrayMethodTest.java │ ├── MockUnitBaseTest.java │ ├── MockUnitCollectionMethodTest.java │ ├── MockUnitConsumeTest.java │ ├── MockUnitDaysTest.java │ ├── MockUnitDictsTest.java │ ├── MockUnitDoubleTest.java │ ├── MockUnitGenericComposeTest.java │ ├── MockUnitIntTest.java │ ├── MockUnitListMethodTest.java │ ├── MockUnitLocalDateTest.java │ ├── MockUnitMapKeysMethodTest.java │ ├── MockUnitMapMethodTest.java │ ├── MockUnitMapValsMethodTest.java │ ├── MockUnitMonthTest.java │ ├── MockUnitSerializeTest.java │ ├── MockUnitSetMethodTest.java │ ├── MockUnitStringTest.java │ ├── MockUnitValAndGetMethodTest.java │ ├── MockUnitValAndGetStrMethodTest.java │ ├── MockUnitValueTest.java │ └── models │ │ ├── AbstractListNoInstance.java │ │ ├── AbstractMapNoInstance.java │ │ ├── AbstractSetNoInstance.java │ │ ├── ClassicPojo.java │ │ └── ToString.java │ ├── unit │ ├── address │ │ ├── CitiesTest.java │ │ ├── CountriesTest.java │ │ └── USStatesTest.java │ ├── companies │ │ ├── CompaniesTest.java │ │ ├── DepartmentsTest.java │ │ └── IndustriesTest.java │ ├── financial │ │ ├── CVVSTest.java │ │ ├── CreditCardsTest.java │ │ ├── CurrenciesTest.java │ │ ├── IBANsTest.java │ │ └── MoneyTest.java │ ├── hashes │ │ ├── MD2sTest.java │ │ ├── MD5sTest.java │ │ ├── SHA1sTest.java │ │ ├── SHA256sTest.java │ │ ├── SHA384sTest.java │ │ └── SHA512sTest.java │ ├── misc │ │ ├── ISSNSTest.java │ │ ├── MimesTest.java │ │ └── SSCsTest.java │ ├── networking │ │ ├── DomainsTest.java │ │ ├── IPv4sTest.java │ │ ├── IPv6sTest.java │ │ ├── MacsTest.java │ │ └── URLsTest.java │ ├── objects │ │ ├── ConstantTest.java │ │ ├── ConstructorTest.java │ │ ├── FactoryTest.java │ │ ├── FillerTest.java │ │ ├── ObjectMapTest.java │ │ ├── ProbabilitiesTest.java │ │ ├── ReflectTest.java │ │ ├── ShufflersTest.java │ │ └── model │ │ │ ├── Customer1.java │ │ │ ├── FactoryMethods.java │ │ │ ├── FinalValue.java │ │ │ ├── MultipleConstructors.java │ │ │ ├── SerialPojo.java │ │ │ ├── SimpleBean.java │ │ │ └── TheAbstractClass.java │ ├── regex │ │ └── RegexTest.java │ ├── seq │ │ ├── IntSeqTest.java │ │ ├── LongSeqTest.java │ │ └── SeqTest.java │ ├── text │ │ ├── CSVsTest.java │ │ ├── CreaturesTest.java │ │ ├── FormatterTest.java │ │ ├── FromFilesTest.java │ │ ├── MarkovsTest.java │ │ ├── StringsTest.java │ │ └── WordsTest.java │ ├── time │ │ ├── DaysTest.java │ │ ├── LocalDatesTest.java │ │ └── MonthsTest.java │ ├── types │ │ ├── BoolsTest.java │ │ ├── CharsTest.java │ │ ├── DoublesTest.java │ │ ├── FloatsTest.java │ │ ├── IntsTest.java │ │ └── LongsTest.java │ └── user │ │ ├── EmailsTest.java │ │ ├── GendersTest.java │ │ ├── NamesTest.java │ │ ├── NonBinaryGenderTest.java │ │ ├── PasswordsTest.java │ │ └── UsersTest.java │ └── utils │ ├── LuhnUtils.java │ ├── MapCheckUtils.java │ └── NamesCheckUtils.java └── test.iml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: nomemory 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: gradle 4 | directory: "/" 5 | schedule: 6 | interval: weekly 7 | time: "03:00" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradlew 2 | .gradlew.bat 3 | .gradle/* 4 | !gradle/wrapper/gradle-wrapper.jar 5 | .idea/* 6 | build/* 7 | /bin/ 8 | .classpath 9 | .project 10 | .settings/ 11 | src/main/main.iml 12 | src/main/test.iml 13 | gradle.properties -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk9 4 | before_install: 5 | - chmod +x gradlew 6 | before_script: 7 | - chmod +x gradlew 8 | script: 9 | - ./gradlew check 10 | - ./gradlew jacocoTestReport 11 | after_success: 12 | - bash <(curl -s https://codecov.io/bash) -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | For more information on how you can contribute to the development of the library please visit our dedicated wiki page: 2 | https://github.com/nomemory/mockneat/wiki/Contributing 3 | -------------------------------------------------------------------------------- /SPECIAL_THANKS.md: -------------------------------------------------------------------------------- 1 | ### MockNeat Special Thanks 2 | 3 | 1. A cool list of "naughty strings" was found on github, thank you, minimaxir: 4 | https://github.com/minimaxir/big-list-of-naughty-strings/blob/master/blns.txt 5 | 6 | 2. A cool library that was used for the `regExp()` method, thank you, mifmif: 7 | https://github.com/mifmif/Generex 8 | 9 | 3. Apache Foundation for their great libraries! -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ossrhUsername=nomemory 2 | ossrhPassword= 3 | 4 | signing.keyId= 5 | signing.password= 6 | signing.secretKeyRingFile=/Users/andreiciobanu/Keys/secret-keys.gpg -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /logo/facebook_cover_photo_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/facebook_cover_photo_1.png -------------------------------------------------------------------------------- /logo/facebook_cover_photo_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/facebook_cover_photo_2.png -------------------------------------------------------------------------------- /logo/facebook_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/facebook_profile_image.png -------------------------------------------------------------------------------- /logo/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/favicon.png -------------------------------------------------------------------------------- /logo/instagram_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/instagram_profile_image.png -------------------------------------------------------------------------------- /logo/linkedin_banner_image_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/linkedin_banner_image_1.png -------------------------------------------------------------------------------- /logo/linkedin_banner_image_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/linkedin_banner_image_2.png -------------------------------------------------------------------------------- /logo/linkedin_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/linkedin_profile_image.png -------------------------------------------------------------------------------- /logo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/logo.png -------------------------------------------------------------------------------- /logo/logo_transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/logo_transparent.png -------------------------------------------------------------------------------- /logo/pinterest_board_photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/pinterest_board_photo.png -------------------------------------------------------------------------------- /logo/pinterest_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/pinterest_profile_image.png -------------------------------------------------------------------------------- /logo/twitter_header_photo_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/twitter_header_photo_1.png -------------------------------------------------------------------------------- /logo/twitter_header_photo_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/twitter_header_photo_2.png -------------------------------------------------------------------------------- /logo/twitter_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/twitter_profile_image.png -------------------------------------------------------------------------------- /logo/youtube_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomemory/mockneat/619844a492b0388e821adc92686532ad0e456572/logo/youtube_profile_image.png -------------------------------------------------------------------------------- /scripts/capitalize-awk: -------------------------------------------------------------------------------- 1 | # This script can be used to capitalize all the lines from 2 | # a text file. 3 | 4 | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2)) }' -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'mockneat' 2 | 3 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/abstraction/MockConstValue.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. PARAM NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER PARAM AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | public final class MockConstValue implements MockValue { 20 | 21 | private final T value; 22 | 23 | private MockConstValue(T value) { 24 | this.value = value; 25 | } 26 | 27 | /** 28 | *

Creates a new "constant" MockValue by wrapping an Object value.

29 | * 30 | * @param Generic type for the constant value 31 | * @param value The Object wrapped by the {@code MockConstantValue} class. 32 | * @return A new MockConstValue. 33 | */ 34 | public static MockConstValue constant(T value) { 35 | return new MockConstValue<>(value); 36 | } 37 | 38 | /** 39 | * @return The wrapped Object value. 40 | */ 41 | @Override 42 | public T get() { 43 | return value; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/abstraction/MockUnitBase.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import static org.apache.commons.lang3.Validate.notNull; 5 | 6 | /** 7 | * An abstract class containing a MockNeat reference. 8 | * Most of the MockUnit implementations also extend from this base class. 9 | */ 10 | public abstract class MockUnitBase { 11 | 12 | protected final MockNeat mockNeat; 13 | 14 | public MockUnitBase(MockNeat mockNeat) { 15 | notNull(mockNeat, "mockNeat"); 16 | this.mockNeat = mockNeat; 17 | } 18 | 19 | /** 20 | * By default the MockUnitBase is using {@code MockNeat.threadLocal()} as the internal MockNeat implementation. 21 | */ 22 | public MockUnitBase() { 23 | this.mockNeat = MockNeat.threadLocal(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/abstraction/MockUnitDouble.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | 4 | import net.andreinc.mockneat.utils.ValidationUtils; 5 | 6 | import java.util.function.Supplier; 7 | import java.util.stream.DoubleStream; 8 | 9 | import static java.util.stream.IntStream.range; 10 | import static net.andreinc.mockneat.utils.ValidationUtils.isTrue; 11 | 12 | public interface MockUnitDouble extends MockUnit { 13 | 14 | /** 15 | *

Transforms an existing {@code MockUnitDouble} into a {@code MockUnit}.

16 | * 17 | *

The DoubleStream will be "infinite" and will contain values generated by the internal {@code MockUnitDouble} supplier.

18 | * 19 | * @return A new {@code MockUnit} 20 | */ 21 | default MockUnit doubleStream() { 22 | Supplier supp = () -> DoubleStream.generate(supplier()::get); 23 | return () -> supp; 24 | } 25 | 26 | /** 27 | *

Transforms an existing {@code MockUnitDouble} into a {@code MockUnit}.

28 | * 29 | *

The values in the array will be generated using the {@code MockUnitDouble} supplier.

30 | * 31 | * @param size The size of the array. 32 | * @return A new {@code MockUnit} 33 | */ 34 | default MockUnit arrayPrimitive(int size) { 35 | isTrue(size>=0, ValidationUtils.SIZE_BIGGER_THAN_ZERO); 36 | Supplier supp = () -> { 37 | final double[] result = new double[size]; 38 | range(0, size).forEach(i -> result[i] = val()); 39 | return result; 40 | }; 41 | return () -> supp; 42 | } 43 | 44 | /** 45 | *

Transforms an existing {@code MockUnitDouble} into a {@code MockUnit}

46 | * 47 | *

The values in the array will be generated using the {@code MockUnitDouble} supplier.

48 | * 49 | * @param size The size of the array 50 | * @return A new {@code MockUnit} 51 | */ 52 | default MockUnit array(int size) { 53 | isTrue(size>=0, ValidationUtils.SIZE_BIGGER_THAN_ZERO); 54 | Supplier supp = () -> { 55 | final Double[] result = new Double[size]; 56 | range(0, size).forEach(i -> result[i] = val()); 57 | return result; 58 | }; 59 | return () -> supp; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/abstraction/MockUnitInt.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | 4 | import net.andreinc.mockneat.utils.ValidationUtils; 5 | 6 | import java.util.function.Supplier; 7 | import java.util.stream.IntStream; 8 | 9 | import static java.util.stream.IntStream.generate; 10 | import static java.util.stream.IntStream.range; 11 | import static net.andreinc.mockneat.utils.ValidationUtils.isTrue; 12 | 13 | public interface MockUnitInt extends MockUnit { 14 | 15 | /** 16 | *

Transforms an existing {@code MockUnitInt} into a {@code MockUnit}.

17 | * 18 | *

The {@code IntStream} will be "infinite" and will contain values generated by the internal {@code MockUnitInt} supplier.

19 | * 20 | * @return A new {@code MockUnit} 21 | */ 22 | default MockUnit intStream() { 23 | Supplier supp = () -> generate(supplier()::get); 24 | return () -> supp; 25 | } 26 | 27 | /** 28 | *

Transforms an existing {@code MockUnitInt} into a {@code MockUnit}.

29 | * 30 | *

The values in the array will be generated using the {@code MockUnitInt} supplier.

31 | * 32 | * @param size The size of the Array 33 | * @return A new {@code MockUnit} 34 | */ 35 | default MockUnit arrayPrimitive(int size) { 36 | isTrue(size>=0, ValidationUtils.SIZE_BIGGER_THAN_ZERO); 37 | Supplier supp = () -> { 38 | final int[] result = new int[size]; 39 | range(0, size).forEach(i -> result[i] = val()); 40 | return result; 41 | }; 42 | return () -> supp; 43 | } 44 | 45 | /** 46 | *

Transforms an existing {@code MockUnitInt} into a {@code MockUnit}.

47 | * 48 | *

The values in the array will be generated using the {@code MockUnitInt} supplier.

49 | * 50 | * @param size The size of the Array 51 | * @return A new {@code MockUnit} 52 | */ 53 | default MockUnit array(int size) { 54 | isTrue(size>=0, ValidationUtils.SIZE_BIGGER_THAN_ZERO); 55 | Supplier supp = () -> { 56 | final Integer[] result = new Integer[size]; 57 | range(0, size).forEach(i -> result[i] = val()); 58 | return result; 59 | }; 60 | return () -> supp; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/abstraction/MockUnitLong.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.utils.ValidationUtils; 4 | 5 | import java.util.function.Supplier; 6 | import java.util.stream.LongStream; 7 | 8 | import static java.util.stream.IntStream.range; 9 | import static net.andreinc.mockneat.utils.ValidationUtils.isTrue; 10 | 11 | public interface MockUnitLong extends MockUnit { 12 | 13 | /** 14 | *

Transforms an existing {@code MockUnitLong} into a {@code MockUnit}.

15 | * 16 | *

The {@code LongStream} will be "infinite" and will contain values generated by the internal {@code MockUnitLong} supplier.

17 | * 18 | * @return A new {@code MockUnit} 19 | */ 20 | default MockUnit longStream() { 21 | Supplier supp = () -> LongStream.generate(supplier()::get); 22 | return () -> supp; 23 | } 24 | 25 | /** 26 | *

Transforms an existing {@code MockUnitLong} into a {@code MockUnit}.

27 | * 28 | *

The values in the array will be generated using the {@code MockUnitLong} supplier.

29 | * 30 | * @param size The size of the Array 31 | * @return A new {@code MockUnit} 32 | */ 33 | default MockUnit arrayPrimitive(int size) { 34 | isTrue(size>=0, ValidationUtils.SIZE_BIGGER_THAN_ZERO); 35 | Supplier supp = () -> { 36 | long[] array = new long[size]; 37 | range(0, size).forEach(i -> array[i] = val()); 38 | return array; 39 | }; 40 | return () -> supp; 41 | } 42 | 43 | /** 44 | *

Transforms an existing {@code MockUnitLong} into a {@code MockUnit}.

45 | * 46 | *

The values in the array will be generated using the {@code MockUnitLong} supplier.

47 | * 48 | * @param size The size of the Array 49 | * @return A new {@code MockUnit} 50 | */ 51 | default MockUnit array(int size) { 52 | isTrue(size>=0, ValidationUtils.SIZE_BIGGER_THAN_ZERO); 53 | Supplier supp = () -> { 54 | final Long[] result = new Long[size]; 55 | range(0, size).forEach(i -> result[i] = val()); 56 | return result; 57 | }; 58 | return () -> supp; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/abstraction/MockUnitMonth.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import java.time.Month; 4 | import java.time.format.TextStyle; 5 | import java.util.Locale; 6 | import java.util.function.Supplier; 7 | 8 | import static java.time.format.TextStyle.FULL; 9 | import static net.andreinc.mockneat.utils.ValidationUtils.notNull; 10 | 11 | public interface MockUnitMonth extends MockUnit { 12 | 13 | /** 14 | *

Transforms the current {@code MockUnitMonth} into a {@code MOckUnitString} representing the textual representation of the {@code Month} (Eg.: 'Jan' for January).

15 | * 16 | * @param textStyle The style used to represent the day of the week. (Eg.: If we use {@code TextStyle.SHORT} the value for 'January' will be 'Jan') 17 | * @param locale The locale to use in order to represent the days of the week. (Eg.: If we use {@code Locale.ENGLISH} and {@code TextStyle.FULL} the value for January will be 'January'). 18 | * @return A new {@code MockUnitString} 19 | */ 20 | default MockUnitString display(TextStyle textStyle, Locale locale) { 21 | notNull(textStyle, "textStyle"); 22 | notNull(locale, "locale"); 23 | Supplier supp = () -> supplier().get().getDisplayName(textStyle, locale); 24 | return () -> supp; 25 | } 26 | 27 | /** 28 | *

Transforms the current {@code MockUnitMonth} into a {@code MOckUnitString} representing the textual representation of the {@code Month} (Eg.: 'Jan' for January).

29 | * 30 | *

Note: The default locale will be {@code Locale.ENGLISH}

31 | * 32 | * @param textStyle The style used to represent the day of the week. (Eg.: If we use {@code TextStyle.SHORT} the value for 'January' will be 'Jan') 33 | * @return A new {@code MockUnitString} 34 | */ 35 | default MockUnitString display(TextStyle textStyle) { 36 | return display(textStyle, Locale.ENGLISH); 37 | } 38 | 39 | /** 40 | *

Transforms the current {@code MockUnitMonth} into a {@code MOckUnitString} representing the textual representation of the {@code Month} (Eg.: 'Jan' for January).

41 | * 42 | *

Note: The default locale will be {@code Locale.ENGLISH}

43 | * 44 | *

Note: The default locale will be {@code TextStyle.FULL}

45 | * @return A new {@code MockUnitString} 46 | */ 47 | default MockUnitString display() { 48 | return display(FULL); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/abstraction/MockUnitValue.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | public final class MockUnitValue implements MockValue { 21 | 22 | private final MockUnit mockUnit; 23 | 24 | private MockUnitValue(MockUnit mockUnit) { 25 | this.mockUnit = mockUnit; 26 | } 27 | 28 | /** 29 | * Wraps a {@code MockUnit}. 30 | * @param unit The {@code MockUnit} to be wrapped. 31 | * @param generic param for the MockUnit 32 | * @return A new {@code MockUnitValue} 33 | */ 34 | public static MockUnitValue unit(MockUnit unit) { 35 | return new MockUnitValue<>(unit); 36 | } 37 | 38 | /** 39 | * Retrieves one value generated by the wrapped {@code MockUnit}. 40 | * @return An Object value generated by the {@code MockUnit} 41 | */ 42 | @Override 43 | public T get() { 44 | return mockUnit.supplier().get(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/abstraction/MockValue.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software.MockValue 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. PARAM NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER PARAM AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | public interface MockValue { 21 | 22 | T get(); 23 | 24 | default String getStr() { 25 | Object obj = get(); 26 | if (null==obj) { return ""; } 27 | else { return obj.toString(); } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/CallBack.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, OUT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | @FunctionalInterface 21 | public interface CallBack { 22 | void call(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/Pair.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, OUT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | /** 21 | * A simple Pair (or Tuple implementation). 22 | * @param The type of the first member 23 | * @param The type of the second member 24 | */ 25 | public class Pair { 26 | 27 | private final T1 first; 28 | private final T2 second; 29 | 30 | public Pair(T1 first, T2 second) { 31 | this.first = first; 32 | this.second = second; 33 | } 34 | 35 | public static Pair of(T1 first, T2 second) { 36 | return new Pair<>(first, second); 37 | } 38 | 39 | /** 40 | * @return the first member of the {@code Pair}. 41 | */ 42 | public T1 getFirst() { 43 | return first; 44 | } 45 | 46 | /** 47 | * @return the second member fo the {@code Pair} 48 | */ 49 | public T2 getSecond() { 50 | return second; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/Range.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, OUT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | /** 21 | * A simple model class encapsulating a Range between two numbers. 22 | * @param The type of the number 23 | */ 24 | public class Range { 25 | 26 | private final T lowerBound; 27 | private final T upperBound; 28 | 29 | public Range(T lowerBound, T upperBound) { 30 | this.lowerBound = lowerBound; 31 | this.upperBound = upperBound; 32 | } 33 | 34 | public T getLowerBound() { 35 | return lowerBound; 36 | } 37 | 38 | public T getUpperBound() { 39 | return upperBound; 40 | } 41 | 42 | public Boolean isConstant() { return lowerBound.equals(upperBound); } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/TriConsumer.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, OUT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | @FunctionalInterface 21 | public interface TriConsumer { 22 | void consume(T t, U u, R r); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/CVVType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, OUT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | @SuppressWarnings("ImmutableEnumChecker") 21 | public enum CVVType { 22 | CVV3(3), 23 | CVV4(4); 24 | 25 | private final Integer length; 26 | 27 | CVVType(Integer length) { 28 | this.length = length; 29 | } 30 | 31 | public Integer getLength() { 32 | return length; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/CelebrityType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | public enum CelebrityType { 4 | ACTORS(new DictType[]{ DictType.ACTORS }), 5 | ACTRESSES(new DictType[]{ DictType.ACTRESSES }), 6 | JAZZ_ARTISTS(new DictType[]{ DictType.JAZZ_ARTISTS }), 7 | ROCK_STARS(new DictType[]{ DictType.ROCK_STARS }), 8 | UK_PRIME_MINISTERS(new DictType[]{ DictType.UK_PRIME_MINISTERS }), 9 | US_PRESIDENTS(new DictType[]{ DictType.US_PRESIDENTS }), 10 | 11 | // COMPOSED 12 | 13 | SINGERS(new DictType[]{ 14 | DictType.ROCK_STARS, 15 | DictType.JAZZ_ARTISTS 16 | }), 17 | 18 | POLITICIANS(new DictType[]{ 19 | DictType.US_PRESIDENTS, 20 | DictType.UK_PRIME_MINISTERS 21 | }); 22 | 23 | private final DictType[] dictionaries; 24 | 25 | CelebrityType(DictType[] dictionaries) { 26 | this.dictionaries = dictionaries; 27 | } 28 | 29 | public DictType[] getDictionaries() { 30 | return dictionaries; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/CharsType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. PARAM NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER PARAM AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | 21 | @SuppressWarnings("ImmutableEnumChecker") 22 | public enum CharsType { 23 | DIGITS, 24 | LOWER_LETTERS, 25 | UPPER_LETTERS, 26 | LETTERS, 27 | HEX, 28 | ALPHA_NUMERIC 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/CreditCardType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | 4 | import java.util.Arrays; 5 | import java.util.LinkedList; 6 | import java.util.List; 7 | 8 | import static java.util.Collections.unmodifiableList; 9 | import static java.util.stream.Collectors.toList; 10 | 11 | @SuppressWarnings("ImmutableEnumChecker") 12 | public enum CreditCardType { 13 | 14 | AMERICAN_EXPRESS(15, 34, 37), 15 | CHINA_UNION_PAY_16(16, 62), 16 | CHINA_UNION_PAY_17(17, 62), 17 | CHINA_UNION_PAY_18(18, 62), 18 | CHINA_UNION_PAY_19(19, 62), 19 | DINERS_CLUB_CARTE_BLANCHE(14, 300, 301, 302, 303, 304, 305), 20 | DINERS_CLUB_INTERNATIONAL(14, 309, 36, 38, 39), 21 | DISCOVER_16(16, 6011, 644, 645, 646, 647, 648, 649, 65), 22 | DISCOVER_19(19, 6011, 644, 645, 646, 647, 648, 649, 65), 23 | INTER_PAYMENT_16(16, 636), 24 | INTER_PAYMENT_19(19, 636), 25 | INSTA_PAYMENT(16, 637, 638, 639), 26 | JCB(16, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3544, 3545, 3546, 3547, 3548, 3549, 3550), 27 | MAESTRO_12(12, 56, 57, 58, 6), 28 | MAESTRO_13(13, 56, 57, 58, 6), 29 | MAESTRO_14(14, 56, 57, 58, 6), 30 | MAESTRO_15(15, 56, 57, 58, 6), 31 | MAESTRO_16(16, 56, 57, 58, 6), 32 | MAESTRO_17(17, 56, 57, 58, 6), 33 | MAESTRO_18(18, 56, 57, 58, 6), 34 | MAESTRO_19(19, 56, 57, 58, 6), 35 | MASTERCARD(16, 2221, 2720, 51, 52, 53, 54, 55), 36 | VISA_13(13, 4), 37 | VISA_16(16, 4), 38 | VISA_19(19, 4); 39 | 40 | private final Integer length; 41 | 42 | private final List> prefixes; 43 | 44 | CreditCardType(Integer length, Integer... prefixes) { 45 | this.length = length; 46 | this.prefixes = 47 | unmodifiableList(Arrays.stream(prefixes) 48 | .map(this::fromNumber) 49 | .collect(toList())); 50 | } 51 | 52 | public List> getPrefixes() { 53 | return prefixes; 54 | } 55 | 56 | public Integer getLength() { return length; } 57 | 58 | private List fromNumber(int num) { 59 | List list = new LinkedList<>(); 60 | int tmp = num; 61 | while(tmp!=0) { 62 | list.add(0, tmp%10); 63 | tmp/=10; 64 | } 65 | return unmodifiableList(list); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/DomainSuffixType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | import static net.andreinc.mockneat.types.enums.DictType.DOMAIN_TOP_LEVEL_ALL; 4 | import static net.andreinc.mockneat.types.enums.DictType.DOMAIN_TOP_LEVEL_POPULAR; 5 | 6 | @SuppressWarnings("ImmutableEnumChecker") 7 | public enum DomainSuffixType { 8 | 9 | ALL(DOMAIN_TOP_LEVEL_ALL), POPULAR(DOMAIN_TOP_LEVEL_POPULAR); 10 | 11 | private final DictType dictType; 12 | 13 | DomainSuffixType(DictType dictType) { 14 | this.dictType = dictType; 15 | } 16 | 17 | public DictType getDictType() { 18 | return dictType; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/IPv4Type.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | import net.andreinc.mockneat.types.Range; 4 | 5 | @SuppressWarnings("ImmutableEnumChecker") 6 | public enum IPv4Type { 7 | CLASS_A (new Range<>(1, 126), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255)), 8 | CLASS_A_LOOPBACK (new Range<>(127, 127), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255)), 9 | CLASS_A_PRIVATE (new Range<>(10, 10), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255)), 10 | CLASS_A_NONPRIVATE (new Range<>(1, 126), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255), false), 11 | CLASS_B (new Range<>(128, 191), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255)), 12 | CLASS_B_PRIVATE (new Range<>(172, 172), new Range<>(16, 31), new Range<>(0, 255), new Range<>(0, 255)), 13 | CLASS_B_NONPRIVATE (new Range<>(128, 191), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255), false), 14 | CLASS_C (new Range<>(192, 223), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255)), 15 | CLASS_C_PRIVATE (new Range<>(192, 192), new Range<>(168, 168), new Range<>(0, 255), new Range<>(0, 255)), 16 | CLASS_C_NONPRIVATE (new Range<>(192, 223), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255), false), 17 | CLASS_D (new Range<>(224, 239), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255)), 18 | CLASS_E (new Range<>(240, 254), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255)), 19 | NO_CONSTRAINT(new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255), new Range<>(0, 255)); 20 | 21 | private final Range[] octets; 22 | private final boolean privateAllowed; 23 | 24 | IPv4Type(Range o1, Range o2, Range o3, Range o4, boolean privateAllowed) { 25 | //noinspection unchecked 26 | this.octets = (Range[]) new Range[4]; 27 | this.octets[0] = o1; 28 | this.octets[1] = o2; 29 | this.octets[2] = o3; 30 | this.octets[3] = o4; 31 | this.privateAllowed = privateAllowed; 32 | } 33 | 34 | IPv4Type(Range o1, Range o2, Range o3, Range o4){ 35 | this(o1,o2,o3,o4,true); 36 | } 37 | 38 | public Range[] getOctets() { 39 | return octets; 40 | } 41 | 42 | public boolean isPrivateAllowed() { 43 | return privateAllowed; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/MACAddressFormatType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.types.TriConsumer; 5 | 6 | @SuppressWarnings("ImmutableEnumChecker") 7 | public enum MACAddressFormatType { 8 | 9 | DASH_EVERY_2_DIGITS(MACAddressFormatType::line2Digits), 10 | COLON_EVERY_2_DIGITS(MACAddressFormatType::colon2Digits), 11 | DOT_EVERY_2_DIGITS(MACAddressFormatType::point2Digits), 12 | DOT_EVERY_4_DIGITS(MACAddressFormatType::point4Digits); 13 | 14 | private final TriConsumer consumer; 15 | 16 | MACAddressFormatType(TriConsumer consumer) { 17 | this.consumer = consumer; 18 | } 19 | 20 | public TriConsumer getConsumer() { 21 | return consumer; 22 | } 23 | 24 | private static void everyDigits(Integer i, StringBuilder buff, MockNeat rand, String chr, Integer digits) { 25 | if (i % digits == 0) 26 | buff.append(chr); 27 | buff.append(Integer.toHexString(rand.ints().range(0, 16).val())); 28 | } 29 | 30 | private static void line2Digits(Integer i, StringBuilder buff, MockNeat rand) { 31 | everyDigits(i, buff, rand, "-", 2); 32 | } 33 | 34 | private static void colon2Digits(Integer i, StringBuilder buff, MockNeat rand) { 35 | everyDigits(i, buff, rand, ":", 2); 36 | } 37 | 38 | private static void point2Digits(Integer i, StringBuilder buff, MockNeat rand) { 39 | everyDigits(i, buff, rand, ".", 2); 40 | } 41 | 42 | private static void point4Digits(Integer i, StringBuilder buff, MockNeat rand) { 43 | everyDigits(i, buff, rand, ".", 4); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/MarkovChainType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, OUT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | @SuppressWarnings("ImmutableEnumChecker") 21 | public enum MarkovChainType { 22 | 23 | 24 | @Deprecated 25 | KAFKA("kafka"), 26 | 27 | LOREM_IPSUM("loremipsum"); 28 | 29 | private final String path; 30 | 31 | MarkovChainType(String path) { 32 | this.path = path; 33 | } 34 | 35 | public String getFile() { 36 | return path; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/NameType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Copyright 2017, Andrei N. Ciobanu 7 | 8 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 9 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 11 | persons to whom the Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 14 | Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. PARAM NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER PARAM AN ACTION OF CONTRACT, TORT OR 19 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 20 | */ 21 | 22 | @SuppressWarnings("ImmutableEnumChecker") 23 | public enum NameType { 24 | 25 | FIRST_NAME(new DictType[]{ 26 | DictType.FIRST_NAME_MALE_AMERICAN, 27 | DictType.FIRST_NAME_FEMALE_AMERICAN 28 | }), 29 | FIRST_NAME_MALE(new DictType[]{ 30 | DictType.FIRST_NAME_MALE_AMERICAN 31 | }), 32 | FIRST_NAME_FEMALE(new DictType[]{ 33 | DictType.FIRST_NAME_FEMALE_AMERICAN 34 | }), 35 | FIRST_NAME_MALE_AMERICAN(new DictType[]{ 36 | DictType.FIRST_NAME_MALE_AMERICAN 37 | }), 38 | FIRST_NAME_FEMALE_AMERICAN(new DictType[]{ 39 | DictType.FIRST_NAME_FEMALE_AMERICAN 40 | }), 41 | LAST_NAME(new DictType[]{ 42 | DictType.LAST_NAME_AMERICAN 43 | }); 44 | 45 | private final DictType[] dictionaries; 46 | 47 | NameType(DictType[] dictionaries) { 48 | this.dictionaries = dictionaries; 49 | } 50 | 51 | public DictType[] getDictionaries() { 52 | return Arrays.copyOf(dictionaries, dictionaries.length); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/PassStrengthType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | import net.andreinc.mockneat.types.Range; 4 | 5 | @SuppressWarnings("ImmutableEnumChecker") 6 | public enum PassStrengthType { 7 | WEAK(new Range<>(6, 9)), 8 | MEDIUM(new Range<>(8, 13)), 9 | STRONG(new Range<>(12, 15)); 10 | 11 | private final Range length; 12 | 13 | PassStrengthType(Range length) { 14 | this.length = length; 15 | } 16 | 17 | public Range getLength() { 18 | return length; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/RandomType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | import java.security.SecureRandom; 4 | import java.util.Random; 5 | import java.util.concurrent.ThreadLocalRandom; 6 | 7 | @SuppressWarnings("ImmutableEnumChecker") 8 | public enum RandomType { 9 | 10 | OLD(new Random()), 11 | SECURE(new SecureRandom()), 12 | THREAD_LOCAL(ThreadLocalRandom.current()); 13 | 14 | private final Random random; 15 | 16 | RandomType(Random random) { 17 | this.random = random; 18 | } 19 | 20 | public Random getRandom() { 21 | return random; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/SpaceType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | import java.util.Arrays; 4 | 5 | public enum SpaceType { 6 | 7 | CONSTELLATIONS(new DictType[]{DictType.SPACE_CONSTELLATIONS}), 8 | GALAXIES(new DictType[]{DictType.SPACE_GALAXIES}), 9 | MOONS(new DictType[]{DictType.SPACE_MOONS}), 10 | NEBULAS(new DictType[]{DictType.SPACE_NEBULAS}), 11 | PLANETS(new DictType[]{DictType.SPACE_PLANETS}), 12 | STARS(new DictType[]{DictType.SPACE_STARS}), 13 | ALL(new DictType[]{ 14 | DictType.SPACE_CONSTELLATIONS, 15 | DictType.SPACE_GALAXIES, 16 | DictType.SPACE_MOONS, 17 | DictType.SPACE_NEBULAS, 18 | DictType.SPACE_PLANETS, 19 | DictType.SPACE_STARS 20 | }); 21 | 22 | SpaceType(DictType[] dictTypes) { 23 | this.dictTypes = dictTypes; 24 | } 25 | 26 | private final DictType[] dictTypes; 27 | 28 | public DictType[] getDictTypes() { 29 | return Arrays.copyOf(dictTypes, dictTypes.length); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/StringFormatType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import java.util.function.UnaryOperator; 6 | 7 | @SuppressWarnings("ImmutableEnumChecker") 8 | public enum StringFormatType { 9 | 10 | UPPER_CASE(StringUtils::upperCase), 11 | LOWER_CASE(StringUtils::lowerCase), 12 | CAPITALIZED(StringUtils::capitalize); 13 | 14 | private final UnaryOperator formatter; 15 | 16 | StringFormatType(UnaryOperator formatter) { 17 | this.formatter = formatter; 18 | } 19 | 20 | public UnaryOperator getFormatter() { 21 | return formatter; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/StringType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. PARAM NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER PARAM AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | @SuppressWarnings("ImmutableEnumChecker") 21 | public enum StringType { 22 | NUMBERS, 23 | ALPHA_NUMERIC, 24 | LETTERS, 25 | HEX, 26 | SPECIAL_CHARACTERS 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/URLSchemeType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. PARAM NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER PARAM AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | @SuppressWarnings("ImmutableEnumChecker") 21 | public enum URLSchemeType { 22 | HTTP("http"), 23 | HTTPS("https"), 24 | FTP("ftp"), 25 | NONE(""); 26 | 27 | private final String str; 28 | 29 | URLSchemeType(String str) { 30 | this.str = str; 31 | } 32 | 33 | public String getStr() { 34 | return str; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return str; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/UserNameType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | import net.andreinc.mockneat.types.Pair; 4 | 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | import static java.util.Arrays.asList; 9 | import static java.util.Collections.unmodifiableList; 10 | 11 | @SuppressWarnings("ImmutableEnumChecker") 12 | public enum UserNameType { 13 | 14 | ADJECTIVE_NOUN( 15 | unmodifiableList(asList( 16 | new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.EN_NOUN_1SYLL), 17 | new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.EN_NOUN_2SYLL), 18 | new Pair<>(DictType.EN_ADJECTIVE_2SYLL, DictType.EN_NOUN_1SYLL) 19 | )) 20 | ), 21 | 22 | ADVERB_VERB( 23 | unmodifiableList(asList( 24 | new Pair<>(DictType.EN_ADVERB_1SYLL, DictType.EN_VERB_1SYLL), 25 | new Pair<>(DictType.EN_ADVERB_2SYLL, DictType.EN_VERB_1SYLL), 26 | new Pair<>(DictType.EN_ADVERB_1SYLL, DictType.EN_VERB_2SYLL) 27 | )) 28 | ), 29 | 30 | ADJECTIVE_FIRST_NAME( 31 | unmodifiableList(asList( 32 | new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_MALE_AMERICAN), 33 | new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_FEMALE_AMERICAN) 34 | )) 35 | ), 36 | 37 | ADJECTIVE_LAST_NAME( 38 | unmodifiableList(asList( 39 | new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.LAST_NAME_AMERICAN), 40 | new Pair<>(DictType.EN_ADJECTIVE_2SYLL, DictType.LAST_NAME_AMERICAN) 41 | )) 42 | ), 43 | 44 | ADJECTIVE_FIRST_NAME_MALE( 45 | Collections.singletonList( 46 | new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_MALE_AMERICAN) 47 | ) 48 | ), 49 | 50 | ADJECTIVE_FIRST_NAME_FEMALE( 51 | Collections.singletonList( 52 | new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_FEMALE_AMERICAN) 53 | ) 54 | ); 55 | 56 | private final List> dictCombos; 57 | 58 | UserNameType(List> dictCombos) { 59 | this.dictCombos = dictCombos; 60 | } 61 | 62 | public List> getDictCombos() { 63 | return dictCombos; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/types/enums/WordsType.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.types.enums; 2 | 3 | public enum WordsType { 4 | ADJECTIVES, 5 | ADJECTIVES_1SYLL, 6 | ADJECTIVES_2SYLL, 7 | ADJECTIVES_3SYLL, 8 | ADJECTIVES_4SYLL, 9 | ADVERBS, 10 | ADVERBS_1SYLL, 11 | ADVERBS_2SYLL, 12 | ADVERBS_3SYLL, 13 | ADVERBS_4SYLL, 14 | NOUNS, 15 | NOUNS_1SYL, 16 | NOUNS_2SYL, 17 | NOUNS_3SYL, 18 | NOUNS_4SYL, 19 | VERBS, 20 | VERBS_1SYLL, 21 | VERBS_2SYLL, 22 | VERBS_3SYLL, 23 | VERBS_4SYLL 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/address/Countries.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.address; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | 7 | import java.util.function.Supplier; 8 | 9 | import static net.andreinc.mockneat.types.enums.DictType.COUNTRY_ISO_CODE_2; 10 | import static net.andreinc.mockneat.types.enums.DictType.COUNTRY_NAME; 11 | 12 | public class Countries extends MockUnitBase implements MockUnitString { 13 | 14 | /** 15 | *

Returns a {@code Countries} object that can be used to generate country names or country ISO2 codes.

16 | * 17 | * @return A re-usable {@code Countries} object. 18 | */ 19 | public static Countries countries() { 20 | return MockNeat.threadLocal().countries(); 21 | } 22 | 23 | public Countries(MockNeat mockNeat) { 24 | super(mockNeat); 25 | } 26 | 27 | /** 28 | * The method returns a new {@code MockUnitString} that can be used to generate country names. (Eg.: "Romania") 29 | * 30 | * @return A new {@code MockUnitString}. 31 | */ 32 | public MockUnitString names() { 33 | return mockNeat.dicts().type(COUNTRY_NAME); 34 | } 35 | 36 | /** 37 | * The method returns a new {@code MockUnitString} that can be used to generate country ISO2 codes. (Eg.: "RO") 38 | * 39 | * @return A new {@code MockUnitString}. 40 | */ 41 | public MockUnitString iso2() { 42 | return mockNeat.dicts().type(COUNTRY_ISO_CODE_2); 43 | } 44 | 45 | /** 46 | * @return A supplier {@code Supplier} that when it's called returns an arbitrary country name. (Eg.: "France") 47 | */ 48 | @Override 49 | public Supplier supplier() { 50 | return names().supplier(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/address/USStates.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.address; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | public class USStates extends MockUnitBase implements MockUnitString { 11 | 12 | public static USStates usStates() { 13 | return MockNeat.threadLocal().usStates(); 14 | } 15 | 16 | public USStates(MockNeat mockNeat) { 17 | super(mockNeat); 18 | } 19 | 20 | /** 21 | * The method returns a {@code MockUnitString} that can be used to generate US state names (Eg.: "Indiana") 22 | * @return A new {@code MockUnitString} 23 | */ 24 | @Override 25 | public Supplier supplier() { 26 | return mockNeat 27 | .dicts() 28 | .type(DictType.US_STATES) 29 | .supplier(); 30 | } 31 | 32 | /** 33 | * The method returns a {@code MockUnitString} that can be used to generate US State ISO2 names (Eg.: "LA") 34 | * @return A new {@code MockUnitString} 35 | */ 36 | public MockUnitString iso2() { 37 | return () -> mockNeat 38 | .dicts() 39 | .type(DictType.US_STATES_IS_CODE_2) 40 | .supplier(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/celebrities/Actors.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.celebrities; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | public class Actors extends MockUnitBase implements MockUnitString { 11 | 12 | /** 13 | *

Returns a {@code Actors} object that can be used to generate arbitrary actor names (e.g.: Michael Douglas)

14 | * 15 | * @return a re-usable {@code Actors} instance. This class implements {@code MockUnitString} 16 | */ 17 | public static Actors actors() { 18 | return MockNeat.threadLocal().actors(); 19 | } 20 | 21 | public Actors(MockNeat mockNeat) { 22 | super(mockNeat); 23 | } 24 | 25 | /** 26 | * The method returns a {@code Supplier} that can be used to generate full actor names (Eg.: "Adrien Brody") 27 | * 28 | * @return A new {@code Supplier} 29 | */ 30 | @Override 31 | public Supplier supplier() { 32 | return mockNeat.dicts() 33 | .type(DictType.ACTORS) 34 | .supplier(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/celebrities/Actresses.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.celebrities; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | public class Actresses extends MockUnitBase implements MockUnitString { 11 | 12 | /** 13 | *

Returns a {@code Actresses} object that can be used to generate arbitrary actresses names (e.g.: Elizabeth Taylor)

14 | * 15 | * @return a re-usable {@code Actresses} instance. This class implements {@code MockUnitString} 16 | */ 17 | public static Actresses actresses() { 18 | return MockNeat.threadLocal().actresses(); 19 | } 20 | 21 | public Actresses(MockNeat mockNeat) { 22 | super(mockNeat); 23 | } 24 | 25 | /** 26 | * The method returns a {@code Supplier} that can be used to generate full actress names (Eg.: Tilda Swinton") 27 | * 28 | * @return A new {@code Supplier} 29 | */ 30 | @Override 31 | public Supplier supplier() { 32 | return mockNeat.dicts() 33 | .type(DictType.ACTRESSES) 34 | .supplier(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/celebrities/JazzArtists.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.celebrities; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | public class JazzArtists extends MockUnitBase implements MockUnitString { 11 | 12 | /** 13 | *

Returns a {@code JazzArtists} object that can be used to generate arbitrary jazz artists names

14 | * 15 | * @return a re-usable {@code JazzArtists} object. The {@code JazzArtists} class implements {@code MockUnitString} 16 | */ 17 | public static JazzArtists jazzArtists() { 18 | return MockNeat.threadLocal().jazzArtists(); 19 | } 20 | 21 | public JazzArtists(MockNeat mockNeat) { 22 | super(mockNeat); 23 | } 24 | 25 | /** 26 | * The method returns a {@code Supplier} that can be used to generate jazz artists names (Eg.: "Duke Ellington") 27 | * 28 | * @return A new {@code Supplier} 29 | */ 30 | @Override 31 | public Supplier supplier() { 32 | return mockNeat.dicts() 33 | .type(DictType.JAZZ_ARTISTS) 34 | .supplier(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/celebrities/RockStars.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.celebrities; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | public class RockStars extends MockUnitBase implements MockUnitString { 11 | 12 | public RockStars(MockNeat mockNeat) { 13 | super(mockNeat); 14 | } 15 | 16 | /** 17 | * The method returns a {@code Supplier} that can be used to generate rock star names (Eg.: "Ronnie James Dio") 18 | * 19 | * @return A new {@code Supplier} 20 | */ 21 | @Override 22 | public Supplier supplier() { 23 | return mockNeat.dicts() 24 | .type(DictType.ROCK_STARS) 25 | .supplier(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/celebrities/UKPrimeMinisters.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.celebrities; 2 | 3 | 4 | import net.andreinc.mockneat.MockNeat; 5 | import net.andreinc.mockneat.abstraction.MockUnitBase; 6 | import net.andreinc.mockneat.abstraction.MockUnitString; 7 | import net.andreinc.mockneat.types.enums.DictType; 8 | 9 | import java.util.function.Supplier; 10 | 11 | public class UKPrimeMinisters extends MockUnitBase implements MockUnitString { 12 | 13 | public UKPrimeMinisters(MockNeat mockNeat) { 14 | super(mockNeat); 15 | } 16 | 17 | /** 18 | * The method returns a {@code Supplier} that can be used to generate British prime-minister names (Eg.: "William Lamb") 19 | * 20 | * @return A new {@code Supplier} 21 | */ 22 | @Override 23 | public Supplier supplier() { 24 | return mockNeat.dicts() 25 | .type(DictType.UK_PRIME_MINISTERS) 26 | .supplier(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/celebrities/USPresidents.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.celebrities; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | public class USPresidents extends MockUnitBase implements MockUnitString { 11 | 12 | public USPresidents(MockNeat mockNeat) { 13 | super(mockNeat); 14 | } 15 | 16 | /** 17 | * The method returns a {@code Supplier} that can be used to generate US president names (Eg.: "Abraham Lincoln") 18 | * 19 | * @return A new {@code Supplier} 20 | */ 21 | @Override 22 | public Supplier supplier() { 23 | return mockNeat.dicts().type(DictType.US_PRESIDENTS).supplier(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/companies/Companies.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.companies; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | public class Companies extends MockUnitBase implements MockUnitString { 11 | 12 | /** 13 | *

Returns a {@code Companies} object that can be used to generate company names

14 | * 15 | * @return A re-usable {@code Companies} object. The {@code Companies} class is implementing {@code MockUnitString}. 16 | */ 17 | public static Companies companies() { 18 | return MockNeat.threadLocal().companies(); 19 | } 20 | 21 | @Override 22 | public Supplier supplier() { 23 | return mockNeat.dicts().type(DictType.COMPANIES).supplier(); 24 | } 25 | 26 | public Companies(MockNeat mockNeat) { 27 | super(mockNeat); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/companies/Departments.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.companies; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | 7 | import java.util.function.Supplier; 8 | 9 | import static net.andreinc.mockneat.types.enums.DictType.DEPARTMENTS; 10 | 11 | public class Departments extends MockUnitBase implements MockUnitString { 12 | 13 | /** 14 | *

Returns a {@code Departments} object that can be used to generate arbitrary names representing department names from a company.

15 | * 16 | * @return A re-usable {@code Departments} object. The {@code Departments} class is implementing {@code MockUnitString}. 17 | */ 18 | public static Departments departments() { 19 | return MockNeat.threadLocal().departments(); 20 | } 21 | 22 | protected Departments() { } 23 | 24 | public Departments(MockNeat mockNeat) { 25 | super(mockNeat); 26 | } 27 | 28 | @Override 29 | public Supplier supplier() { 30 | return mockNeat.dicts().type(DEPARTMENTS).supplier(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/companies/Industries.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.companies; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * Copyright 2019, Andrei N. Ciobanu 12 | 13 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 14 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 15 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 16 | persons to whom the Software is furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 19 | Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 22 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. PARAM NO EVENT SHALL THE AUTHORS OR 23 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER PARAM AN ACTION OF CONTRACT, TORT OR 24 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 25 | */ 26 | 27 | public class Industries extends MockUnitBase implements MockUnitString { 28 | 29 | /** 30 | *

Returns a {@code Industries} object that can be used to generate valid Industry names (Eg.: "Education and Health Services")

31 | * 32 | * @return A re-usable {@code Industries} object. The {@code Industries} class implements {@code MockUnitString}. 33 | */ 34 | public static Industries industries() { 35 | return MockNeat.threadLocal().industries(); 36 | } 37 | 38 | public Industries(MockNeat mockNeat) { 39 | super(mockNeat); 40 | } 41 | 42 | @Override 43 | public Supplier supplier() { 44 | return mockNeat.dicts().type(DictType.INDUSTRIES).supplier(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/financial/Money.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.financial; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | 7 | import java.text.NumberFormat; 8 | import java.util.Locale; 9 | import java.util.function.Supplier; 10 | 11 | import static java.text.NumberFormat.getCurrencyInstance; 12 | import static java.util.Locale.US; 13 | import static net.andreinc.mockneat.utils.ValidationUtils.notNull; 14 | 15 | public class Money extends MockUnitBase implements MockUnitString { 16 | 17 | public static final double DEFAULT_LOWER = 0.0; 18 | public static final double DEFAULT_UPPER = 10000.0; 19 | 20 | private NumberFormat formatter = getCurrencyInstance(US); 21 | 22 | /** 23 | *

Returns a {@code Money} object that can be used to generate arbitrary "money" information.

24 | * 25 | *

The generated text represents sums of money generated using {@code NumberFormat.getCurrencyInstance().format(...)}.

26 | * 27 | *

Note:By default it returns a random sum of money

28 | * 29 | * @return A re-usable {@code Money} object. The {@code Money} class implements {@code MockUnitString}. 30 | */ 31 | public static Money money() { 32 | return MockNeat.threadLocal().money(); 33 | } 34 | 35 | public Money() { } 36 | 37 | public Money(MockNeat mockNeat) { 38 | super(mockNeat); 39 | } 40 | 41 | public Money locale(Locale locale) { 42 | notNull(locale, "locale"); 43 | this.formatter = getCurrencyInstance(locale); 44 | return this; 45 | } 46 | 47 | public MockUnitString range(double lowerBound, double upperBound) { 48 | return () -> mockNeat.doubles() 49 | .range(lowerBound, upperBound) 50 | .mapToString(formatter::format).supplier(); 51 | } 52 | 53 | public MockUnitString bound(double bound) { 54 | return () -> mockNeat.doubles() 55 | .bound(bound) 56 | .mapToString(formatter::format)::val; 57 | } 58 | 59 | @Override 60 | public Supplier supplier() { 61 | return range(DEFAULT_LOWER, DEFAULT_UPPER).supplier(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/id/UUIDs.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.id; 2 | 3 | import net.andreinc.mockneat.abstraction.MockUnitBase; 4 | import net.andreinc.mockneat.abstraction.MockUnitString; 5 | 6 | import java.util.UUID; 7 | import java.util.function.Supplier; 8 | 9 | public class UUIDs extends MockUnitBase implements MockUnitString { 10 | 11 | public static UUIDs uuids() { return new UUIDs(); } 12 | 13 | public UUIDs() { 14 | super(); 15 | } 16 | 17 | @Override 18 | public Supplier supplier() { 19 | return ()->UUID.randomUUID().toString(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/misc/Creatures.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.misc; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | public class Creatures extends MockUnitBase implements MockUnitString { 11 | 12 | /** 13 | *

Returns a {@code Creatures} object that can be used to generate arbitrary creature names.

14 | * 15 | * @return A re-usable {@code Creatures} instance. The class implements {@code MockUnitString}. 16 | */ 17 | public static Creatures creatures() { 18 | return MockNeat.threadLocal().creatures(); 19 | } 20 | 21 | public Creatures(MockNeat mockNeat) { 22 | super(mockNeat); 23 | } 24 | 25 | @Override 26 | public Supplier supplier() { 27 | return mockNeat.dicts().type(DictType.CREATURES).supplier(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/misc/ISSNS.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.misc; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | 7 | import java.util.function.Supplier; 8 | 9 | import static org.apache.commons.lang3.StringUtils.join; 10 | 11 | public class ISSNS extends MockUnitBase implements MockUnitString { 12 | 13 | private static final String ISSN_PREFIX = "ISSN"; 14 | 15 | /** 16 | *

Returns a {@code ISSNS} object that can be used to generate arbitrary ISSN codes.

17 | * 18 | * @return A re-usable {@code ISSNS} object. The {@code ISSNS} class implements {@code MockUnitString}. 19 | */ 20 | public static ISSNS issns() { return MockNeat.threadLocal().issns(); } 21 | 22 | protected ISSNS() { } 23 | 24 | public ISSNS(MockNeat mockNeat) { 25 | super(mockNeat); 26 | } 27 | 28 | @Override 29 | public Supplier supplier() { 30 | return () -> { 31 | Integer[] array = mockNeat.ints().range(0, 10).array(7).val(); 32 | int sum = 0; 33 | for(int i = 0, j = 8; i < array.length; i++, j--) { 34 | sum += j * array[i]; 35 | } 36 | int remainder = sum % 11; 37 | if (remainder != 0) { remainder = 11 - remainder; } 38 | return ISSN_PREFIX + " " + join(array, "", 0, 4) 39 | + "-" + join(array, "", 4, 7) 40 | + ((remainder == 10) ? "X" : remainder + ""); 41 | }; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/misc/Mimes.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.misc; 2 | 3 | 4 | import net.andreinc.mockneat.MockNeat; 5 | import net.andreinc.mockneat.abstraction.MockUnitBase; 6 | import net.andreinc.mockneat.abstraction.MockUnitString; 7 | 8 | import java.util.function.Supplier; 9 | 10 | import static net.andreinc.mockneat.types.enums.DictType.MIME_TYPE; 11 | 12 | public class Mimes extends MockUnitBase implements MockUnitString { 13 | 14 | /** 15 | *

Returns a {@code Mimes} object that can be used to generate arbitrary Mime Types (Eg.: "text/html", "image/x-icon", "text/calendar")

16 | * 17 | * @return A re-usable {@code Mimes} object. The {@code Mimes} class implements {@code MockUnitString}. 18 | */ 19 | public static Mimes mimes() { 20 | return MockNeat.threadLocal().mimes(); 21 | } 22 | 23 | protected Mimes() { 24 | } 25 | 26 | public Mimes(MockNeat mockNeat) { 27 | super(mockNeat); 28 | } 29 | 30 | @Override 31 | public Supplier supplier() { 32 | return mockNeat.dicts().type(MIME_TYPE).supplier(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/misc/SSCs.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.misc; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | 7 | import java.util.function.Supplier; 8 | 9 | import static net.andreinc.mockneat.utils.FormatUtils.prependZeroesToSize; 10 | 11 | public class SSCs extends MockUnitBase implements MockUnitString { 12 | 13 | public static SSCs sscs() { 14 | return MockNeat.threadLocal().sscs(); 15 | } 16 | 17 | private SSCs() { } 18 | 19 | public SSCs(MockNeat mockNeat) { 20 | super(mockNeat); 21 | } 22 | 23 | /** 24 | * AAA-GG-SSSS 25 | */ 26 | @Override 27 | public Supplier supplier() { 28 | return () -> generateAAA() + "-" + generateGG() + "-" + generateSSSS(); 29 | } 30 | 31 | private String generateAAA() { 32 | Integer number = mockNeat.ints().range(1, 900).val(); 33 | // "078051120" - Woolworth Wallet Fiasco 34 | // "219099999" - Used in add 35 | // 666-xx-xxxx - Doesn't work 36 | while(number==666 || number==78 || number==219) 37 | number = mockNeat.ints().range(1, 900).val(); 38 | return prependZeroesToSize(number.toString(), 3); 39 | } 40 | 41 | private String generateGG() { 42 | return prependZeroesToSize(mockNeat.ints().range(1, 100).valStr(), 2); 43 | } 44 | 45 | private String generateSSSS() { 46 | return prependZeroesToSize(mockNeat.ints().range(1, 10000).valStr(), 4); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/networking/IPv6s.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.networking; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.utils.LoopsUtils; 7 | 8 | import java.util.function.Supplier; 9 | import java.util.stream.Collectors; 10 | 11 | import static net.andreinc.mockneat.alphabets.Alphabets.HEXA_STR; 12 | 13 | public class IPv6s extends MockUnitBase implements MockUnitString { 14 | 15 | /** 16 | *

Returns a {@code IPv6s} object that can be used to generate arbitrary IPv6 addresses.

17 | * 18 | * @return A re-usable {@code IPv6s} object. The {@code IPv6s} class implements {@code MockUnitString}. 19 | */ 20 | public static IPv6s ipv6s() { 21 | return MockNeat.threadLocal().iPv6s(); 22 | } 23 | 24 | public IPv6s() { } 25 | 26 | public IPv6s(MockNeat mockNeat) { 27 | super(mockNeat); 28 | } 29 | 30 | @Override 31 | public Supplier supplier() { 32 | return this::ip; 33 | } 34 | 35 | private String group() { 36 | String result = mockNeat.from(HEXA_STR) 37 | .stream().val() 38 | .limit(4) 39 | .collect(Collectors.joining()) 40 | .replaceAll("([0])\\1", ""); 41 | return result.length() == 0 ? "0" : result; 42 | } 43 | 44 | private String ip() { 45 | final StringBuilder buff = new StringBuilder(); 46 | LoopsUtils.loop(8, () -> buff.append(group()).append(":")); 47 | buff.deleteCharAt(buff.length()-1); 48 | return buff.toString(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/networking/Macs.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.networking; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.MACAddressFormatType; 7 | 8 | import java.util.function.Supplier; 9 | import java.util.stream.IntStream; 10 | 11 | import static net.andreinc.mockneat.types.enums.MACAddressFormatType.COLON_EVERY_2_DIGITS; 12 | import static net.andreinc.mockneat.utils.ValidationUtils.notNull; 13 | 14 | public class Macs extends MockUnitBase implements MockUnitString { 15 | 16 | /** 17 | *

Returns a {@code Macs} object that can be used to generate arbitrary physical addresses (MAC).

18 | * 19 | * @return A re-usable {@code Macs} object. The {@code Macs} class implements {@code MockUnitString}. 20 | */ 21 | public static Macs macs() { 22 | return MockNeat.threadLocal().macs(); 23 | } 24 | 25 | public Macs() { } 26 | 27 | public Macs(MockNeat mockNeat) { 28 | super(mockNeat); 29 | } 30 | 31 | @Override 32 | public Supplier supplier() { 33 | return type(COLON_EVERY_2_DIGITS)::val; 34 | } 35 | 36 | /** 37 | *

This method can be used to setup the format of the MAC address.

38 | * 39 | * @param type The format. 40 | * @return A new {@code MockUnitString}. 41 | */ 42 | public MockUnitString type(MACAddressFormatType type) { 43 | notNull(type, "type"); 44 | Supplier supplier = () -> { 45 | StringBuilder buff = new StringBuilder(); 46 | IntStream.range(0, 12).forEach(i -> type.getConsumer().consume(i, buff, this.mockNeat)); 47 | return buff.deleteCharAt(0).toString(); 48 | }; 49 | return () -> supplier; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/objects/Constant.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.objects; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnit; 5 | 6 | import java.util.function.Supplier; 7 | 8 | public class Constant implements MockUnit { 9 | 10 | /** 11 | *

Returns a new {@code Constant} object.

12 | * 13 | *

This method is a {@code MockUnit} used to generate constant values

14 | * 15 | * @param object The constant object to return 16 | * @param The type of the object 17 | * @return The constant object to return 18 | */ 19 | public static Constant constant(T object) { return MockNeat.threadLocal().constant(object); } 20 | 21 | private final T object; 22 | 23 | public Constant(T object) { 24 | this.object = object; 25 | } 26 | 27 | @Override 28 | public Supplier supplier() { 29 | return () -> object; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/objects/Filler.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.objects; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnit; 5 | import net.andreinc.mockneat.abstraction.MockUnitBase; 6 | 7 | import java.util.LinkedHashMap; 8 | import java.util.Map; 9 | import java.util.function.BiConsumer; 10 | import java.util.function.Supplier; 11 | 12 | import static net.andreinc.mockneat.utils.ValidationUtils.notNull; 13 | 14 | public class Filler extends MockUnitBase implements MockUnit { 15 | 16 | private final Supplier supplier; 17 | 18 | //TODO: Change this horrible way 19 | @SuppressWarnings("rawtypes") 20 | final 21 | Map setters = new LinkedHashMap<>(); 22 | 23 | public static Filler filler(Supplier supplier) { 24 | return MockNeat.threadLocal().filler(supplier); 25 | } 26 | 27 | protected Filler(Supplier supplier) { 28 | super(); 29 | notNull(supplier, "supplier"); 30 | this.supplier = supplier; 31 | } 32 | 33 | public Filler(MockNeat mockNeat, Supplier supplier) { 34 | super(mockNeat); 35 | notNull(supplier, "supplier"); 36 | this.supplier = supplier; 37 | } 38 | 39 | public Filler setter(BiConsumer setter, MockUnit mockUnit) { 40 | notNull(setter, "setter"); 41 | notNull(mockUnit, "mockUnit"); 42 | setters.put(setter, mockUnit); 43 | return this; 44 | } 45 | 46 | public Filler constant(BiConsumer setter, R constant) { 47 | notNull(setter, "setter"); 48 | notNull(constant, "constant"); 49 | setters.put(setter, () -> () -> constant); 50 | return this; 51 | } 52 | 53 | @SuppressWarnings("unchecked") 54 | @Override 55 | public Supplier supplier() { 56 | return () -> { 57 | T object = supplier.get(); 58 | notNull(object, "supplier"); 59 | setters.forEach((k,v) -> k.accept(object, v.val())); 60 | return object; 61 | }; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/regex/Regex.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.regex; 2 | 3 | import com.mifmif.common.regex.Generex; 4 | import net.andreinc.mockneat.MockNeat; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | 7 | import java.util.function.Supplier; 8 | 9 | import static net.andreinc.mockneat.utils.ValidationUtils.notNull; 10 | import static net.andreinc.mockneat.utils.ValidationUtils.validRegex; 11 | 12 | public class Regex implements MockUnitString { 13 | 14 | /** 15 | *

Returns a new {@code Regex} object that can be used to generate arbitrary text based on a certain regex pattern.

16 | * 17 | * @param regex The regex pattern that the generated string needs to comply. 18 | * @return A new {@code Regex} object. The {@code Regex} class implements {@code MockUnitString}. 19 | */ 20 | public static Regex regex(String regex) { 21 | return MockNeat.threadLocal().regex(regex); 22 | } 23 | 24 | private final String regExp; 25 | 26 | public Regex(String regExp) { 27 | this.regExp = regExp; 28 | } 29 | 30 | @Override 31 | public Supplier supplier() { 32 | notNull(regExp, "regExp"); 33 | validRegex(regExp); 34 | return () -> new Generex(regExp).random(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/text/FromFiles.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.text; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.utils.file.FileManager; 7 | 8 | import static net.andreinc.mockneat.types.enums.StringFormatType.LOWER_CASE; 9 | import static net.andreinc.mockneat.utils.ValidationUtils.notEmpty; 10 | 11 | public class FromFiles extends MockUnitBase { 12 | 13 | private final FileManager fm = FileManager.getInstance(); 14 | 15 | /** 16 | *

Returns a {@code FromFiles} object that can used to generate random strings from a given text file.

17 | * 18 | *

Note: The file is loaded in memory. For the moment there is no functionality to "unload" it.

19 | * 20 | * @return A re-usable {@code FromFiles} object. 21 | */ 22 | public static FromFiles files() { 23 | return MockNeat.threadLocal().files(); 24 | } 25 | 26 | public FromFiles() { } 27 | 28 | public FromFiles(MockNeat mockNeat) { 29 | super(mockNeat); 30 | } 31 | 32 | /** 33 | *

Generates a new {@code MockUnitString} that can be used to generate String lines from the given {@code path}.

34 | * 35 | *

Note: The files needs to exist and have read rights.

36 | * 37 | * @param path The path of the file from the disk. 38 | * @return A new {@code MockUnitString} 39 | */ 40 | public MockUnitString from(String path) { 41 | notEmpty(path, "path"); 42 | return mockNeat.fromStrings(fm.getLines(path)).format(LOWER_CASE); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/text/Space.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.text; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | import net.andreinc.mockneat.types.enums.SpaceType; 8 | 9 | import java.util.function.Supplier; 10 | 11 | public class Space extends MockUnitBase implements MockUnitString { 12 | 13 | public static Space space() { 14 | return MockNeat.threadLocal().space(); 15 | } 16 | 17 | protected Space() { 18 | } 19 | 20 | public Space(MockNeat mockNeat) { 21 | super(mockNeat); 22 | } 23 | 24 | @Override 25 | public Supplier supplier() { 26 | return mockNeat.dicts().types(SpaceType.ALL.getDictTypes()).supplier(); 27 | } 28 | 29 | public MockUnitString type(SpaceType spaceType) { 30 | DictType[] types = spaceType.getDictTypes(); 31 | return () -> mockNeat.dicts().types(types).supplier(); 32 | } 33 | 34 | public MockUnitString types(SpaceType... spaceTypes) { 35 | return () -> { 36 | SpaceType spaceType = mockNeat.from(spaceTypes).val(); 37 | return type(spaceType).supplier(); 38 | }; 39 | } 40 | 41 | public MockUnitString constellations() { 42 | return type(SpaceType.CONSTELLATIONS); 43 | } 44 | 45 | public MockUnitString galaxies() { 46 | return type(SpaceType.GALAXIES); 47 | } 48 | 49 | public MockUnitString moons() { 50 | return type(SpaceType.NEBULAS); 51 | } 52 | 53 | public MockUnitString planets() { 54 | return type(SpaceType.PLANETS); 55 | } 56 | 57 | public MockUnitString stars() { 58 | return type(SpaceType.STARS); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/text/sql/escapers/Generic.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.text.sql.escapers; 2 | 3 | import net.andreinc.mockneat.unit.text.sql.SQLEscaper; 4 | 5 | import java.util.Collections; 6 | import java.util.function.UnaryOperator; 7 | 8 | public class Generic { 9 | public static final UnaryOperator DOUBLE_APOSTROPHE = new SQLEscaper( 10 | Collections.singletonList( 11 | new SQLEscaper.TextEscapeToken( 12 | "'", 13 | "'", 14 | "''") 15 | ) 16 | )::escape; 17 | 18 | private Generic() {} 19 | } -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/text/sql/escapers/MySQL.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.text.sql.escapers; 2 | 3 | import net.andreinc.mockneat.unit.text.sql.SQLEscaper; 4 | 5 | import java.util.Arrays; 6 | import java.util.function.Function; 7 | 8 | public class MySQL { 9 | // Text Escaper for MYSQL 10 | public static final Function TEXT_BACKSLASH = new SQLEscaper( 11 | Arrays.asList( 12 | new SQLEscaper.TextEscapeToken( 13 | "\u0000", 14 | "\\x00", 15 | "\\\\0"), 16 | new SQLEscaper.TextEscapeToken( 17 | "'", 18 | "'", 19 | "''"), 20 | new SQLEscaper.TextEscapeToken( 21 | "\"", 22 | "\"", 23 | "\\\\\"" 24 | ), 25 | new SQLEscaper.TextEscapeToken( 26 | "\b", 27 | "\\x08", 28 | "\\\\b" 29 | ), 30 | new SQLEscaper.TextEscapeToken( 31 | "\n", 32 | "\\n", 33 | "\\\\n" 34 | ), 35 | new SQLEscaper.TextEscapeToken( 36 | "\r", 37 | "\\r", 38 | "\\\\r" 39 | ), 40 | new SQLEscaper.TextEscapeToken( 41 | "\t", 42 | "\\t", 43 | "\\\\t" 44 | ), 45 | new SQLEscaper.TextEscapeToken( 46 | "\u001A", 47 | "\\x1A", 48 | "\\\\Z" 49 | ), 50 | new SQLEscaper.TextEscapeToken( 51 | "\\", 52 | "\\\\", 53 | "\\\\\\\\" 54 | ) 55 | ) 56 | )::escape; 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/types/Bools.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.types; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnit; 5 | import net.andreinc.mockneat.abstraction.MockUnitBase; 6 | 7 | import java.util.Random; 8 | import java.util.function.Supplier; 9 | 10 | import static org.apache.commons.lang3.Validate.inclusiveBetween; 11 | 12 | public class Bools extends MockUnitBase implements MockUnit { 13 | 14 | private final Random random; 15 | 16 | /** 17 | *

Returns a {@code Bools} object that can be used to generate arbitrary {@code Boolean} values.

18 | * 19 | * @return A re-usable {@code Bools} instance. The class implements {@code MockUnit}. 20 | */ 21 | public static Bools bools() { 22 | return MockNeat.threadLocal().bools(); 23 | } 24 | 25 | public Bools(MockNeat mockNeat) { 26 | super(mockNeat); 27 | this.random = mockNeat.getRandom(); 28 | } 29 | 30 | /** 31 | *

Returns a new {@code MockUnit} that returns arbitrary boolean values with a given probability.

32 | * 33 | * @param probability The probability to obtain {@code true}. (Eg.: If the probability is 99.99, the {@code MockUnit} will generate {@code true} in 99.99% of the cases. 34 | * @return A new {@code MockUnit} 35 | */ 36 | public MockUnit probability(double probability) { 37 | inclusiveBetween(0.0, 100.0, probability); 38 | Supplier supp = () -> mockNeat.doubles() 39 | .range(0.0, 100.0) 40 | .val() < probability; 41 | return () -> supp; 42 | } 43 | 44 | /** 45 | *

Returns the internal {@code Supplier} that is used to generate boolean values.

46 | * 47 | * @return A {@code Supplier} used to generate arbitrary {@code Boolean} values. 48 | */ 49 | @Override 50 | public Supplier supplier() { 51 | return random::nextBoolean; 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/types/Primes.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.types; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitInt; 6 | import net.andreinc.mockneat.alphabets.Alphabets; 7 | 8 | import java.util.function.Supplier; 9 | 10 | import static net.andreinc.mockneat.unit.objects.From.from; 11 | 12 | public class Primes extends MockUnitBase implements MockUnitInt { 13 | 14 | /** 15 | *

Returns a {@code Primes} object that can be used to generate prime numbers (small)

16 | * 17 | *

The primes are only generated in this interval [0, 7919]

18 | * 19 | * @return A re-usable {@code Primes} object. The {@code Primes} class implements {@code MockUnitInt} 20 | */ 21 | public static Primes primes() { return MockNeat.threadLocal().primes(); } 22 | 23 | public Primes(MockNeat mockNeat) { 24 | super(mockNeat); 25 | } 26 | 27 | public MockUnitInt smallPrimes() { 28 | return () -> from(Alphabets.SMALL_PRIMES).supplier(); 29 | } 30 | 31 | @Override 32 | public Supplier supplier() { 33 | return from(Alphabets.SMALL_PRIMES).supplier(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/user/Emails.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.user; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.abstraction.MockUnit; 7 | 8 | import java.util.function.Supplier; 9 | import static net.andreinc.mockneat.types.enums.DictType.DOMAIN_EMAIL; 10 | 11 | public class Emails extends MockUnitBase implements MockUnitString { 12 | 13 | /** 14 | *

Returns an {@code Email} object that can be used to generate arbitrary email address.

15 | * 16 | * @return A re-usable {@code Emails} object. The {@code Emails} class implements {@code MockUnitString}. 17 | */ 18 | public static Emails emails() { 19 | return MockNeat.threadLocal().emails(); 20 | } 21 | 22 | public Emails(MockNeat mockNeat) { 23 | super(mockNeat); 24 | } 25 | 26 | @Override 27 | public Supplier supplier() { 28 | return () -> mockNeat.users().val() + "@" + mockNeat.dicts().type(DOMAIN_EMAIL).val(); 29 | } 30 | 31 | /** 32 | *

Generates a new {@code MockUnitString} that can be used to generate emails that have specific domains (eg.: "gmail.com").

33 | * 34 | *

This is particularly useful when the requirement is to generate "company/enterprise" emails.

35 | * 36 | * @param domains A var-arg String array containing the list of the domains to be used. 37 | * @return A new {@code MockUnitString}. 38 | */ 39 | public MockUnitString domains(String... domains) { 40 | Supplier supp = () -> { 41 | String user = mockNeat.users().val(); 42 | String domain = mockNeat.from(domains).val(); 43 | return user + "@" + domain; 44 | }; 45 | return () -> supp; 46 | } 47 | 48 | /** 49 | *

Generates a new {@code MockUnitString} that can be used to generate emails that have a specific domain (eg.: "gmail.com").

50 | * 51 | *

This is particularly useful when the requirement is to generate "company/enterprise" emails.

52 | * 53 | * @param domain The domain to be used. 54 | * @return A new {@code MockUnitString}. 55 | */ 56 | public MockUnitString domain(String domain) { 57 | return domains(domain); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/user/Genders.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.user; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | 7 | import java.util.Arrays; 8 | import java.util.List; 9 | import java.util.function.Supplier; 10 | 11 | public class Genders extends MockUnitBase implements MockUnitString { 12 | 13 | private static final List LONG = Arrays.asList("Male", "Female"); 14 | private static final List SHORT = Arrays.asList("M", "F"); 15 | 16 | public static Genders genders() { 17 | return MockNeat.threadLocal().genders(); 18 | } 19 | 20 | public Genders() { } 21 | 22 | public Genders(MockNeat mockNeat) { 23 | super(mockNeat); 24 | } 25 | 26 | @Override 27 | public Supplier supplier() { 28 | return mockNeat.from(LONG).supplier(); 29 | } 30 | 31 | /** 32 | *

Returns a new {@code MockUnitString} that is used to return "M" or "F".

33 | * 34 | * @return A new {@code MockUnitString}. 35 | */ 36 | public MockUnitString letter() { 37 | return () -> mockNeat.from(SHORT).supplier(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/user/NonBinaryGenders.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.user; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.enums.DictType; 7 | 8 | import java.util.function.Supplier; 9 | 10 | public class NonBinaryGenders extends MockUnitBase implements MockUnitString { 11 | 12 | public static NonBinaryGenders nonBinaryGenders() { 13 | return MockNeat.threadLocal().nonBinaryGenders(); 14 | } 15 | 16 | public NonBinaryGenders(MockNeat mockNeat) { 17 | super(mockNeat); 18 | } 19 | 20 | @Override 21 | public Supplier supplier() { 22 | return mockNeat.dicts().type(DictType.NON_BINARY_GENDERS).supplier(); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/unit/user/Users.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.user; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.abstraction.MockUnitBase; 5 | import net.andreinc.mockneat.abstraction.MockUnitString; 6 | import net.andreinc.mockneat.types.Pair; 7 | import net.andreinc.mockneat.types.enums.DictType; 8 | import net.andreinc.mockneat.types.enums.UserNameType; 9 | 10 | import java.util.function.Supplier; 11 | 12 | import static net.andreinc.mockneat.types.enums.StringFormatType.LOWER_CASE; 13 | import static net.andreinc.mockneat.utils.ValidationUtils.notEmptyOrNullValues; 14 | import static net.andreinc.mockneat.utils.ValidationUtils.notNull; 15 | 16 | public class Users extends MockUnitBase implements MockUnitString { 17 | 18 | private static final Double UNDERSCORE = 0.15; 19 | 20 | public static Users users() { 21 | return MockNeat.threadLocal().users(); 22 | } 23 | 24 | protected Users() { } 25 | 26 | public Users(MockNeat mockNeat) { 27 | super(mockNeat); 28 | } 29 | 30 | @Override 31 | public Supplier supplier() { 32 | return types(UserNameType.values()).supplier(); 33 | } 34 | 35 | public MockUnitString type(UserNameType type) { 36 | notNull(type, "type"); 37 | Supplier supplier = () -> generateUserName(type); 38 | return () -> supplier; 39 | } 40 | 41 | public MockUnitString types(UserNameType... types) { 42 | notEmptyOrNullValues(types, "types"); 43 | return () -> { 44 | UserNameType type = mockNeat.from(types).val(); 45 | return type(type).supplier(); 46 | }; 47 | } 48 | 49 | private String generateUserName(UserNameType type) { 50 | Pair pair = mockNeat.from(type.getDictCombos()).val(); 51 | 52 | String part1 = 53 | mockNeat.dicts().type(pair.getFirst()).format(LOWER_CASE).val(); 54 | String part2 = 55 | mockNeat.dicts().type(pair.getSecond()).format(LOWER_CASE).val(); 56 | 57 | if (mockNeat.bools().probability(UNDERSCORE).val()) { 58 | part1 += "_"; 59 | } 60 | 61 | 62 | return part1 + part2; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.utils; 2 | 3 | import java.time.Instant; 4 | import java.time.LocalDate; 5 | import java.time.LocalDateTime; 6 | import java.time.ZoneId; 7 | import java.util.Date; 8 | 9 | public class DateUtils { 10 | 11 | public static LocalDate convertToLocalDateViaMilisecond(Date dateToConvert) { 12 | return Instant.ofEpochMilli(dateToConvert.getTime()) 13 | .atZone(ZoneId.systemDefault()) 14 | .toLocalDate(); 15 | } 16 | 17 | public static LocalDateTime convertToLocalDateTimeViaInstant(Date dateToConvert) { 18 | return dateToConvert.toInstant() 19 | .atZone(ZoneId.systemDefault()) 20 | .toLocalDateTime(); 21 | } 22 | 23 | public static LocalDateTime convertToLocalDateTimeViaMilisecond(Date dateToConvert) { 24 | return Instant.ofEpochMilli(dateToConvert.getTime()) 25 | .atZone(ZoneId.systemDefault()) 26 | .toLocalDateTime(); 27 | } 28 | 29 | public static Date convertToDateViaInstant(LocalDate dateToConvert) { 30 | return java.util.Date.from(dateToConvert.atStartOfDay() 31 | .atZone(ZoneId.systemDefault()) 32 | .toInstant()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/utils/FormatUtils.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.utils; 2 | 3 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 4 | 5 | public final class FormatUtils { 6 | 7 | private FormatUtils() {} 8 | 9 | public static String prependZeroesToSize(String string, int size) { 10 | if (string.length() buff.append("0")); 14 | buff.append(string); 15 | return buff.toString(); 16 | } 17 | return string; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/net/andreinc/mockneat/utils/LoopsUtils.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.utils; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import net.andreinc.mockneat.types.CallBack; 5 | 6 | import java.util.Arrays; 7 | import java.util.function.Consumer; 8 | import java.util.function.Function; 9 | 10 | public final class LoopsUtils { 11 | 12 | private LoopsUtils() {} 13 | 14 | public static void loop(int cycles, CallBack callBack) { 15 | for (int i = 0; i < cycles; i++) { 16 | callBack.call(); 17 | } 18 | } 19 | 20 | public static void loop(int cycles, MockNeat[] array, Consumer consumer) { 21 | loop(cycles, () -> Arrays.stream(array).forEach(consumer)); 22 | } 23 | 24 | public static void loop(int cycles, MockNeat[] array, Function map, Consumer consume) { 25 | loop(cycles, () -> Arrays.stream(array) 26 | .map(map) 27 | .forEach(consume)); 28 | } 29 | 30 | public static void loop(boolean dbg, int cycles, MockNeat[] array, Function map, Consumer consume) { 31 | loop(cycles, 32 | () -> Arrays.stream(array) 33 | .map(r -> { 34 | T o = map.apply(r); 35 | return o; 36 | }) 37 | .forEach(consume)); 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/resources/capitalize-awk: -------------------------------------------------------------------------------- 1 | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2)) }' -------------------------------------------------------------------------------- /src/main/resources/dicts/american-presidents: -------------------------------------------------------------------------------- 1 | George Washington 2 | John Adams 3 | Thomas Jefferson 4 | James Madison 5 | James Monroe 6 | John Quincy Adams 7 | Andrew Jackson 8 | Martin Van Buren 9 | William Henry Harrison 10 | John Tyler 11 | James K. Polk 12 | Zachary Taylor 13 | Millard Fillmore 14 | Franklin Pierce 15 | James Buchanan 16 | Abraham Lincoln 17 | Andrew Johnson 18 | Ulysses S. Grant 19 | Rutherford B. Hayes 20 | James Garfield 21 | Chester A. Arthur 22 | Grover Cleveland 23 | Benjamin Harrison 24 | Grover Cleveland 25 | William McKinley 26 | Theodore Roosevelt 27 | William Howard Taft 28 | Woodrow Wilson 29 | Warren G. Harding 30 | Calvin Coolidge 31 | Herbert Hoover 32 | Franklin D. Roosevelt 33 | Harry S. Truman 34 | Dwight D. Eisenhower 35 | John F. Kennedy 36 | Lyndon B. Johnson 37 | Richard M. Nixon 38 | Gerald R. Ford 39 | James Carter 40 | Ronald Reagan 41 | George H. W. Bush 42 | William J. Clinton 43 | George W. Bush 44 | Barack Obama 45 | Donald J. Trump 46 | Joe R. Biden -------------------------------------------------------------------------------- /src/main/resources/dicts/car-brands: -------------------------------------------------------------------------------- 1 | Acura 2 | Alfa Romeo 3 | Aston Martin 4 | Audi 5 | Bentley 6 | BMW 7 | Bugatti 8 | Buick 9 | Cadillac 10 | Chevrolet 11 | Chrysler 12 | Citroen 13 | Dacia 14 | Dodge 15 | Ferrari 16 | Fiat 17 | Ford 18 | Genesis 19 | Honda 20 | Hummer 21 | Hyundai 22 | Infiniti 23 | Isuzu 24 | Jaguar 25 | Jeep 26 | Kia 27 | Lada 28 | Lamborghini 29 | Land Rover 30 | Lexus 31 | Lincoln 32 | Lotus 33 | Maserati 34 | Mazda 35 | McLaren 36 | Mercedes-Benz 37 | Mercury 38 | Mitsubishi 39 | Nissan 40 | Oldsmobile 41 | Peugeot 42 | Pontiac 43 | Porsche 44 | Regal 45 | Renault 46 | Rolls-Royce 47 | Rover 48 | Saab 49 | Saturn 50 | Seat 51 | Skoda 52 | Subaru 53 | Suzuki 54 | Tesla 55 | Toyota 56 | Volkswagen 57 | Volvo -------------------------------------------------------------------------------- /src/main/resources/dicts/cities/cities-capitals-africa: -------------------------------------------------------------------------------- 1 | Abuja 2 | Accra 3 | Addis Ababa 4 | Algiers 5 | Antananarivo 6 | Asmara 7 | Bamako 8 | Bangui 9 | Banjul 10 | Bissau 11 | Brazzaville 12 | Bujumbura 13 | Cairo 14 | Cape Town 15 | Bloemfontein 16 | Pretoria 17 | Conakry 18 | Dakar 19 | Dodoma 20 | Dar es Salaam 21 | Djibouti 22 | El Aaiún 23 | Freetown 24 | Gaborone 25 | Harare 26 | Juba 27 | Kampala 28 | Khartoum 29 | Kigali 30 | Kinshasa 31 | Libreville 32 | Lilongwe 33 | Mbabane 34 | Lobamba 35 | Lomé 36 | Luanda 37 | Lusaka 38 | Malabo 39 | Maputo 40 | Maseru 41 | Mogadishu 42 | Monrovia 43 | Moroni 44 | Nairobi 45 | N'Djamena 46 | Niamey 47 | Nouakchott 48 | Ouagadougou 49 | Port Louis 50 | Porto-Novo 51 | Cotonou 52 | Praia 53 | Rabat 54 | Tripoli 55 | Tunis 56 | Victoria 57 | Windhoek 58 | Yamoussoukro 59 | Yaoundé -------------------------------------------------------------------------------- /src/main/resources/dicts/cities/cities-capitals-america: -------------------------------------------------------------------------------- 1 | Asunción 2 | Basseterre 3 | Belmopan 4 | Bogotá 5 | Brasilia 6 | Bridgetown 7 | Buenos Aires 8 | Caracas 9 | Castries 10 | Georgetown 11 | Guatemala City 12 | Havana 13 | Kingston 14 | Kingstown 15 | La Paz 16 | Sucre 17 | Lima 18 | Managua 19 | México 20 | Montevideo 21 | Nassau 22 | Ottawa 23 | Panamá 24 | Paramaribo 25 | Port au Prince 26 | Port of Spain 27 | Quito 28 | Roseau 29 | Saint George's 30 | Saint John's 31 | San José 32 | San Salvador 33 | Santiago 34 | Santo Domingo 35 | Tegucigalpa 36 | Washington -------------------------------------------------------------------------------- /src/main/resources/dicts/cities/cities-capitals-asia: -------------------------------------------------------------------------------- 1 | Abu Dhabi 2 | Amman 3 | Ankara 4 | Ashgabat 5 | Nur-Sultan 6 | Baghdad 7 | Baku 8 | Bandar 9 | Bangkok 10 | Beijing 11 | Beirut 12 | Bishkek 13 | Colombo 14 | Kotte 15 | Damascus 16 | Dhaka 17 | Dili 18 | Doha 19 | Dushanbe 20 | Hanoi 21 | Islamabad 22 | Jakarta 23 | Jerusalem 24 | Kabul 25 | Kathmandu 26 | Kuala Lumpur 27 | Kuwait-City 28 | Lhasa 29 | Malé 30 | Manama 31 | Manila 32 | Muscat 33 | Naypyidaw 34 | New Delhi 35 | Phnom Penh 36 | P'yongyang 37 | Riyadh 38 | Sanaa 39 | Seoul 40 | Singapore 41 | Taipei 42 | Tashkent 43 | T'bilisi 44 | Tehran 45 | Thimphu 46 | Tokyo 47 | Ulaanbaatar 48 | Vientiane 49 | Yerevan -------------------------------------------------------------------------------- /src/main/resources/dicts/cities/cities-capitals-australia-and-oceania: -------------------------------------------------------------------------------- 1 | Adamstown 2 | Alofi 3 | Apia 4 | Avarua 5 | Canberra 6 | Hagåtña 7 | Funafuti 8 | Honiara 9 | Majuro 10 | Ngerulmud 11 | Nouméa 12 | Nuku'alofa 13 | Pago Pago 14 | Palikir 15 | Papeete 16 | Port Moresby 17 | Port Vila 18 | Saipan 19 | Suva 20 | Wellington -------------------------------------------------------------------------------- /src/main/resources/dicts/cities/cities-capitals-europe: -------------------------------------------------------------------------------- 1 | Amsterdam 2 | Andorra la Vella 3 | Ankara 4 | Astana 5 | Athens 6 | Baku 7 | Belgrade 8 | Berlin 9 | Bern 10 | Bratislava 11 | Brussels 12 | Bucharest 13 | Budapest 14 | Chisinau 15 | Copenhagen 16 | Dublin 17 | Helsinki 18 | Kiev 19 | Lisbon 20 | Ljubljana 21 | London 22 | Luxembourg 23 | Madrid 24 | Minsk 25 | Monaco 26 | Moscow 27 | Nicosia 28 | Oslo 29 | Paris 30 | Podgorica 31 | Prague 32 | Reykjavík 33 | Riga 34 | Rome 35 | San Marino 36 | Sarajevo 37 | Skopje 38 | Sofia 39 | Stockholm 40 | Tallinn 41 | Tbilisi 42 | Tirana 43 | Vaduz 44 | Valletta 45 | Vatican City 46 | Vienna 47 | Vilnius 48 | Warsaw 49 | Yerevan 50 | Zagreb -------------------------------------------------------------------------------- /src/main/resources/dicts/country-iso-code-2: -------------------------------------------------------------------------------- 1 | AF 2 | AL 3 | DZ 4 | AS 5 | AD 6 | AO 7 | AI 8 | AQ 9 | AG 10 | AR 11 | AM 12 | AW 13 | AU 14 | AT 15 | AZ 16 | BS 17 | BH 18 | BD 19 | BB 20 | BY 21 | BE 22 | BZ 23 | BJ 24 | BM 25 | BT 26 | BO 27 | BA 28 | BW 29 | BV 30 | BR 31 | IO 32 | BN 33 | BG 34 | BF 35 | BI 36 | KH 37 | CM 38 | CA 39 | CV 40 | KY 41 | CF 42 | TD 43 | CL 44 | CN 45 | CX 46 | CC 47 | CO 48 | KM 49 | CG 50 | CD 51 | CK 52 | CR 53 | CI 54 | HR 55 | CU 56 | CY 57 | CZ 58 | DK 59 | DJ 60 | DM 61 | DO 62 | TP 63 | EC 64 | EG 65 | SV 66 | GQ 67 | ER 68 | EE 69 | ET 70 | FK 71 | FO 72 | FJ 73 | FI 74 | FR 75 | GF 76 | PF 77 | TF 78 | GA 79 | GM 80 | GE 81 | DE 82 | GH 83 | GI 84 | GR 85 | GL 86 | GD 87 | GP 88 | GU 89 | GT 90 | GN 91 | GW 92 | GY 93 | HT 94 | HM 95 | VA 96 | HN 97 | HK 98 | HU 99 | IS 100 | IN 101 | ID 102 | IR 103 | IQ 104 | IE 105 | IL 106 | IT 107 | JM 108 | JP 109 | JO 110 | KZ 111 | KE 112 | KI 113 | KP 114 | KR 115 | KV 116 | KW 117 | KG 118 | LA 119 | LV 120 | LB 121 | LS 122 | LR 123 | LY 124 | LI 125 | LT 126 | LU 127 | MO 128 | MK 129 | MG 130 | MW 131 | MY 132 | MV 133 | ML 134 | MT 135 | MH 136 | MQ 137 | MR 138 | MU 139 | YT 140 | MX 141 | FM 142 | MD 143 | MC 144 | MN 145 | MS 146 | ME 147 | MA 148 | MZ 149 | MM 150 | NA 151 | NR 152 | NP 153 | NL 154 | AN 155 | NC 156 | NZ 157 | NI 158 | NE 159 | NG 160 | NU 161 | NF 162 | MP 163 | NO 164 | OM 165 | PK 166 | PW 167 | PS 168 | PA 169 | PG 170 | PY 171 | PE 172 | PH 173 | PN 174 | PL 175 | PT 176 | PR 177 | QA 178 | RE 179 | RO 180 | RU 181 | RW 182 | SH 183 | KN 184 | LC 185 | PM 186 | VC 187 | WS 188 | SM 189 | ST 190 | SA 191 | SN 192 | RS 193 | SC 194 | SL 195 | SG 196 | SK 197 | SI 198 | SB 199 | SO 200 | ZA 201 | GS 202 | ES 203 | LK 204 | SD 205 | SR 206 | SJ 207 | SZ 208 | SE 209 | CH 210 | SY 211 | TW 212 | TJ 213 | TZ 214 | TH 215 | TG 216 | TK 217 | TO 218 | TT 219 | TN 220 | TR 221 | TM 222 | TC 223 | TV 224 | UG 225 | UA 226 | AE 227 | GB 228 | US 229 | UM 230 | UY 231 | UZ 232 | VU 233 | VE 234 | VN 235 | VG 236 | VI 237 | WF 238 | EH 239 | YE 240 | ZM 241 | ZW -------------------------------------------------------------------------------- /src/main/resources/dicts/credit-card-names: -------------------------------------------------------------------------------- 1 | American Express 2 | China Union Pay 3 | Diners Club 4 | Discover 5 | Inter Payment 6 | Insta Payment 7 | JCB 8 | Maestro 9 | Mastercard 10 | Visa -------------------------------------------------------------------------------- /src/main/resources/dicts/departments: -------------------------------------------------------------------------------- 1 | Customer Service 2 | Customers 3 | Financial 4 | General Management 5 | Human Resources 6 | IT 7 | Insurance 8 | Inventory 9 | Licenses 10 | Logistics 11 | Marketing 12 | Operational 13 | Organizational 14 | Purchasing 15 | Research And Development 16 | Quality Assurance 17 | Sales 18 | Services 19 | Staffing -------------------------------------------------------------------------------- /src/main/resources/dicts/domain-email: -------------------------------------------------------------------------------- 1 | aol.com 2 | att.net 3 | comcast.net 4 | email.com 5 | gmail.com 6 | gmx.com 7 | hotmail.com 8 | hotmail.co.uk 9 | live.com 10 | mac.com 11 | me.com 12 | mail.com 13 | msn.com 14 | verizon.net 15 | yahoo.com 16 | yahoo.co.uk -------------------------------------------------------------------------------- /src/main/resources/dicts/domain-top-level-popular: -------------------------------------------------------------------------------- 1 | com 2 | org 3 | net 4 | edu 5 | gov 6 | info 7 | io -------------------------------------------------------------------------------- /src/main/resources/dicts/forex-pairs: -------------------------------------------------------------------------------- 1 | AUD/CAD 2 | AUD/CHF 3 | AUD/JPY 4 | AUD/NZD 5 | AUD/USD 6 | BGN/RON 7 | CAD/CHF 8 | CAD/JPY 9 | CHF/BGN 10 | CHF/JPY 11 | CHF/RON 12 | CHF/TRY 13 | EUR/AUD 14 | EUR/CAD 15 | EUR/CHF 16 | EUR/CZK 17 | EUR/DKK 18 | EUR/GBP 19 | EUR/HKD 20 | EUR/HUF 21 | EUR/ILS 22 | EUR/JPY 23 | EUR/MXN 24 | EUR/NOK 25 | EUR/NZD 26 | EUR/PLN 27 | EUR/RON 28 | EUR/RUB 29 | EUR/SEK 30 | EUR/SGD 31 | EUR/TRY 32 | EUR/USD 33 | EUR/ZAR 34 | GBP/AUD 35 | GBP/BGN 36 | GBP/CAD 37 | GBP/CHF 38 | GBP/CZK 39 | GBP/DKK 40 | GBP/HKD 41 | GBP/HUF 42 | GBP/JPY 43 | GBP/NOK 44 | GBP/NZD 45 | GBP/PLN 46 | GBP/RON 47 | GBP/SEK 48 | GBP/SGD 49 | GBP/TRY 50 | GBP/USD 51 | GBP/ZAR 52 | HKD/JPY 53 | NZD/CAD 54 | NZD/CHF 55 | NZD/JPY 56 | NZD/USD 57 | SGD/HKD 58 | SGD/JPY 59 | TRY/BGN 60 | TRY/JPY 61 | TRY/RON 62 | USD/BGN 63 | USD/CAD 64 | USD/CHF 65 | USD/CZK 66 | USD/DKK 67 | USD/HKD 68 | USD/HUF 69 | USD/ILS 70 | USD/JPY 71 | USD/MXN 72 | USD/NOK 73 | USD/PLN 74 | USD/RON 75 | USD/RUB 76 | USD/SEK 77 | USD/SGD 78 | USD/TRY 79 | USD/ZAR -------------------------------------------------------------------------------- /src/main/resources/dicts/jazz-artists: -------------------------------------------------------------------------------- 1 | Louis Armstrong 2 | Duke Ellington 3 | Miles Davis 4 | Charlie Parker 5 | John Coltrane 6 | Dizzy Gillespie 7 | Billie Holiday 8 | Thelonious Monk 9 | Charles Mingus 10 | Count Basie 11 | Lester Young 12 | Coleman Hawkins 13 | Ella Fitzgerald 14 | Sonny Rollins 15 | Sidney Bechet 16 | Art Blakey 17 | Ornette Coleman 18 | Benny Goodman 19 | Jelly Roll Morton 20 | Bill Evans 21 | Art Tatum 22 | Clifford Brown 23 | Stan Getz 24 | Sarah Vaughan 25 | Bud Powell 26 | Fletcher Henderson 27 | Django Reinhardt 28 | Herbie Hancock 29 | Wayne Shorter 30 | Horace Silver 31 | Dave Brubeck 32 | Rahsaan Roland Kirk 33 | Cecil Taylor 34 | King Oliver 35 | Sun Ra 36 | Gil Evans 37 | Lionel Hampton 38 | Art Pepper 39 | Eric Dolphy 40 | Oscar Peterson 41 | Charlie Christian 42 | Ben Webster 43 | Fats Waller 44 | Earl Hines 45 | Woody Herman 46 | Wes Montgomery 47 | J.J. Johnson 48 | John McLaughlin 49 | Artie Shaw 50 | Lee Morgan 51 | David Murray 52 | Chick Corea 53 | Max Roach 54 | Roy Eldridge 55 | Anthony Braxton 56 | Bix Beiderbecke 57 | Dexter Gordon 58 | Keith Jarrett 59 | Lee Konitz 60 | Stan Kenton 61 | Joe Henderson 62 | Gerry Mulligan 63 | Benny Carter 64 | Teddy Wilson 65 | Freddie Hubbard 66 | Cannonball Adderley 67 | McCoy Tyner 68 | Chet Baker 69 | Lennie Tristano 70 | Jimmy Smith 71 | Mary Lou Williams 72 | George Russell 73 | Fats Navarro 74 | Bennie Moten 75 | Jimmie Lunceford 76 | Wynton Marsalis 77 | Albert Ayler 78 | Charlie Haden 79 | Erroll Garner 80 | Meade Lux Lewis 81 | Pat Metheny 82 | Jack Teagarden 83 | Johnny Hodges 84 | Chick Webb 85 | James P. Johnson 86 | Jimmy Giuffre 87 | Jaco Pastorius 88 | Hank Mobley 89 | Elvin Jones 90 | Evan Parker 91 | Paul Chambers 92 | Ron Carter 93 | Carla Bley 94 | Bennie Golson 95 | Jackie McLean 96 | James Carter 97 | Donald Byrd 98 | Johnny Dodds 99 | Glenn Miller -------------------------------------------------------------------------------- /src/main/resources/dicts/mimetypes: -------------------------------------------------------------------------------- 1 | audio/aac 2 | application/x-abiword 3 | application/octet-stream 4 | video/x-msvideo 5 | application/vnd.amazon.ebook 6 | application/octet-stream 7 | application/x-bzip 8 | application/x-bzip2 9 | application/x-csh 10 | text/css 11 | text/csv 12 | application/msword 13 | application/epub+zip 14 | image/gif 15 | text/html 16 | image/x-icon 17 | text/calendar 18 | application/java-archive 19 | image/jpeg 20 | application/javascript 21 | application/json 22 | audio/midi 23 | video/mpeg 24 | application/vnd.apple.installer+xml 25 | application/vnd.oasis.opendocument.presentation 26 | application/vnd.oasis.opendocument.spreadsheet 27 | application/vnd.oasis.opendocument.text 28 | audio/ogg 29 | video/ogg 30 | application/ogg 31 | application/pdf 32 | application/vnd.ms-powerpoint 33 | application/x-rar-compressed 34 | application/rtf 35 | application/x-sh 36 | image/svg+xml 37 | application/x-shockwave-flash 38 | application/x-tar 39 | image/tiff 40 | font/ttf 41 | application/vnd.visio 42 | audio/x-wav 43 | audio/webm 44 | video/webm 45 | image/webp 46 | font/woff 47 | font/woff2 48 | application/xhtml+xml 49 | application/vnd.ms-excel 50 | application/xml 51 | application/vnd.mozilla.xul+xml 52 | application/zip 53 | video/3gpp 54 | video/3gpp2 55 | application/x-7z-compressed -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/cvevulnerabilities: -------------------------------------------------------------------------------- 1 | () { 0; }; touch /tmp/blns.shellshock1.fail; 2 | () { _; } >_[$($())] { touch /tmp/blns.shellshock2.fail; } 3 | <<< %s(un='%s') = %u 4 | +++ATH0 -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/emoji: -------------------------------------------------------------------------------- 1 | 😍 2 | 👩🏽 3 | 👾 🙇 💁 🙅 🙆 🙋 🙎 🙍 4 | 🐵 🙈 🙉 🙊 5 | ❤️ 💔 💌 💕 💞 💓 💗 💖 💘 💝 💟 💜 💛 💚 💙 6 | ✋🏿 💪🏿 👐🏿 🙌🏿 👏🏿 🙏🏿 7 | 🚾 🆒 🆓 🆕 🆖 🆗 🆙 🏧 8 | 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟 9 | -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/fileinclusions: -------------------------------------------------------------------------------- 1 | ../../../../../../../../../../../etc/passwd%00 2 | ../../../../../../../../../../../etc/hosts -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/inconousstrings: -------------------------------------------------------------------------------- 1 | Scunthorpe General Hospital 2 | Penistone Community Church 3 | Lightwater Country Park 4 | Jimmy Clitheroe 5 | Horniman Museum 6 | shitake mushrooms 7 | RomansInSussex.co.uk 8 | http://www.cum.qc.ca/ 9 | Craig Cockburn, Software Specialist 10 | Linda Callahan 11 | Dr. Herman I. Libshitz 12 | magna cum laude 13 | Super Bowl XXX 14 | medieval erection of parapets 15 | evaluate 16 | mocha 17 | expression 18 | Arsenal canal 19 | classic 20 | Tyson Gay 21 | Dick Van Dyke 22 | basement -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/japaneseemoji: -------------------------------------------------------------------------------- 1 | ヽ༼ຈل͜ຈ༽ノ ヽ༼ຈل͜ຈ༽ノ 2 | (。◕ ∀ ◕。) 3 | `ィ(´∀`∩ 4 | __ロ(,_,*) 5 | ・( ̄∀ ̄)・:*: 6 | ゚・✿ヾ╲(。◕‿◕。)╱✿・゚ 7 | ,。・:*:・゜’( ☻ ω ☻ )。・:*:・゜’ 8 | (╯°□°)╯︵ ┻━┻) 9 | (ノಥ益ಥ)ノ ┻━┻ 10 | ┬─┬ノ( º _ ºノ) 11 | ( ͡° ͜ʖ ͡°) -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/msdosspecialfilenames: -------------------------------------------------------------------------------- 1 | CON 2 | PRN 3 | AUX 4 | CLOCK$ 5 | NUL 6 | A: 7 | ZZ: 8 | COM1 9 | LPT1 10 | LPT2 11 | LPT3 12 | COM2 13 | COM3 14 | COM4 -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/numeric: -------------------------------------------------------------------------------- 1 | 2 | 0 3 | 1 4 | 1.00 5 | $1.00 6 | 1/2 7 | 1E2 8 | 1E02 9 | 1E+02 10 | -1 11 | -1.00 12 | -$1.00 13 | -1/2 14 | -1E2 15 | -1E02 16 | -1E+02 17 | 1/0 18 | 0/0 19 | -2147483648/-1 20 | -9223372036854775808/-1 21 | -0 22 | -0.0 23 | +0 24 | +0.0 25 | 0.00 26 | 0..0 27 | . 28 | 0.0.0 29 | 0,00 30 | 0,,0 31 | , 32 | 0,0,0 33 | 0.0/0 34 | 1.0/0.0 35 | 0.0/0.0 36 | 1,0/0,0 37 | 0,0/0,0 38 | --1 39 | - 40 | -. 41 | -, 42 | 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 43 | NaN 44 | Infinity 45 | -Infinity 46 | INF 47 | 1#INF 48 | -1#IND 49 | 1#QNAN 50 | 1#SNAN 51 | 1#IND 52 | 0x0 53 | 0xffffffff 54 | 0xffffffffffffffff 55 | 0xabad1dea 56 | 123456789012345678901234567890123456789 57 | 1,000.00 58 | 1 000.00 59 | 1'000.00 60 | 1,000,000.00 61 | 1 000 000.00 62 | 1'000'000.00 63 | 1.000,00 64 | 1 000,00 65 | 1'000,00 66 | 1.000.000,00 67 | 1 000 000,00 68 | 1'000'000,00 69 | 01000 70 | 08 71 | 09 72 | 2.2250738585072011e-308 -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/quotations: -------------------------------------------------------------------------------- 1 | ' 2 | " 3 | '' 4 | "" 5 | '"' 6 | "''''"'" 7 | "'"'"''''" 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/regionalindicators: -------------------------------------------------------------------------------- 1 | 🇺🇸🇷🇺🇸 🇦🇫🇦🇲🇸 2 | 🇺🇸🇷🇺🇸🇦🇫🇦🇲 3 | 🇺🇸🇷🇺🇸🇦 -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/reservedkeywords: -------------------------------------------------------------------------------- 1 | undefined 2 | undef 3 | null 4 | NULL 5 | (null) 6 | nil 7 | NIL 8 | true 9 | false 10 | True 11 | False 12 | TRUE 13 | FALSE 14 | None 15 | hasOwnProperty 16 | \ 17 | \\ 18 | bool 19 | boolean 20 | int 21 | double -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/righttoleftstrings: -------------------------------------------------------------------------------- 1 | ثم نفس سقطت وبالتحديد،, جزيرتي باستخدام أن دنو. إذ هنا؟ الستار وتنصيب كان. أهّل ايطاليا، بريطانيا-فرنسا قد أخذ. سليمان، إتفاقية بين ما, يذكر الحدود أي بعد, معاملة بولندا، الإطلاق عل إيو. 2 | בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ 3 | הָיְתָהtestالصفحات التّحول 4 | ﷽ 5 | ﷺ 6 | مُنَاقَشَةُ سُبُلِ اِسْتِخْدَامِ اللُّغَةِ فِي النُّظُمِ الْقَائِمَةِ وَفِيم يَخُصَّ التَّطْبِيقَاتُ الْحاسُوبِيَّةُ، -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/rubyinjection: -------------------------------------------------------------------------------- 1 | eval("puts 'hello world'") 2 | System("ls -al /") 3 | `ls -al /` 4 | Kernel.exec("ls -al /") 5 | Kernel.exit(1) 6 | %x('ls -al /') -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/servercodeinjection: -------------------------------------------------------------------------------- 1 | - 2 | -- 3 | --version 4 | --help 5 | $USER 6 | /dev/null; touch /tmp/blns.fail ; echo 7 | `touch /tmp/blns.fail` 8 | $(touch /tmp/blns.fail) 9 | @{[system "touch /tmp/blns.fail"]} 10 | -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/specialchars: -------------------------------------------------------------------------------- 1 | ,./;'[]\-= 2 | <>?:"{}|_+ 3 | !@#$%^&*()`~ -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/sqlinjection: -------------------------------------------------------------------------------- 1 | 1;DROP TABLE users 2 | 1'; DROP TABLE users-- 1 3 | ' OR 1=1 -- 1 4 | ' OR '1'='1 -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/trickunicode: -------------------------------------------------------------------------------- 1 | test‪ 2 | ‫test‫ 3 | 
test
 4 | test⁠test‫ 5 | ⁦test⁧ -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/twobytechars: -------------------------------------------------------------------------------- 1 | 田中さんにあげて下さい 2 | パーティーへ行かないか 3 | 和製漢語 4 | 部落格 5 | 사회과학원 어학연구소 6 | 찦차를 타고 온 펲시맨과 쑛다리 똠방각하 7 | 社會科學院語學研究所 8 | 울란바토르 9 | 𠜎𠜱𠝹𠱓𠱸𠲖𠳏 -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/unicodefont: -------------------------------------------------------------------------------- 1 | The quick brown fox jumps over the lazy dog 2 | 𝐓𝐡𝐞 𝐪𝐮𝐢𝐜𝐤 𝐛𝐫𝐨𝐰𝐧 𝐟𝐨𝐱 𝐣𝐮𝐦𝐩𝐬 𝐨𝐯𝐞𝐫 𝐭𝐡𝐞 𝐥𝐚𝐳𝐲 𝐝𝐨𝐠 3 | 𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐 𝖇𝖗𝖔𝖜𝖓 𝖋𝖔𝖝 𝖏𝖚𝖒𝖕𝖘 𝖔𝖛𝖊𝖗 𝖙𝖍𝖊 𝖑𝖆𝖟𝖞 𝖉𝖔𝖌 4 | 𝑻𝒉𝒆 𝒒𝒖𝒊𝒄𝒌 𝒃𝒓𝒐𝒘𝒏 𝒇𝒐𝒙 𝒋𝒖𝒎𝒑𝒔 𝒐𝒗𝒆𝒓 𝒕𝒉𝒆 𝒍𝒂𝒛𝒚 𝒅𝒐𝒈 5 | 𝓣𝓱𝓮 𝓺𝓾𝓲𝓬𝓴 𝓫𝓻𝓸𝔀𝓷 𝓯𝓸𝔁 𝓳𝓾𝓶𝓹𝓼 𝓸𝓿𝓮𝓻 𝓽𝓱𝓮 𝓵𝓪𝔃𝔂 𝓭𝓸𝓰 6 | 𝕋𝕙𝕖 𝕢𝕦𝕚𝕔𝕜 𝕓𝕣𝕠𝕨𝕟 𝕗𝕠𝕩 𝕛𝕦𝕞𝕡𝕤 𝕠𝕧𝕖𝕣 𝕥𝕙𝕖 𝕝𝕒𝕫𝕪 𝕕𝕠𝕘 7 | 𝚃𝚑𝚎 𝚚𝚞𝚒𝚌𝚔 𝚋𝚛𝚘𝚠𝚗 𝚏𝚘𝚡 𝚓𝚞𝚖𝚙𝚜 𝚘𝚟𝚎𝚛 𝚝𝚑𝚎 𝚕𝚊𝚣𝚢 𝚍𝚘𝚐 8 | ⒯⒣⒠ ⒬⒰⒤⒞⒦ ⒝⒭⒪⒲⒩ ⒡⒪⒳ ⒥⒰⒨⒫⒮ ⒪⒱⒠⒭ ⒯⒣⒠ ⒧⒜⒵⒴ ⒟⒪⒢ -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/unicodenumbers: -------------------------------------------------------------------------------- 1 | 123 2 | ١٢٣ -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/unicodesubsuperscript: -------------------------------------------------------------------------------- 1 | ⁰⁴⁵ 2 | ₀₁₂ 3 | ⁰⁴⁵₀₁₂ 4 | ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็ ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็ ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็ -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/unicodesymbols: -------------------------------------------------------------------------------- 1 | Ω≈ç√∫˜µ≤≥÷ 2 | åß∂ƒ©˙∆˚¬…æ 3 | œ∑´®†¥¨ˆøπ“‘ 4 | ¡™£¢∞§¶•ªº–≠ 5 | ¸˛Ç◊ı˜Â¯˘¿ 6 | ÅÍÎÏ˝ÓÔÒÚÆ☃ 7 | Œ„´‰ˇÁ¨ˆØ∏”’ 8 | `⁄€‹›fifl‡°·‚—± 9 | ⅛⅜⅝⅞ 10 | ЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя 11 | ٠١٢٣٤٥٦٧٨٩ -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/unicodeupsidedown: -------------------------------------------------------------------------------- 1 | ˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯǝʇ poɯsnᴉǝ op pǝs 'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ 'ʇǝɯɐ ʇᴉs ɹolop ɯnsdᴉ ɯǝɹo˥ 2 | 00˙Ɩ$- -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/unwantedinterpolation: -------------------------------------------------------------------------------- 1 | $HOME 2 | $ENV{'HOME'} 3 | %d 4 | %s 5 | {0} 6 | %*.*s 7 | File:/// -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/xmlinjection: -------------------------------------------------------------------------------- 1 | 2 | ]>&xxe; -------------------------------------------------------------------------------- /src/main/resources/dicts/naughtystrings/zalgotext: -------------------------------------------------------------------------------- 1 | ˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯǝʇ poɯsnᴉǝ op pǝs 'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ 'ʇǝɯɐ ʇᴉs ɹolop ɯnsdᴉ ɯǝɹo˥ 2 | 00˙Ɩ$- -------------------------------------------------------------------------------- /src/main/resources/dicts/non-binary-genders: -------------------------------------------------------------------------------- 1 | Agender 2 | Androgyne 3 | Androgynous 4 | Bigender 5 | Cis 6 | Cis Female 7 | Cis Male 8 | Cis Man 9 | Cis Woman 10 | Cisgender 11 | Cisgender Female 12 | Cisgender Male 13 | Cisgender Man 14 | Cisgender Woman 15 | Female to Male 16 | FTM 17 | Gender Fluid 18 | Gender Nonconforming 19 | Gender Questioning 20 | Gender Variant 21 | Genderqueer 22 | Intersex 23 | Male to Female 24 | MTF 25 | Neither 26 | Neutrois 27 | Non-binary 28 | Other 29 | Pangender 30 | Trans 31 | Trans Female 32 | Trans Male 33 | Trans Man 34 | Trans Person 35 | Trans Woman 36 | Trans* 37 | Trans* Female 38 | Trans* Male 39 | Trans* Man 40 | Trans* Person 41 | Trans* Woman 42 | Transfeminine 43 | Transgender 44 | Transgender Female 45 | Transgender Male 46 | Transgender Man 47 | Transgender Person 48 | Transgender Woman 49 | Transmasculine 50 | Transsexual 51 | Transsexual Female 52 | Transsexual Male 53 | Transsexual Man 54 | Transsexual Person 55 | Transsexual Woman 56 | Two-spirit -------------------------------------------------------------------------------- /src/main/resources/dicts/space/constellations: -------------------------------------------------------------------------------- 1 | Andromeda 2 | Antlia 3 | Apus 4 | Aquarius 5 | Aquila 6 | Ara 7 | Aries 8 | Auriga 9 | Bootes 10 | Caelum 11 | Camelopardalis 12 | Cancer 13 | Canes Venatici 14 | Canis Major 15 | Canis Minor 16 | Capricornus 17 | Carina 18 | Cassiopeia 19 | Centaurus 20 | Cepheus 21 | Cetus 22 | Chamaeleon 23 | Circinus 24 | Columba 25 | Coma Berenices 26 | Corona Australis 27 | Corona Borealis 28 | Corvus 29 | Crater 30 | Crux 31 | Cygnus 32 | Delphinus 33 | Dorado 34 | Draco 35 | Equuleus 36 | Eridanus 37 | Fornax 38 | Gemini 39 | Grus 40 | Hercules 41 | Horologium 42 | Hydra 43 | Hydrus 44 | Indus 45 | Lacerta 46 | Leo 47 | Leo Minor 48 | Lepus 49 | Libra 50 | Lupus 51 | Lynx 52 | Lyra 53 | Mensa 54 | Microscopium 55 | Monoceros 56 | Musca 57 | Norma 58 | Octans 59 | Ophiuchus 60 | Orion 61 | Pavo 62 | Pegasus 63 | Perseus 64 | Phoenix 65 | Pictor 66 | Pisces 67 | Piscis Austrinus 68 | Puppis 69 | Pyxis 70 | Reticulum 71 | Sagitta 72 | Sagittarius 73 | Scorpius 74 | Sculptor 75 | Scutum 76 | Serpens 77 | Sextans 78 | Taurus 79 | Telescopium 80 | Triangulum 81 | Triangulum Australe 82 | Tucana 83 | Ursa Major 84 | Ursa Minor 85 | Vela 86 | Virgo 87 | Volans 88 | Vulpecula -------------------------------------------------------------------------------- /src/main/resources/dicts/space/galaxies: -------------------------------------------------------------------------------- 1 | Milky Way 2 | Andromeda 3 | Triangulum 4 | Whirlpool 5 | Blackeye 6 | Sunflower 7 | Pinwheel 8 | Hoags Object 9 | Centaurus A 10 | Messier 83 -------------------------------------------------------------------------------- /src/main/resources/dicts/space/moons: -------------------------------------------------------------------------------- 1 | Moon 2 | Luna 3 | Deimos 4 | Phobos 5 | Ganymede 6 | Callisto 7 | Io 8 | Europa 9 | Titan 10 | Rhea 11 | Iapetus 12 | Dione 13 | Tethys 14 | Hyperion 15 | Ariel 16 | Puck 17 | Oberon 18 | Umbriel 19 | Triton 20 | Proteus -------------------------------------------------------------------------------- /src/main/resources/dicts/space/nebulas: -------------------------------------------------------------------------------- 1 | Lagoon Nebula 2 | Eagle Nebula 3 | Triffid Nebula 4 | Dumbell Nebula 5 | Orion Nebula 6 | Ring Nebula 7 | Bodes Nebula 8 | Owl Nebula -------------------------------------------------------------------------------- /src/main/resources/dicts/space/planets: -------------------------------------------------------------------------------- 1 | Mercury 2 | Venus 3 | Earth 4 | Mars 5 | Jupiter 6 | Saturn 7 | Uranus 8 | Neptune 9 | Pluto -------------------------------------------------------------------------------- /src/main/resources/dicts/space/stars: -------------------------------------------------------------------------------- 1 | Sun 2 | Proxima Centauri 3 | Rigil Kentaurus 4 | Barnards Star 5 | Wolf 359 6 | Luyten 726-8A 7 | Luyten 726-8B 8 | Sirius A 9 | Sirius B 10 | Ross 154 11 | Ross 248 12 | Procyon A 13 | Procyon B 14 | Vega 15 | Rigel 16 | Arcturus 17 | Betelgeuse 18 | Mahasim 19 | Polaris -------------------------------------------------------------------------------- /src/main/resources/dicts/uk-primeministers: -------------------------------------------------------------------------------- 1 | Alec Douglas-Home 2 | Anthony Eden 3 | Archibald Philip Primrose 4 | Arthur James Balfour 5 | Arthur Wellesley 6 | Augustus Henry Fitzroy 7 | Benjamin Disraeli 8 | Bonar Law 9 | Boris Johnson 10 | Charles Grey 11 | Charles Watson Wentworth 12 | Clement Attlee 13 | David Cameron 14 | David Lloyd George 15 | Edward Geoffrey Stanley 16 | Edward Heath 17 | Frederick John Robinson 18 | Frederick North 19 | George Canning 20 | George Grenville 21 | George Hamilton-Gordon 22 | Gordon Brown 23 | H.H. Asquith 24 | Harold Macmillan 25 | Harold Wilson 26 | Henry Addington 27 | Henry Campbell-Bannerman 28 | Henry John Temple 29 | Henry Pelham 30 | James Callaghan 31 | John Major 32 | John Russell 33 | John Stuart 34 | Margaret Thatcher 35 | Neville Chamberlain 36 | Ramsay Macdonald 37 | Robert Banks Jenkinson 38 | Robert Cecil 39 | Robert Peel 40 | Robert Walpole 41 | Spencer Compton 42 | Spencer Perceval 43 | Stanley Baldwin 44 | Theresa May 45 | Thomas Pelham-Holles 46 | Tony Blair 47 | William Cavendish 48 | William Ewart Gladstone 49 | William Henry Cavendish-Bentinck 50 | William Lamb 51 | William Petty-Fitzmaurice 52 | William Pitt, the Elder 53 | William Pitt, the Younger 54 | William Wyndham Grenville 55 | Winston Churchill -------------------------------------------------------------------------------- /src/main/resources/dicts/us-states: -------------------------------------------------------------------------------- 1 | Alabama 2 | Alaska 3 | Arizona 4 | Arkansas 5 | California 6 | Colorado 7 | Connecticut 8 | Delaware 9 | Florida 10 | Georgia 11 | Hawaii 12 | Idaho 13 | Illinois 14 | Indiana 15 | Iowa 16 | Kansas 17 | Kentucky 18 | Louisiana 19 | Maine 20 | Maryland 21 | Massachusetts 22 | Michigan 23 | Minnesota 24 | Mississippi 25 | Missouri 26 | Montana 27 | Nebraska 28 | Nevada 29 | New Hampshire 30 | New Jersey 31 | New Mexico 32 | New York 33 | North Carolina 34 | North Dakota 35 | Ohio 36 | Oklahoma 37 | Oregon 38 | Pennsylvania 39 | Rhode Island 40 | South Carolina 41 | South Dakota 42 | Tennessee 43 | Texas 44 | Utah 45 | Vermont 46 | Virginia 47 | Washington 48 | West Virginia 49 | Wisconsin 50 | Wyoming -------------------------------------------------------------------------------- /src/main/resources/dicts/us-states-iso2: -------------------------------------------------------------------------------- 1 | AL 2 | AK 3 | AZ 4 | AR 5 | CA 6 | CO 7 | CT 8 | DE 9 | FL 10 | GA 11 | HI 12 | ID 13 | IL 14 | IN 15 | IA 16 | KS 17 | KY 18 | LA 19 | ME 20 | MD 21 | MA 22 | MI 23 | MN 24 | MS 25 | MO 26 | MT 27 | NE 28 | NV 29 | NH 30 | NJ 31 | NM 32 | NY 33 | NC 34 | ND 35 | OH 36 | OK 37 | OR 38 | PA 39 | RI 40 | SC 41 | SD 42 | TN 43 | TX 44 | UT 45 | VT 46 | VA 47 | WA 48 | WV 49 | WI 50 | WY -------------------------------------------------------------------------------- /src/main/resources/dicts/words/en-adverb-1syll: -------------------------------------------------------------------------------- 1 | aft 2 | all 3 | anes 4 | anon 5 | aught 6 | bang 7 | bene 8 | bis 9 | blamed 10 | bolt 11 | but 12 | cheap 13 | chock 14 | clean 15 | cool 16 | course 17 | damn 18 | damned 19 | dang 20 | darn 21 | darned 22 | dash 23 | dashed 24 | days 25 | dern 26 | dooms 27 | dryer 28 | due 29 | eath 30 | eft 31 | eighth 32 | else 33 | erst 34 | fain 35 | far 36 | firm 37 | flop 38 | flush 39 | fore 40 | forte 41 | foul 42 | fresh 43 | fro 44 | gey 45 | grave 46 | heads 47 | heap 48 | heigh 49 | hence 50 | here 51 | how 52 | incog 53 | laigh 54 | lark 55 | left 56 | less 57 | lest 58 | licht 59 | lief 60 | lieve 61 | like 62 | loads 63 | lots 64 | loud 65 | lowse 66 | mair 67 | mile 68 | mobs 69 | much 70 | nae 71 | natch 72 | naught 73 | nay 74 | near 75 | needs 76 | next 77 | nigh 78 | nights 79 | ninth 80 | none 81 | nope 82 | now 83 | oft 84 | once 85 | ought 86 | over 87 | phut 88 | please 89 | plop 90 | plumb 91 | plump 92 | plunk 93 | posh 94 | prompt 95 | proud 96 | quite 97 | same 98 | scant 99 | scarce 100 | sheer 101 | since 102 | sith 103 | sixth 104 | skeigh 105 | slap 106 | slier 107 | smack 108 | smash 109 | some 110 | soon 111 | sore 112 | spang 113 | stiff 114 | such 115 | super 116 | sure 117 | swith 118 | syne 119 | tails 120 | tenth 121 | that 122 | then 123 | thence 124 | there 125 | thick 126 | thin 127 | this 128 | tho 129 | though 130 | thrice 131 | through 132 | thru 133 | thus 134 | thwart 135 | tight 136 | ton 137 | too 138 | tough 139 | trim 140 | twice 141 | vite 142 | waur 143 | way 144 | ways 145 | week 146 | well 147 | wham 148 | what 149 | when 150 | whence 151 | where 152 | whiles 153 | why 154 | wide 155 | wit 156 | worse 157 | worst 158 | yare 159 | yea 160 | yeah 161 | yep 162 | yes 163 | yet 164 | yon 165 | yore -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockConstValueTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.abstraction.models.ToString; 4 | import org.junit.Test; 5 | 6 | import static net.andreinc.mockneat.abstraction.MockConstValue.constant; 7 | import static org.junit.Assert.assertEquals; 8 | 9 | public class MockConstValueTest { 10 | 11 | @Test 12 | public void testGet() { 13 | String s = "test"; 14 | MockConstValue mco = constant(s); 15 | assertEquals("test", mco.get()); 16 | } 17 | 18 | @Test 19 | public void testGetStr() { 20 | ToString s = new ToString(); 21 | MockConstValue mco = constant(s); 22 | assertEquals(mco.getStr(), ToString.CONST); 23 | } 24 | 25 | @Test 26 | public void testGetStrNull() { 27 | MockConstValue mco = constant(null); 28 | assertEquals("", mco.getStr()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitArrayMethodTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.abstraction.models.ClassicPojo; 4 | import net.andreinc.mockneat.Constants; 5 | import org.junit.Test; 6 | 7 | import java.util.Arrays; 8 | 9 | import static net.andreinc.mockneat.types.enums.StringType.ALPHA_NUMERIC; 10 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 11 | import static org.apache.commons.lang3.StringUtils.isAlphanumeric; 12 | import static org.junit.Assert.*; 13 | 14 | public class MockUnitArrayMethodTest { 15 | 16 | @Test(expected = NullPointerException.class) 17 | public void testArrayNullClass() { 18 | Constants.M.constructor(ClassicPojo.class) 19 | .params(Constants.M.strings(), Constants.M.ints()) 20 | .array(null, 10) 21 | .val(); 22 | } 23 | 24 | @Test(expected = IllegalArgumentException.class) 25 | public void testArrayNegativeSize() { 26 | Constants.M.constructor(ClassicPojo.class) 27 | .params(Constants.M.strings(), Constants.M.ints()) 28 | .array(ClassicPojo.class, -10) 29 | .val(); 30 | } 31 | 32 | @Test 33 | public void testArray() { 34 | loop( 35 | Constants.MOCK_CYCLES, 36 | Constants.MOCKS, 37 | m -> m.constructor(ClassicPojo.class) 38 | .params(Constants.M.strings().type(ALPHA_NUMERIC), 39 | Constants.M.ints().range(0, 10)) 40 | .array(ClassicPojo.class, 10) 41 | .val(), 42 | arr -> { 43 | assertEquals(10, arr.length); 44 | Arrays.stream(arr) 45 | .forEach(el -> { 46 | assertNotNull(el); 47 | assertTrue(isAlphanumeric(el.getName())); 48 | assertTrue(0<= el.getAge() && el.getAge() <= 10); 49 | }); 50 | } 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitBaseTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | public class MockUnitBaseTest { 8 | @Test 9 | public void testMockUnitBase() { 10 | MockUnitBase mub = new MockUnitBase() {}; 11 | Assert.assertEquals(mub.mockNeat, MockNeat.threadLocal()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitConsumeTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertNull; 6 | 7 | import static net.andreinc.mockneat.Constants.M; 8 | 9 | public class MockUnitConsumeTest { 10 | 11 | @Test(expected = NullPointerException.class) 12 | public void testConsumeNulLConsumer() { 13 | M.ints().range(0, 100).consume(null); 14 | } 15 | 16 | @Test(expected = NullPointerException.class) 17 | public void testConsumeWithBiConsumerNullBiConsumer() { 18 | M.ints().range(0, 100).consume(10, null); 19 | } 20 | 21 | @Test(expected = IllegalArgumentException.class) 22 | public void testBiConsumerNegativeTimes() { 23 | M.ints().range(0, 100).consume(-1, null); 24 | } 25 | 26 | @Test(expected = IllegalArgumentException.class) 27 | public void testBiConsumerZeroTimes() { 28 | M.ints().range(0, 100).consume(0, null); 29 | } 30 | 31 | @Test 32 | public void testBiConsumer() { 33 | M.from(new String[]{ null }).consume(10, (i, val) -> assertNull(val)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitDictsTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.types.enums.DictType; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | import java.util.List; 8 | 9 | import static net.andreinc.mockneat.Constants.M; 10 | import static net.andreinc.mockneat.types.enums.DictType.CITIES_US; 11 | 12 | public class MockUnitDictsTest { 13 | 14 | @Test(expected = NullPointerException.class) 15 | public void dictTypeNull() { 16 | M.dicts().type(null).val(); 17 | } 18 | 19 | @Test(expected = IllegalArgumentException.class) 20 | public void dictTypesEmpty() { 21 | DictType[] dictTypes = {}; 22 | M.dicts().types(dictTypes).val(); 23 | } 24 | 25 | @Test(expected = NullPointerException.class) 26 | public void dictDataNull() { 27 | M.dicts().data(null); 28 | } 29 | 30 | @Test 31 | public void dictData() { 32 | List data = M.dicts().data(DictType.COUNTRY_ISO_CODE_2); 33 | data.forEach((code) -> Assert.assertEquals(2, code.length())); 34 | } 35 | 36 | @Test 37 | public void correctFileName() { 38 | Assert.assertEquals("cities/cities-us", CITIES_US.getFileName()); 39 | } 40 | 41 | @Test 42 | public void hasCorrectSize() { 43 | Assert.assertEquals(DictType.ACTORS.size(), 303); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitDoubleTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import org.junit.Test; 4 | 5 | import java.util.Arrays; 6 | 7 | import static net.andreinc.mockneat.Constants.*; 8 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 9 | import static org.junit.Assert.*; 10 | 11 | public class MockUnitDoubleTest { 12 | @Test 13 | public void testDoubleStream() { 14 | loop( 15 | MOCK_CYCLES, 16 | MOCKS, 17 | m -> m.doubles().range(0.0, 10.0).doubleStream().val(), 18 | ds -> { 19 | assertNotNull(ds); 20 | ds.limit(10).forEach(el -> { 21 | assertTrue(0.0 <= el); 22 | assertTrue(el < 10.0); 23 | }); 24 | } 25 | ); 26 | } 27 | 28 | @Test(expected = IllegalArgumentException.class) 29 | public void testArrayPrimitiveWithNegativeSize() { 30 | M.doubles().arrayPrimitive(-5).val(); 31 | } 32 | 33 | @Test 34 | public void testArrayPrimitive() { 35 | loop( 36 | MOCK_CYCLES, 37 | MOCKS, 38 | m -> m.doubles().range(0.0, 10.0).arrayPrimitive(10).val(), 39 | ad -> { 40 | assertNotNull(ad); 41 | assertEquals(10, ad.length); 42 | Arrays.stream(ad).forEach(el -> { 43 | assertTrue(0.0 <= el); 44 | assertTrue(el < 10.0); 45 | }); 46 | } 47 | ); 48 | } 49 | 50 | @Test(expected = IllegalArgumentException.class) 51 | public void testArrayNegative() { 52 | M.doubles().array(-10).val(); 53 | } 54 | 55 | @Test 56 | public void testArray() { 57 | loop( 58 | MOCK_CYCLES, 59 | MOCKS, 60 | m -> m.doubles().range(0.0, 10.0).array(100).val(), 61 | ad -> { 62 | assertNotNull(ad); 63 | assertEquals(100, ad.length); 64 | Arrays.stream(ad).forEach(el -> 65 | { 66 | assertTrue(0.0 <= el); 67 | assertTrue(el < 10.0); 68 | }); 69 | } 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitGenericComposeTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import org.junit.Test; 5 | 6 | import static org.junit.Assert.assertEquals; 7 | 8 | public class MockUnitGenericComposeTest { 9 | 10 | @Test(expected = NullPointerException.class) 11 | public void testConsumerNullConsumer() { 12 | Constants.M.ints().range(0, 100).consume(null); 13 | } 14 | 15 | @Test 16 | public void testConsume1() { 17 | final StringBuilder buff = new StringBuilder(); 18 | Constants.M.intSeq().list(10).consume(l -> l.forEach(buff::append)); 19 | assertEquals("0123456789", buff.toString()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitIntTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import org.junit.Test; 5 | 6 | import java.util.Arrays; 7 | 8 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 9 | import static org.junit.Assert.*; 10 | 11 | public class MockUnitIntTest { 12 | 13 | @Test 14 | public void testIntStream() { 15 | loop( 16 | Constants.MOCK_CYCLES, 17 | Constants.MOCKS, 18 | m -> m.ints().range(0, 10).intStream().val(), 19 | ds -> { 20 | assertNotNull(ds); 21 | ds.limit(10).forEach(el -> { 22 | assertTrue(0 <= el); 23 | assertTrue(el < 10); 24 | }); 25 | } 26 | ); 27 | } 28 | 29 | @Test(expected = IllegalArgumentException.class) 30 | public void testArrayPrimitiveWithNegativeSize() { 31 | Constants.M.ints().arrayPrimitive(-5).val(); 32 | } 33 | 34 | @Test 35 | public void testArrayPrimitive() { 36 | loop( 37 | Constants.MOCK_CYCLES, 38 | Constants.MOCKS, 39 | m -> m.ints().range(0, 10).arrayPrimitive(10).val(), 40 | ai -> { 41 | assertNotNull(ai); 42 | assertEquals(10, ai.length); 43 | Arrays.stream(ai).forEach(el -> { 44 | assertTrue(0 <= el); 45 | assertTrue(el < 10); 46 | }); 47 | } 48 | ); 49 | } 50 | 51 | @Test(expected = IllegalArgumentException.class) 52 | public void testArrayNegative() { 53 | Constants.M.ints().array(-10).val(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitSerializeTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.abstraction.models.ClassicPojo; 4 | import org.junit.Test; 5 | 6 | import java.io.File; 7 | import java.io.FileInputStream; 8 | import java.util.List; 9 | 10 | import static java.util.stream.IntStream.range; 11 | import static net.andreinc.mockneat.Constants.M; 12 | import static org.apache.commons.lang3.SerializationUtils.deserialize; 13 | import static org.junit.Assert.*; 14 | 15 | public class MockUnitSerializeTest { 16 | 17 | @Test 18 | public void testSerializeInteger() throws Exception { 19 | String randomFileName = M.strings().size(36).val(); 20 | M.ints().bound(10).serialize(randomFileName); 21 | 22 | Integer x = deserialize(new FileInputStream(randomFileName)); 23 | assertTrue(x >= 0 && x < 10); 24 | 25 | boolean isDeleted = new File(randomFileName).delete(); 26 | assertTrue(isDeleted); 27 | } 28 | 29 | @Test 30 | public void testSerializeList() throws Exception { 31 | String randomFileName = M.strings().size(36).val(); 32 | M.intSeq().list(100).serialize(randomFileName); 33 | 34 | List list = deserialize(new FileInputStream(randomFileName)); 35 | 36 | assertNotNull(list); 37 | assertEquals(100, list.size()); 38 | assertEquals(0, (int) list.get(0)); 39 | range(0, list.size()).forEach(i -> assertEquals((int) list.get(i), i)); 40 | 41 | boolean isDeleted = new File(randomFileName).delete(); 42 | assertTrue(isDeleted); 43 | } 44 | 45 | @Test 46 | public void testSerializeBean() throws Exception { 47 | String randomFileName = M.strings().size(36).val(); 48 | 49 | M.reflect(ClassicPojo.class) 50 | .useDefaults(true) 51 | .list(100) 52 | .serialize(randomFileName); 53 | 54 | List list = deserialize(new FileInputStream(randomFileName)); 55 | 56 | assertNotNull(list); 57 | assertEquals(100, list.size()); 58 | 59 | boolean isDeleted = new File(randomFileName).delete(); 60 | assertTrue(isDeleted); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitValAndGetMethodTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import org.junit.Test; 5 | 6 | import static org.junit.Assert.assertEquals; 7 | 8 | public class MockUnitValAndGetMethodTest { 9 | 10 | @Test(expected = NullPointerException.class) 11 | public void testValFunctionNullFunction() { 12 | Constants.M.ints().val(null); 13 | } 14 | 15 | @Test(expected = NullPointerException.class) 16 | public void testGetFunctionNullFunction() { 17 | Constants.M.ints().get(null); 18 | } 19 | 20 | 21 | @Test 22 | public void testValFunction() { 23 | String zero = Constants.M.ints().range(0, 1).val(Object::toString); 24 | assertEquals("0", zero); 25 | } 26 | 27 | @Test 28 | public void getGetFunction() { 29 | String zero = Constants.M.ints().range(0, 1).val(Object::toString); 30 | assertEquals("0", zero); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitValAndGetStrMethodTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import org.junit.Test; 4 | 5 | import static net.andreinc.mockneat.Constants.MOCKS; 6 | import static net.andreinc.mockneat.Constants.MOCK_CYCLES; 7 | import static java.lang.Character.isDigit; 8 | import static java.util.Arrays.stream; 9 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 10 | import static org.junit.Assert.*; 11 | 12 | public class MockUnitValAndGetStrMethodTest { 13 | 14 | @Test 15 | public void testValStrNulls() { 16 | loop(MOCK_CYCLES, MOCKS, m -> m.from(new Integer[]{ null, null, null }).valStr(), 17 | s -> assertEquals("", s)); 18 | } 19 | 20 | @Test 21 | public void testStrValBools() { 22 | loop(MOCK_CYCLES, () -> stream(MOCKS).forEach(r -> { 23 | String b = r.bools().valStr(); 24 | assertTrue(b.equals("false") || b.equals("true")); 25 | })); 26 | } 27 | 28 | @Test 29 | public void testStrValChars() { 30 | loop(MOCK_CYCLES, () -> stream(MOCKS).forEach(r -> { 31 | String c = r.chars().digits().valStr(); 32 | assertTrue(c.length()==1 && isDigit(c.charAt(0))); 33 | })); 34 | } 35 | 36 | @Test 37 | public void testStrValDoubles() { 38 | loop(MOCK_CYCLES, () -> stream(MOCKS).forEach(r -> { 39 | String d = r.doubles().valStr(); 40 | try { Double.valueOf(d); } 41 | catch (NumberFormatException e) { fail(); } 42 | })); 43 | } 44 | 45 | @Test 46 | public void testStrValInts() { 47 | loop(MOCK_CYCLES, () -> stream(MOCKS).forEach(r -> { 48 | String i = r.ints().valStr(); 49 | try { Integer.valueOf(i); } 50 | catch (NumberFormatException e) { fail(); } 51 | })); 52 | } 53 | 54 | @Test 55 | public void testStrValLongs() { 56 | loop(MOCK_CYCLES, () -> stream(MOCKS).forEach(r -> { 57 | String l = r.longs().valStr(); 58 | try { Long.valueOf(l); } 59 | catch (NumberFormatException e) { fail(); } 60 | })); 61 | } 62 | 63 | @Test 64 | public void testStrValFloats() { 65 | loop(MOCK_CYCLES, () -> stream(MOCKS).forEach(r -> { 66 | String f = r.floats().valStr(); 67 | try { Float.valueOf(f); } 68 | catch (NumberFormatException e) { fail(); } 69 | })); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/MockUnitValueTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import org.junit.Test; 5 | 6 | import java.time.DayOfWeek; 7 | 8 | import static java.time.DayOfWeek.TUESDAY; 9 | import static net.andreinc.mockneat.abstraction.MockUnitValue.unit; 10 | import static org.junit.Assert.*; 11 | 12 | public class MockUnitValueTest { 13 | 14 | @Test 15 | public void testGet() { 16 | MockUnitInt m = Constants.M.ints().range(0, 5); 17 | MockUnitValue muv = unit(m); 18 | 19 | Integer o = muv.get(); 20 | assertNotNull(o); 21 | 22 | int i = o; 23 | assertTrue(0<=i && i < 5); 24 | } 25 | 26 | @Test 27 | public void testGetStr() { 28 | MockUnitDays m = Constants.M.days().before(TUESDAY); 29 | MockUnitValue muv = unit(m); 30 | 31 | String monday = muv.getStr(); 32 | assertEquals("MONDAY", monday); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/models/AbstractListNoInstance.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction.models; 2 | 3 | import java.util.List; 4 | 5 | public abstract class AbstractListNoInstance implements List { 6 | } 7 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/models/AbstractMapNoInstance.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction.models; 2 | 3 | import java.util.Map; 4 | 5 | public abstract class AbstractMapNoInstance implements Map { 6 | } 7 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/models/AbstractSetNoInstance.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction.models; 2 | 3 | import java.util.Set; 4 | 5 | public abstract class AbstractSetNoInstance implements Set { 6 | } 7 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/models/ClassicPojo.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction.models; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Copyright 2017, Andrei N. Ciobanu 7 | 8 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 9 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 11 | persons to whom the Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 14 | Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 20 | */ 21 | 22 | public class ClassicPojo implements Serializable { 23 | 24 | public String name; 25 | public Integer age; 26 | 27 | public ClassicPojo() {} 28 | 29 | public ClassicPojo(String name, Integer age) { 30 | this.name = name; 31 | this.age = age; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public Integer getAge() { 43 | return age; 44 | } 45 | 46 | public void setAge(Integer age) { 47 | this.age = age; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/abstraction/models/ToString.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.abstraction.models; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | public class ToString { 21 | public static final String CONST = "123456"; 22 | @Override 23 | public String toString() { 24 | return CONST; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/address/CountriesTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.address; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import net.andreinc.mockneat.utils.file.FileManager; 5 | import org.junit.Test; 6 | 7 | import java.util.HashSet; 8 | import java.util.Set; 9 | 10 | import static java.lang.Character.isLowerCase; 11 | import static java.lang.Character.isUpperCase; 12 | import static net.andreinc.mockneat.types.enums.DictType.COUNTRY_ISO_CODE_2; 13 | import static net.andreinc.mockneat.types.enums.DictType.COUNTRY_NAME; 14 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 15 | import static org.junit.Assert.assertTrue; 16 | 17 | public class CountriesTest { 18 | 19 | private final FileManager fm = FileManager.getInstance(); 20 | 21 | @Test 22 | public void testNextCountryName() { 23 | Set countries = 24 | new HashSet<>(fm.getLines(COUNTRY_NAME)); 25 | loop(Constants.COUNTRIES_CYCLES, 26 | Constants.MOCKS, 27 | r -> r.countries().names().val(), 28 | c -> { 29 | assertTrue(isUpperCase(c.charAt(0))); 30 | assertTrue(isLowerCase(c.charAt(1))); 31 | assertTrue(countries.contains(c)); 32 | }); 33 | } 34 | 35 | @Test 36 | public void testNextCountryISO2() { 37 | Set iso2 = 38 | new HashSet<>(fm.getLines(COUNTRY_ISO_CODE_2)); 39 | loop(Constants.COUNTRIES_CYCLES, 40 | Constants.MOCKS, 41 | r -> r.countries().iso2().val(), 42 | c -> { 43 | assertTrue(isUpperCase(c.charAt(0))); 44 | assertTrue(isUpperCase(c.charAt(1))); 45 | assertTrue(iso2.contains(c)); 46 | }); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/address/USStatesTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.address; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import net.andreinc.mockneat.types.enums.DictType; 5 | import net.andreinc.mockneat.utils.LoopsUtils; 6 | import net.andreinc.mockneat.utils.file.FileManager; 7 | import org.junit.Assert; 8 | import org.junit.Test; 9 | 10 | import java.util.HashSet; 11 | import java.util.Set; 12 | 13 | public class USStatesTest { 14 | 15 | private static final FileManager FM = FileManager.getInstance(); 16 | private static final Set US_STATES = new HashSet<>(); 17 | private static final Set US_STATES_ISO2 = new HashSet<>(); 18 | 19 | static { 20 | US_STATES.addAll(FM.getLines(DictType.US_STATES)); 21 | US_STATES_ISO2.addAll(FM.getLines(DictType.US_STATES_IS_CODE_2)); 22 | } 23 | 24 | @Test 25 | public void testUsStates() { 26 | LoopsUtils.loop( 27 | Constants.US_STATES_CYCLES, 28 | Constants.MOCKS, 29 | mockNeat -> mockNeat.usStates().val(), 30 | usState -> Assert.assertTrue(US_STATES.contains(usState)) 31 | ); 32 | } 33 | 34 | @Test 35 | public void testUsStatesIso2() { 36 | LoopsUtils.loop( 37 | Constants.US_STATES_CYCLES, 38 | Constants.MOCKS, 39 | mockNeat -> mockNeat.usStates().iso2().val(), 40 | usStateIso2 -> Assert.assertTrue(US_STATES_ISO2.contains(usStateIso2)) 41 | ); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/companies/CompaniesTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.companies; 2 | 3 | import net.andreinc.mockneat.utils.file.FileManager; 4 | import org.junit.Test; 5 | 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | import static net.andreinc.mockneat.Constants.*; 10 | import static net.andreinc.mockneat.types.enums.DictType.COMPANIES; 11 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 12 | import static org.apache.commons.lang3.StringUtils.isNotEmpty; 13 | import static org.junit.Assert.assertTrue; 14 | 15 | public class CompaniesTest { 16 | private static final FileManager fm = FileManager.getInstance(); 17 | 18 | @Test 19 | public void testCompaniesCorrectValues() { 20 | Set cmps = new HashSet<>(fm.getLines(COMPANIES)); 21 | loop(COMPANIES_CYCLES, MOCKS, (m) -> m.companies().val(), d -> { 22 | assertTrue(isNotEmpty(d)); 23 | assertTrue(cmps.contains(d)); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/companies/DepartmentsTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.companies; 2 | 3 | import net.andreinc.mockneat.utils.file.FileManager; 4 | import org.junit.Test; 5 | 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | import static net.andreinc.mockneat.Constants.DEP_CYCLES; 10 | import static net.andreinc.mockneat.Constants.MOCKS; 11 | import static net.andreinc.mockneat.types.enums.DictType.DEPARTMENTS; 12 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 13 | import static org.apache.commons.lang3.StringUtils.isNotEmpty; 14 | import static org.junit.Assert.assertTrue; 15 | 16 | /** 17 | * Created by andreinicolinciobanu on 26/02/2017. 18 | */ 19 | public class DepartmentsTest { 20 | 21 | private static final FileManager fm = FileManager.getInstance(); 22 | 23 | @Test 24 | public void testDepartmentsCorrectValues() { 25 | Set deps = new HashSet<>(fm.getLines(DEPARTMENTS)); 26 | loop(DEP_CYCLES, MOCKS, (m) -> m.departments().val(), d -> { 27 | assertTrue(isNotEmpty(d)); 28 | assertTrue(deps.contains(d)); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/companies/IndustriesTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.companies; 2 | 3 | import net.andreinc.mockneat.utils.file.FileManager; 4 | import org.junit.Test; 5 | 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | import static net.andreinc.mockneat.Constants.*; 10 | import static net.andreinc.mockneat.types.enums.DictType.INDUSTRIES; 11 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 12 | import static org.apache.commons.lang3.StringUtils.isNotEmpty; 13 | import static org.junit.Assert.assertTrue; 14 | 15 | public class IndustriesTest { 16 | private static final FileManager fm = FileManager.getInstance(); 17 | 18 | @Test 19 | public void testCompaniesCorrectValues() { 20 | Set inds = new HashSet<>(fm.getLines(INDUSTRIES)); 21 | loop(INDUSTRIES_CYCLES, MOCKS, (m) -> m.industries().val(), d -> { 22 | assertTrue(isNotEmpty(d)); 23 | assertTrue(inds.contains(d)); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/financial/CVVSTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.financial; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import org.apache.commons.lang3.StringUtils; 5 | import org.junit.Test; 6 | 7 | import static net.andreinc.mockneat.Constants.M; 8 | import static net.andreinc.mockneat.types.enums.CVVType.CVV3; 9 | import static net.andreinc.mockneat.types.enums.CVVType.CVV4; 10 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 11 | import static org.apache.commons.lang3.StringUtils.isAlphanumeric; 12 | import static org.apache.commons.lang3.StringUtils.isEmpty; 13 | import static org.junit.Assert.assertTrue; 14 | 15 | /** 16 | * Created by andreinicolinciobanu on 08/02/2017. 17 | */ 18 | public class CVVSTest { 19 | 20 | @Test(expected = NullPointerException.class) 21 | public void testCVVTypeNotNull() { 22 | M.cvvs().type(null).val(); 23 | } 24 | 25 | @Test 26 | public void testCVV3() { 27 | loop(Constants.CVVS_CYCLES, Constants.MOCKS, r -> r.cvvs().type(CVV3).val(), cvv -> { 28 | assertTrue(!isEmpty(cvv) && cvv.length()==3); 29 | assertTrue(isAlphanumeric(cvv)); 30 | }); 31 | } 32 | 33 | @Test 34 | public void testCVV4() { 35 | loop(Constants.CVVS_CYCLES, Constants.MOCKS, r -> r.cvvs().type(CVV4).val(), cvv -> { 36 | assertTrue(null!=cvv && cvv.length()==4); 37 | assertTrue(isAlphanumeric(cvv)); 38 | }); 39 | } 40 | 41 | @Test(expected = NullPointerException.class) 42 | public void testCVVTypesNullType() { 43 | M.cvvs().types(CVV3, null).val(); 44 | } 45 | 46 | @Test 47 | public void testCVVTypes() { 48 | loop( 49 | Constants.CVVS_CYCLES, 50 | Constants.MOCKS, 51 | mockNeat -> mockNeat.cvvs().types(CVV3, CVV4).val(), 52 | cvv -> assertTrue((cvv.length()==3 || cvv.length()==4) 53 | && StringUtils.isNumeric(cvv)) 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/financial/CurrenciesTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.financial; 2 | 3 | import net.andreinc.mockneat.types.enums.CurrencySymbolType; 4 | import org.junit.Test; 5 | 6 | import java.util.Arrays; 7 | import java.util.HashSet; 8 | import java.util.Set; 9 | 10 | import static net.andreinc.mockneat.Constants.CURRENCIES_CYCLES; 11 | import static net.andreinc.mockneat.Constants.MOCKS; 12 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 13 | import static org.junit.Assert.assertTrue; 14 | 15 | public class CurrenciesTest { 16 | private static final Set CODES = new HashSet<>(); 17 | private static final Set SYMBOLS = new HashSet<>(); 18 | private static final Set NAMES = new HashSet<>(); 19 | 20 | static { 21 | Arrays.stream(CurrencySymbolType.values()).forEach(v -> { 22 | CODES.add(v.getCode()); 23 | SYMBOLS.add(v.getSymbol()); 24 | NAMES.add(v.getName()); 25 | }); 26 | } 27 | 28 | @Test 29 | public void testCodes() { 30 | loop(CURRENCIES_CYCLES, MOCKS, r -> r.currencies().code().val(), c -> assertTrue(CODES.contains(c))); 31 | } 32 | 33 | @Test 34 | public void testSymbol() { 35 | loop(CURRENCIES_CYCLES, MOCKS, r -> r.currencies().symbol().val(), c -> assertTrue(SYMBOLS.contains(c))); 36 | } 37 | 38 | @Test 39 | public void testName() { 40 | loop(CURRENCIES_CYCLES, MOCKS, r -> r.currencies().name().val(), c -> assertTrue(NAMES.contains(c))); 41 | } 42 | 43 | @Test 44 | public void testForexPair() { 45 | loop(CURRENCIES_CYCLES, MOCKS, r -> r.currencies().forexPair().val(), c -> { 46 | String[] pairs = c.split("/"); 47 | assertTrue(CODES.contains(pairs[0])); 48 | assertTrue(CODES.contains(pairs[1])); 49 | }); 50 | } 51 | } -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/financial/IBANsTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.financial; 2 | 3 | import net.andreinc.mockneat.types.enums.IBANType; 4 | import org.apache.commons.validator.routines.checkdigit.IBANCheckDigit; 5 | import org.junit.Test; 6 | 7 | import static net.andreinc.mockneat.Constants.*; 8 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 9 | import static org.junit.Assert.assertTrue; 10 | 11 | public class IBANsTest { 12 | 13 | private static final IBANCheckDigit ICD = new IBANCheckDigit(); 14 | 15 | @Test(expected = NullPointerException.class) 16 | public void testNullType() { 17 | M.ibans().type(null).val(); 18 | } 19 | 20 | @Test(expected = NullPointerException.class) 21 | public void testNullTypes() { 22 | M.ibans().types(null, null).val(); 23 | } 24 | 25 | @Test(expected = IllegalArgumentException.class) 26 | public void testEmptyTypes() { 27 | IBANType[] types = new IBANType[]{}; 28 | M.ibans().types(types).val(); 29 | } 30 | 31 | @Test 32 | public void testIbanType() { 33 | loop( 34 | IBANS_CYCLES, 35 | MOCKS, 36 | mockNeat -> mockNeat.ibans().type(IBANType.AUSTRIA).val(), 37 | iban -> assertTrue(ICD.isValid(iban)) 38 | ); 39 | } 40 | 41 | @Test 42 | public void testCheckDigitsInGeneral() { 43 | loop( 44 | IBANS_CYCLES, 45 | MOCKS, 46 | r -> r.ibans().val(), 47 | IBAN -> assertTrue(ICD.isValid(IBAN)) 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/hashes/MD2sTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.hashes; 2 | 3 | import org.junit.Test; 4 | 5 | import static net.andreinc.mockneat.Constants.HASH_CYCLES; 6 | import static net.andreinc.mockneat.Constants.MOCKS; 7 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 8 | import static org.junit.Assert.assertTrue; 9 | 10 | public class MD2sTest { 11 | @Test 12 | public void testMD2sHash() { 13 | loop( 14 | HASH_CYCLES, 15 | MOCKS, 16 | m -> m.hashes().md2().val(), 17 | md2 ->assertTrue(md2.matches("^[0-9a-f]+$")) 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/hashes/MD5sTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.hashes; 2 | 3 | import org.junit.Test; 4 | 5 | import static net.andreinc.mockneat.Constants.HASH_CYCLES; 6 | import static net.andreinc.mockneat.Constants.MOCKS; 7 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 8 | import static org.junit.Assert.assertTrue; 9 | 10 | public class MD5sTest { 11 | @Test 12 | public void testMD5sHash() { 13 | loop( 14 | HASH_CYCLES, 15 | MOCKS, 16 | m -> m.hashes().md5().val(), 17 | md5 -> assertTrue(md5.matches("^[0-9a-f]+$")) 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/hashes/SHA1sTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.hashes; 2 | 3 | import org.junit.Test; 4 | 5 | import static net.andreinc.mockneat.Constants.HASH_CYCLES; 6 | import static net.andreinc.mockneat.Constants.MOCKS; 7 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 8 | import static org.junit.Assert.assertTrue; 9 | 10 | public class SHA1sTest { 11 | @Test 12 | public void testSHA1sHash() { 13 | loop( 14 | HASH_CYCLES, 15 | MOCKS, 16 | m -> m.hashes().sha1().val(), 17 | sha1 -> assertTrue(sha1.matches("^[0-9a-f]+$")) 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/hashes/SHA256sTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.hashes; 2 | 3 | import org.junit.Test; 4 | 5 | import static net.andreinc.mockneat.Constants.HASH_CYCLES; 6 | import static net.andreinc.mockneat.Constants.MOCKS; 7 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 8 | import static org.junit.Assert.assertTrue; 9 | 10 | public class SHA256sTest { 11 | @Test 12 | public void testSHA256sHash() { 13 | loop( 14 | HASH_CYCLES, 15 | MOCKS, 16 | m -> m.hashes().sha256().val(), 17 | sha256 -> assertTrue(sha256.matches("^[0-9a-f]+$")) 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/hashes/SHA384sTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.hashes; 2 | 3 | import org.junit.Test; 4 | 5 | import static net.andreinc.mockneat.Constants.HASH_CYCLES; 6 | import static net.andreinc.mockneat.Constants.MOCKS; 7 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 8 | import static org.junit.Assert.assertTrue; 9 | 10 | public class SHA384sTest { 11 | @Test 12 | public void testSHA384sHash() { 13 | loop( 14 | HASH_CYCLES, 15 | MOCKS, 16 | m -> m.hashes().sha384().val(), 17 | sha384 -> assertTrue(sha384.matches("^[0-9a-f]+$")) 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/hashes/SHA512sTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.hashes; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import static net.andreinc.mockneat.Constants.HASH_CYCLES; 7 | import static net.andreinc.mockneat.Constants.MOCKS; 8 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 9 | 10 | public class SHA512sTest { 11 | 12 | @Test 13 | public void testSHA512sHash() { 14 | loop( 15 | HASH_CYCLES, 16 | MOCKS, 17 | m -> m.hashes().sha512().val(), 18 | sha512 -> Assert.assertTrue(sha512.matches("^[0-9a-f]+$")) 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/misc/ISSNSTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.misc; 2 | 3 | import org.apache.commons.validator.routines.ISSNValidator; 4 | import org.junit.Test; 5 | 6 | import static net.andreinc.mockneat.Constants.*; 7 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 8 | import static org.junit.Assert.assertNotNull; 9 | 10 | public class ISSNSTest { 11 | 12 | private final ISSNValidator validator = ISSNValidator.getInstance(); 13 | 14 | @Test 15 | public void test() { 16 | loop( 17 | ISSNS_CYCLES, 18 | MOCKS, 19 | m -> m.issns().val(), 20 | issn -> assertNotNull(validator.validate(issn)) 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/misc/MimesTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.misc; 2 | 3 | 4 | import net.andreinc.mockneat.Constants; 5 | import net.andreinc.mockneat.types.enums.DictType; 6 | import net.andreinc.mockneat.utils.LoopsUtils; 7 | import net.andreinc.mockneat.utils.file.FileManager; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | 11 | import java.util.HashSet; 12 | import java.util.Set; 13 | 14 | public class MimesTest { 15 | 16 | private final FileManager fm = 17 | FileManager.getInstance(); 18 | 19 | private final Set allMimes = new HashSet<>(fm.getLines(DictType.MIME_TYPE)); 20 | 21 | @Test 22 | public void testMimes() { 23 | LoopsUtils.loop( 24 | Constants.MIME_CYCLES, 25 | Constants.MOCKS, 26 | mockNeat -> mockNeat.mimes().val(), 27 | mime -> Assert.assertTrue(allMimes.contains(mime)) 28 | ); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/misc/SSCsTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.misc; 2 | 3 | import net.andreinc.mockneat.MockNeat; 4 | import org.junit.Test; 5 | 6 | import static net.andreinc.mockneat.Constants.MOCKS; 7 | import static net.andreinc.mockneat.Constants.SSC_CYCLES; 8 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 9 | import static org.junit.Assert.*; 10 | 11 | public class SSCsTest { 12 | 13 | @Test 14 | public void testSSC() { 15 | loop( 16 | SSC_CYCLES, 17 | MOCKS, 18 | m -> m.sscs().val(), 19 | ssc -> { 20 | 21 | assertNotEquals("078-05-1120", ssc); 22 | assertNotEquals("219-09-9999", ssc); 23 | assertFalse(ssc.startsWith("666")); 24 | 25 | String[] sscArr = ssc.split("-"); 26 | 27 | assertEquals(3, sscArr.length); 28 | 29 | String aaa = sscArr[0]; 30 | String gg = sscArr[1]; 31 | String ssss = sscArr[2]; 32 | 33 | assertEquals(3, aaa.length()); 34 | assertEquals(2, gg.length()); 35 | assertEquals(4, ssss.length()); 36 | } 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/networking/DomainsTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.networking; 2 | 3 | import net.andreinc.mockneat.types.enums.DomainSuffixType; 4 | import net.andreinc.mockneat.utils.file.FileManager; 5 | import org.junit.Test; 6 | 7 | import java.util.HashSet; 8 | import java.util.Set; 9 | 10 | import static net.andreinc.mockneat.Constants.*; 11 | import static net.andreinc.mockneat.types.enums.DictType.DOMAIN_TOP_LEVEL_POPULAR; 12 | import static net.andreinc.mockneat.types.enums.DomainSuffixType.ALL; 13 | import static net.andreinc.mockneat.types.enums.DomainSuffixType.POPULAR; 14 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 15 | import static org.junit.Assert.assertTrue; 16 | 17 | public class DomainsTest { 18 | 19 | public static final FileManager FM = FileManager.getInstance(); 20 | 21 | @Test 22 | public void testDomain() { 23 | Set set = new HashSet<>(FM.getLines(DOMAIN_TOP_LEVEL_POPULAR)); 24 | loop(DOMAIN_CYCLES, MOCKS, r -> r.domains().val(), d -> assertTrue(set.contains(d))); 25 | } 26 | 27 | @Test(expected = NullPointerException.class) 28 | public void testDomainNullType() { 29 | M.domains().type(null).val(); 30 | } 31 | 32 | @Test(expected = NullPointerException.class) 33 | public void testDomainNullTypes() { 34 | M.domains().types((DomainSuffixType[]) null).val(); 35 | } 36 | 37 | @Test(expected = IllegalArgumentException.class) 38 | public void testDomainEmptyTypes() { 39 | M.domains().types().val(); 40 | } 41 | 42 | @Test(expected = IllegalArgumentException.class) 43 | public void testDomainEmptyTypes1() { 44 | M.domains().types(new DomainSuffixType[]{}).val(); 45 | } 46 | 47 | @Test(expected = NullPointerException.class) 48 | public void testDomainNullElementInTypes() { 49 | M.domains().types(new DomainSuffixType[]{ ALL, POPULAR, null}).val(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/networking/IPv6sTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.networking; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import org.apache.commons.validator.routines.InetAddressValidator; 5 | import org.junit.Test; 6 | 7 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 8 | import static org.junit.Assert.assertTrue; 9 | 10 | public class IPv6sTest { 11 | private static final InetAddressValidator IAV = new InetAddressValidator(); 12 | 13 | @Test 14 | public void testIPv6AddressesWithINetValidator() { 15 | loop(Constants.IPV6S_CYCLES, 16 | Constants.MOCKS, 17 | r -> r.iPv6s().val(), 18 | i -> assertTrue(IAV.isValidInet6Address(i))); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/objects/ConstantTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.objects; 2 | 3 | import net.andreinc.mockneat.abstraction.MockUnit; 4 | import org.apache.commons.collections.CollectionUtils; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | import java.util.List; 9 | 10 | import static net.andreinc.mockneat.Constants.M; 11 | 12 | /** 13 | * Copyright 2020, Andrei N. Ciobanu 14 | 15 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 16 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 17 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 18 | persons to whom the Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 21 | Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 24 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 25 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 26 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 27 | */ 28 | 29 | public class ConstantTest { 30 | 31 | @Test 32 | public void testConstant() { 33 | MockUnit ints = M.constant(3); 34 | 35 | int x = ints.get(); 36 | int y = ints.get(); 37 | 38 | Assert.assertEquals(x, y); 39 | } 40 | 41 | @Test 42 | public void testConstant_arr() { 43 | MockUnit aAAAs = M.constant("AAA"); 44 | 45 | List l1 = aAAAs.list(10).get(); 46 | List l2 = aAAAs.list(10).get(); 47 | 48 | Assert.assertTrue(CollectionUtils.isEqualCollection(l1, l2)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/objects/FillerTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.objects; 2 | 3 | import net.andreinc.mockneat.unit.objects.model.SimpleBean; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import static net.andreinc.mockneat.Constants.M; 11 | 12 | public class FillerTest { 13 | 14 | @Test 15 | public void test1() { 16 | SimpleBean s = M.filler(SimpleBean::new) 17 | .setter(SimpleBean::setS, M.from(new String[]{"A"})) 18 | .val(); 19 | 20 | Assert.assertEquals("A", s.getS()); 21 | } 22 | 23 | @Test(expected = NullPointerException.class) 24 | public void testFillerNullSupp() { 25 | M.filler(null); 26 | } 27 | 28 | @Test(expected = NullPointerException.class) 29 | public void testFillerNullSetter() { 30 | M.filler(SimpleBean::new) 31 | .setter(null, M.from(new String[]{"A"})); 32 | } 33 | 34 | @Test(expected = NullPointerException.class) 35 | public void testFillerNullValue() { 36 | M.filler(SimpleBean::new) 37 | .setter(SimpleBean::setS, null); 38 | } 39 | 40 | @Test 41 | public void testFillerWithConstant() { 42 | List simpleBeans = M.filler(SimpleBean::new) 43 | .constant(SimpleBean::setS, "A") 44 | .list(ArrayList::new, 5) 45 | .val(); 46 | 47 | simpleBeans.forEach(s -> Assert.assertEquals("A", s.getS())); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/objects/model/FactoryMethods.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.objects.model; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | public final class FactoryMethods { 21 | 22 | public static StringBuilder buffBuilder(String val) { 23 | return new StringBuilder(val); 24 | } 25 | 26 | public static StringBuffer buffBuffer(String val) { 27 | return new StringBuffer(val); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/objects/model/FinalValue.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.objects.model; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | public class FinalValue { 21 | 22 | private final String name = "Hello"; 23 | 24 | public FinalValue() {} 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/objects/model/SerialPojo.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.objects.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class SerialPojo implements Serializable { 6 | 7 | private static final long serialVersionUID = 42L; 8 | 9 | private String name; 10 | 11 | public SerialPojo() { 12 | } 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/objects/model/SimpleBean.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.objects.model; 2 | 3 | import java.util.Objects; 4 | 5 | public class SimpleBean { 6 | private String s; 7 | 8 | public SimpleBean() {} 9 | 10 | public SimpleBean(String s) { 11 | this.s = s; 12 | } 13 | 14 | public String getS() { 15 | return s; 16 | } 17 | 18 | public void setS(String s) { 19 | this.s = s; 20 | } 21 | 22 | @Override 23 | public boolean equals(Object o) { 24 | if (this == o) return true; 25 | if (o == null || getClass() != o.getClass()) return false; 26 | SimpleBean that = (SimpleBean) o; 27 | return Objects.equals(s, that.s); 28 | } 29 | 30 | @Override 31 | public int hashCode() { 32 | return Objects.hash(s); 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "SimpleBean{" + 38 | "s='" + s + '\'' + 39 | '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/objects/model/TheAbstractClass.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.objects.model; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | public abstract class TheAbstractClass { 21 | private final String name; 22 | 23 | public TheAbstractClass(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/regex/RegexTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.regex; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import static net.andreinc.mockneat.Constants.*; 7 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 8 | 9 | public class RegexTest { 10 | 11 | @Test(expected = NullPointerException.class) 12 | public void testNulLRegex() { 13 | M.regex(null).val(); 14 | } 15 | 16 | @Test(expected = IllegalArgumentException.class) 17 | public void testInvalidRegex() { 18 | M.regex("1{").val(); 19 | } 20 | 21 | @Test 22 | public void testFromRegex() { 23 | loop( 24 | REGEX_CYLCES, 25 | MOCKS, 26 | m -> m.regex("[0-3]([a-c]|[e-g]{1,2})").val(), 27 | r -> Assert.assertTrue(r.matches("[0-3]([a-c]|[e-g]{1,2})")) 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/seq/IntSeqTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.seq; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import net.andreinc.mockneat.MockNeat; 5 | import org.junit.Test; 6 | 7 | import java.util.List; 8 | 9 | import static java.util.stream.IntStream.range; 10 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 11 | import static org.junit.Assert.assertEquals; 12 | import static org.junit.Assert.assertTrue; 13 | 14 | public class IntSeqTest { 15 | 16 | @Test(expected = IllegalArgumentException.class) 17 | public void testConstructorMinBiggerMax() { 18 | new IntSeq(0, 1, 10, 20, false); 19 | } 20 | 21 | @Test 22 | public void testIntSeq() { 23 | loop( 24 | Constants.SEQ_CYCLES, 25 | Constants.MOCKS, 26 | MockNeat::intSeq, 27 | seq -> range(0, 100).forEach(i -> assertEquals((int) seq.val(), i)) 28 | ); 29 | } 30 | 31 | @Test 32 | public void testIntSeqCycle() { 33 | loop( 34 | Constants.SEQ_CYCLES, 35 | Constants.MOCKS, 36 | m -> m.intSeq().start(10).max(15).cycle(true), 37 | seq -> 38 | loop(1000, () -> { 39 | int val = seq.val(); 40 | assertTrue(10 <= val); 41 | assertTrue(val <= 15); 42 | }) 43 | ); 44 | } 45 | 46 | @Test 47 | public void testIntSeqListings() { 48 | loop( 49 | Constants.SEQ_CYCLES, 50 | Constants.MOCKS, 51 | (m) -> { 52 | int size = m.ints().range(100, 1000).val(); 53 | List lst = m.intSeq().start(1).list(size).val(); 54 | int sum = lst.stream().mapToInt(Integer::intValue).sum(); 55 | assertEquals(sum, (long) size * (size + 1) / 2); 56 | } 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/seq/LongSeqTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.seq; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import net.andreinc.mockneat.MockNeat; 5 | import org.junit.Test; 6 | 7 | import java.util.List; 8 | 9 | import static java.util.stream.IntStream.range; 10 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 11 | import static org.junit.Assert.assertEquals; 12 | import static org.junit.Assert.assertTrue; 13 | 14 | public class LongSeqTest { 15 | @Test(expected = IllegalArgumentException.class) 16 | public void testConstructorMinBiggerMax() { 17 | new LongSeq(0, 1, 10, 20, false); 18 | } 19 | 20 | @Test 21 | public void testIntSeq() { 22 | loop( 23 | Constants.SEQ_CYCLES, 24 | Constants.MOCKS, 25 | MockNeat::longSeq, 26 | seq -> range(0, 100).forEach(i -> assertEquals((long) seq.val(), i)) 27 | ); 28 | } 29 | 30 | @Test 31 | public void testIntSeqCycle() { 32 | loop( 33 | Constants.SEQ_CYCLES, 34 | Constants.MOCKS, 35 | m -> m.longSeq().start(10).max(15).cycle(true), 36 | seq -> 37 | loop(1000, () -> { 38 | long val = seq.val(); 39 | assertTrue(10 <= val); 40 | assertTrue(val <= 15); 41 | }) 42 | ); 43 | } 44 | 45 | @Test 46 | public void testIntSeqListings() { 47 | loop( 48 | Constants.SEQ_CYCLES, 49 | Constants.MOCKS, 50 | (m) -> { 51 | int size = m.ints().range(100, 1000).val(); 52 | List lst = m.longSeq().start(1).list(size).val(); 53 | long sum = lst.stream().mapToLong(i -> i).sum(); 54 | assertEquals(sum, (long) size * (size + 1) / 2); 55 | } 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/text/CreaturesTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.text; 2 | 3 | import net.andreinc.mockneat.Constants; 4 | import net.andreinc.mockneat.types.enums.DictType; 5 | import net.andreinc.mockneat.utils.file.FileManager; 6 | import org.junit.Test; 7 | 8 | import java.util.HashSet; 9 | import java.util.Set; 10 | 11 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 12 | import static org.junit.Assert.assertTrue; 13 | 14 | public class CreaturesTest { 15 | 16 | private final Set allCreatures = new HashSet<>(FileManager.getInstance().getLines(DictType.CREATURES)); 17 | 18 | @Test 19 | public void testCreatures() { 20 | loop( 21 | Constants.CREATURES_CYCLES, 22 | Constants.MOCKS, 23 | m -> m.creatures().get(), 24 | c -> assertTrue(allCreatures.contains(c)) 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/text/FromFilesTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.text; 2 | 3 | import org.junit.Test; 4 | 5 | import java.io.IOException; 6 | import java.nio.file.Path; 7 | 8 | import static java.nio.file.Files.createTempFile; 9 | import static java.nio.file.Files.write; 10 | import static java.nio.file.StandardOpenOption.APPEND; 11 | import static net.andreinc.mockneat.Constants.*; 12 | import static net.andreinc.mockneat.types.enums.StringType.LETTERS; 13 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 14 | import static org.junit.Assert.assertTrue; 15 | import static org.junit.Assert.fail; 16 | 17 | public class FromFilesTest { 18 | 19 | @Test(expected = NullPointerException.class) 20 | public void testNullPath() { 21 | M.files().from(null).val(); 22 | } 23 | 24 | @Test(expected = IllegalArgumentException.class) 25 | public void testEmptyPath() { 26 | M.files().from("").val(); 27 | } 28 | 29 | @Test 30 | public void testFiles() { 31 | String tmpFile = M.strings().size(32).type(LETTERS).val(); 32 | String tmpFileExt = M.strings().size(3).type(LETTERS).val(); 33 | Path tmp = null; 34 | try { 35 | tmp = createTempFile(tmpFile, tmpFileExt); 36 | tmp.toFile().deleteOnExit(); 37 | final String path = tmp.toFile().getPath(); 38 | // Writing content to disk 39 | write(tmp, M.ints().range(0, 100).mapToString().list(100).val(), APPEND); 40 | loop( 41 | FILES_CYCLES, 42 | MOCKS, 43 | m -> m.files().from(path).val(), 44 | l -> { 45 | int x = Integer.parseInt(l); 46 | assertTrue(0<=x && x <100); 47 | } 48 | ); 49 | } catch (IOException e) { 50 | if (null != tmp) { 51 | tmp.toFile().deleteOnExit(); 52 | } 53 | fail("Cannot write tmp file to disk"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/text/MarkovsTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.text; 2 | 3 | import net.andreinc.mockneat.types.enums.MarkovChainType; 4 | import org.junit.Test; 5 | 6 | import static net.andreinc.mockneat.unit.text.Markovs.markovs; 7 | 8 | public class MarkovsTest { 9 | @Test 10 | public void test1() { 11 | markovs().type(MarkovChainType.LOREM_IPSUM).get(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/time/MonthsTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.time; 2 | 3 | import org.junit.Test; 4 | 5 | import java.time.Month; 6 | import java.util.EnumSet; 7 | import java.util.Set; 8 | 9 | import static net.andreinc.mockneat.Constants.DAYS_CYCLES; 10 | import static net.andreinc.mockneat.Constants.MOCKS; 11 | import static java.time.Month.DECEMBER; 12 | import static java.time.Month.NOVEMBER; 13 | import static java.time.Month.OCTOBER; 14 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 15 | import static org.junit.Assert.assertNotNull; 16 | import static org.junit.Assert.assertTrue; 17 | 18 | public class MonthsTest { 19 | 20 | @Test 21 | public void testMonths() { 22 | loop(DAYS_CYCLES, MOCKS, r -> 23 | assertNotNull((r.months().val()))); 24 | } 25 | 26 | @Test 27 | public void testDaysInRange() { 28 | Set monthSet = EnumSet.of(OCTOBER, NOVEMBER); 29 | loop(DAYS_CYCLES, 30 | MOCKS, 31 | r -> r.months().range(OCTOBER, DECEMBER).val(), 32 | m -> assertTrue(monthSet.contains(m))); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/types/BoolsTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.types; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import static net.andreinc.mockneat.Constants.*; 7 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 8 | 9 | public class BoolsTest { 10 | 11 | @Test 12 | public void test100ProbabilityVal() { 13 | loop(BOOLS_CYCLES, 14 | MOCKS, 15 | r -> r.bools().probability(100.0).val(), 16 | Assert::assertTrue); 17 | } 18 | 19 | @Test 20 | public void testNextBooleanAlwaysFalseIf() { 21 | loop(BOOLS_CYCLES, 22 | MOCKS, 23 | r -> r.bools().probability(0.0).val(), 24 | Assert::assertFalse); 25 | } 26 | 27 | @Test 28 | public void testNextBooleanAlwaysFalseIf02() { 29 | loop(BOOLS_CYCLES, 30 | MOCKS, 31 | rand -> rand.bools().probability(0.0).val(), 32 | Assert::assertFalse); 33 | } 34 | 35 | @Test(expected = IllegalArgumentException.class) 36 | public void testNextBooleanNegativeNotProbability() { 37 | M.bools().probability(-5.0).val(); 38 | } 39 | 40 | @Test(expected = IllegalArgumentException.class) 41 | public void testNextBooleanNegativeNotProbability_2() { 42 | M.bools().probability(-5.0).val(); 43 | } 44 | 45 | @Test(expected = IllegalArgumentException.class) 46 | public void testNextBooleanGreaterThan100NotProbability() { 47 | M.bools().probability(105.0).val(); 48 | } 49 | 50 | @Test(expected = IllegalArgumentException.class) 51 | public void testNextBooleanGreaterThan100NotProbability2() { 52 | M.bools().probability(105.0).val(); 53 | } 54 | 55 | @Test 56 | public void testBools() { 57 | loop(BOOLS_CYCLES, 58 | MOCKS, 59 | r -> r.bools().val(), 60 | Assert::assertNotNull); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/user/GendersTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.user; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import static net.andreinc.mockneat.Constants.GENDERS_CYCLES; 7 | import static net.andreinc.mockneat.Constants.MOCKS; 8 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 9 | 10 | public class GendersTest { 11 | @Test 12 | public void testGendersLong() { 13 | loop( 14 | GENDERS_CYCLES, 15 | MOCKS, 16 | m -> m.genders().val(), 17 | gender -> Assert.assertTrue(gender.equals("Male") || gender.equals("Female")) 18 | ); 19 | } 20 | 21 | @Test 22 | public void testGendersLetter() { 23 | loop( 24 | GENDERS_CYCLES, 25 | MOCKS, 26 | m -> m.genders().letter().val(), 27 | gender -> Assert.assertTrue(gender.equals("M") || gender.equals("F")) 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/user/NonBinaryGenderTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.user; 2 | 3 | import net.andreinc.mockneat.utils.file.FileManager; 4 | import org.junit.Test; 5 | 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | import static net.andreinc.mockneat.Constants.*; 10 | import static net.andreinc.mockneat.types.enums.DictType.NON_BINARY_GENDERS; 11 | import static net.andreinc.mockneat.utils.LoopsUtils.loop; 12 | import static org.apache.commons.lang3.StringUtils.isNotEmpty; 13 | import static org.junit.Assert.assertTrue; 14 | 15 | public class NonBinaryGenderTest { 16 | private static final FileManager fm = FileManager.getInstance(); 17 | 18 | @Test 19 | public void testCompaniesCorrectValues() { 20 | Set nbg = new HashSet<>(fm.getLines(NON_BINARY_GENDERS)); 21 | loop(NON_BINARY_GENDER_CYLES, MOCKS, (m) -> m.nonBinaryGenders().val(), d -> { 22 | assertTrue(isNotEmpty(d)); 23 | assertTrue(nbg.contains(d)); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/unit/user/UsersTest.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.unit.user; 2 | 3 | import net.andreinc.mockneat.types.enums.UserNameType; 4 | import org.junit.Test; 5 | 6 | import static net.andreinc.mockneat.Constants.M; 7 | 8 | public class UsersTest { 9 | 10 | @Test(expected = NullPointerException.class) 11 | public void testUsersTypeNull() { 12 | M.users().type(null).val(); 13 | } 14 | 15 | @Test(expected = NullPointerException.class) 16 | public void testUsersTypesNull() { 17 | M.users().types((UserNameType[]) null).val(); 18 | } 19 | 20 | @Test(expected = IllegalArgumentException.class) 21 | public void testUsersTypesEmpty() { 22 | M.users().types(new UserNameType[]{}).val(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/utils/LuhnUtils.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.utils; 2 | 3 | /** 4 | * Copyright 2017, Andrei N. Ciobanu 5 | 6 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 18 | */ 19 | 20 | 21 | public final class LuhnUtils { 22 | /** 23 | * Tests if a certain String is a valid Luhn number 24 | * @param cc The value to be tested if it's a Luhn number 25 | * @return True if the value is a Luhn number, false otherwise 26 | */ 27 | public static boolean luhnCheck(String cc) { 28 | int result = 0; 29 | boolean flag = false; 30 | int digit; 31 | int i = cc.length(); 32 | 33 | while(i-->0) { 34 | digit = Character.getNumericValue(cc.charAt(i)); 35 | if (flag) { 36 | digit *= 2; 37 | if (digit > 9) { 38 | digit = (digit % 10) + 1; 39 | } 40 | } 41 | result += digit; 42 | flag = !flag; 43 | } 44 | 45 | return (result % 10 == 0); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/utils/MapCheckUtils.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.utils; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.TreeMap; 6 | import java.util.function.Consumer; 7 | 8 | import static org.junit.Assert.*; 9 | 10 | public final class MapCheckUtils { 11 | public static void testMap(Map map, 12 | Consumer validateKeys, 13 | Consumer validateVals, 14 | Consumer> validateMap) { 15 | assertNotNull(map); 16 | map.forEach((k,v) -> { 17 | validateKeys.accept(k); 18 | validateVals.accept(v); 19 | validateMap.accept(map); 20 | }); 21 | } 22 | public static void testMap(Map map, 23 | Consumer validateKeys, 24 | Consumer validateVals) { 25 | testMap(map, validateKeys, validateVals, (m) -> { 26 | if (!(map instanceof TreeMap || map instanceof HashMap)) 27 | fail(); 28 | }); 29 | } 30 | public static > Consumer inRange(T1 low, T1 high) { 31 | return (T1 t) -> { if (!(t.compareTo(low) >= 0 && t.compareTo(high) < 0)) fail(); }; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/net/andreinc/mockneat/utils/NamesCheckUtils.java: -------------------------------------------------------------------------------- 1 | package net.andreinc.mockneat.utils; 2 | 3 | 4 | import net.andreinc.mockneat.types.enums.NameType; 5 | import net.andreinc.mockneat.utils.file.FileManager; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * Copyright 2017, Andrei N. Ciobanu 11 | 12 | Permission is hereby granted, free of charge, to any user obtaining a copy of this software and associated 13 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 14 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 15 | persons to whom the Software is furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 18 | Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 21 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 22 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 23 | OTHERWISE, ARISING FROM, FREE_TEXT OF OR PARAM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS PARAM THE SOFTWARE. 24 | */ 25 | 26 | public final class NamesCheckUtils { 27 | 28 | private static final FileManager FILE_MANAGER = FileManager.getInstance(); 29 | private static final Map>> NAMES = new EnumMap<>(NameType.class); 30 | 31 | static { 32 | Arrays.stream(NameType.values()).forEach(nt -> { 33 | List> ll = new LinkedList<>(); 34 | Arrays.stream(nt.getDictionaries()).forEach(dict -> 35 | ll.add(new HashSet<>(FILE_MANAGER.getLines(dict)))); 36 | NAMES.put(nt, ll); 37 | }); 38 | } 39 | 40 | private static boolean isInSets(String value, List> sets) { 41 | return sets.stream().anyMatch(s -> s.contains(value)); 42 | } 43 | 44 | public static boolean isNameOfType(String name, NameType type) { 45 | return isInSets(name, NAMES.get(type)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/test.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | --------------------------------------------------------------------------------