SkillAgentSearch skills...

Fabricator

Fabricator is a minimalist generator of random strings, numbers, etc. to help reduce some monotony particularly while writing automated tests or anywhere else you need anything random. It's written on scala but fully backward compatible with Java.

Install / Use

/learn @azakordonets/Fabricator
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

fabricator

Maven Central Build Status      Coverage Status      Get automatic notifications about new "fabricator" versions Download Codacy Badge

Fabricator is a minimalist generator of random strings, numbers, etc. to help reduce some monotony particularly while writing automated tests or anywhere else you need anything random. It's written on scala but fully backward compatible with Java.

How to install :

For maven projects you need to add next dependency in your pom.xml file :

<dependency>
  <groupId>com.github.azakordonets</groupId>
  <artifactId>fabricator_2.13</artifactId>
  <version>2.1.9</version>
</dependency>

In case you want to use it in your scala project, then just add this lines to your build.sbt file :

Note : since version 2.1.5 scala 2.10 got deprecated. You can get version 2.1.4, but future fixes and updated will by only for scala versions 2.11.* and higher

For Scala 2.10.4 you can use this :

resolvers += "Fabricator" at "http://dl.bintray.com/biercoff/Fabricator"

libraryDependencies += "com.github.azakordonets" % "fabricator_2.10" % "2.1.4"

For Scala 2.11 you can use this :

resolvers += "Fabricator" at "http://dl.bintray.com/biercoff/Fabricator"

libraryDependencies += "com.github.azakordonets" % "fabricator_2.11" % "2.1.5"

For Scala 2.12 you can use this :

resolvers += "Fabricator" at "http://dl.bintray.com/biercoff/Fabricator"

libraryDependencies += "com.github.azakordonets" % "fabricator_2.12" % "2.1.5"

For Scala 2.13 you can use this :

// https://mvnrepository.com/artifact/com.github.azakordonets/fabricator
libraryDependencies += "com.github.azakordonets" %% "fabricator_2.13" % "2.1.9"

Usage

Fabricator consist of 9 specific modules :

  • Alphanumeric - generates random numbers and strings:
  • Calendar - generates random time and date:
  • Contact - generates contact and person details information :
  • File - generates random csv files
  • Finance - generates random credit cards, bsn numbers
  • Internet - generates random url's, domains, e-mails, ip's, mac addresses, color codes, social networks id's
  • User Agent - generate any random user agent for mobile and desktop client
  • Location - generates random coordinates, geohash
  • Mobile - generates random mobile platforms push tokens or id's
  • Words - generates random words, sentences and even blocks of text

To start using it you need to import fabricator.* and then make a call to appropriate module.

Let's look closer what each module can build :

Alphanumeric

This module allows you to generate any random number or string. As for strings, you can generate either fully random string, or you can generate string basing on a pattern.


val alpha = fabricator.Alphanumeric() // initialize alpha numeric module

alpha.numerify("###ABC") // 981ABC

alpha.letterify("???123") // LsQ123

alpha.botify("???###") // AbC329

alpha.randomInteger // random integer in 0 to 1000 range

alpha.randomInteger(100) // random integer in 0 to 100 range

alpha.randomInteger(200, 300) // random integer in 200 to 300 range

alpha.randomIntegerRangeAsScalaList(1,10,1) // will return scala List[1,2,3,4,5,6,7,8,9,10]
 
alpha.randomIntegerRangeAsJavaList(1,10,1) // will return List<Object>[1,2,3,4,5,6,7,8,9,10] . Each element need to be casted to Integer

alpha.randomHash // d750c843c83a3a980082361e72aa41ac48975eab

alpha.randomGuid // ed7592b7-11e4-5f7f-b83f-488733c8bc56

Besides integer numbers it can generate double, float, gausian, string

Calendar

This module allows you to generate random time or time.


val calendar = fabricator.Calendar() // initialize calendar module

calendar.time12h // 03:15

calendar.time24h // 15:15

calendar.month(asNumber = false) // December

calendar.month(asNumber = true) // 12

calendar.date.asString // 10-02-2014

calendar.date.asString(DateFormat.dd_MMM_yyyy_SEMICOLON) // 10:DEC:2014

calendar.date.asDate // random Date object

calendar.date.inYear(2014).inDay(10).inMinute(10).asString // random date in 2014 year, that happened in 10th day of random month in 10th minute of random hour

calendar.relativeDate.years(2).weeks(1).seconds(-20).asDate // get relative date that is 2 years and 1 weeks in the future and 20 seconds behind (since current time)

calendar.relativeDate(DateTime.now().plusDays(1)).tomorrow().asString // 2 days since now as a string with default formatting

calendar.relativeDate(DateTimeZone.UTC).tomorrow().asString(DateFormat.dd_MM_yy) // tomorrows date in UTC time zone with custom formatting

calendar.datesRange
        .startYear(2010)
        .startMonth(1)
        .startDay(1)
        .stepEvery(1, DateRangeType.DAYS)
        .endYear(2011)
        .endMonth(1)
        .endDay(1)
        .asList // list of dates between 2010-1-1 and 2011-1-1 with a step of 1 day between each date 

Contact

This module allows you to generate random person data


val contact = fabricator.Contact()

contact.fullName // Betty Corwin

contact.birthday(25) // 26.12.1989 (current year - 25 with default format dd.MM.yyyy)

contact.bsn // 730550370 (equivalent of a national ID number)

contact.eMail // Rebecca_Kohler506@yahoo.com

contact.phoneNumber // (792)273-4251 x012

contact.postCode //  44274-6580

contact.state // Alaska

contact.height(true) // 188 cm

contact.height(false) // 1.88 m

contact.weight // 108 kg

contact.bloodType // A-

contact.occupation // Craft Artist

contact.religion // sikhism

contact.zodiac // Taurus

File

This module allows you to generate random images and csv files. For images you can specify width and height ( no more then 2560 px) and as a result you will get an image that has text of it's dimensions on it. It's easy as :

val file = fabricator.file() // initialize file module

file.image(200,300, "drawing.png") // will create a 200x300 image in the root of the project

file.fileExtension(FileType.AUDIO) // mp3

file.fileExtension // randomly selects out of all available Filetypes

file.fileName(FileType.audio) // swoon.mp3

file.fileName // random name + random file type

file.mimeType(MimeType.APPLICATION) // application/ecmascript

file.mimeType // random mime type 


For csv there are 2 ways of generating files. First one is by using specific codes that correspond to the methods that are available withing the lib. Here's the full list of supported codes :

  • integer
  • double
  • hash
  • guid
  • time
  • date
  • name
  • first_name
  • last_name
  • birthday
  • email
  • phone
  • address
  • postcode
  • bsn
  • height
  • weight
  • occupation
  • visa
  • master
  • iban
  • bic
  • url
  • ip
  • macaddress
  • uuid
  • color
  • twitter
  • hashtag
  • facebook
  • google_analytics
  • altitude
  • depth
  • latitude
  • longitude
  • coordinates
  • geohash
  • apple_token
  • android
  • windows7Token
  • windows8Token
  • word
  • sentence

To create csv file using this codes you need to do next :


file.csvBuilder.build() // will create default csv file with 10 rows in default location

val file = fabricator.csvBuilder // get csv file builder

val codes = Array(CsvValueCode.FIRST_NAME,
                                          CsvValueCode.LAST_NAME,
                                          CsvValueCode.BIRTHDAY,
                                          CsvValueCode.EMAIL,
                                          CsvValueCode.PHONE,
                                          CsvValueCode.ADDRESS,
                                          CsvValueCode.BSN,
                                          CsvValueCode.WEIGHT,
                                          CsvValueCode.HEIGHT)

file.csvBuilder
           .withCodes(codes)
           .withNumberOfRows(10)
           .saveTo(csvFilePath)
           .build() // this will create a csv file with 10 rows, each of it has set of data generated by fabricator methods and
                                          // stored in csvFilePath

In case you want some columsn in your csv file to contain same data, you can specify custom Array with both codes and default values and get generated file :


val file = fabricator.file() // initialize file module

val values = Array(CsvValueCode.LAST_NAME, CsvValueCode.BIRTHDAY,CsvValueCode.EMAIL, alpha.randomDouble())

file.csvBuilder
           .withCodes(codes)
           .withNumberOfRows(10)
           .saveTo(csvFilePath)
           .build() // csv file with 10 lines of data from Array will be generated in csvFilePath

Finance

This module allows you to generate random finance data


val finance = fabricator.Finance() // initialize finance module

finance.iban // GB91ROYC80901351879409

finance.bic // CLSBUS33XXX

finance.visacreditCard // 4556623851035641

finance.visacreditCard(15) // 455662622900006

finance.pincode // 1234

Internet

This module allows you to generate random internet data


val internet = fabricator.Internet() // initialize internet module

internet.appleToken // randon apple push token - ze7w6fn0omtkxjuxgw2dx5
View on GitHub
GitHub Stars81
CategoryContent
Updated5mo ago
Forks18

Languages

Scala

Security Score

92/100

Audited on Oct 10, 2025

No findings