Skip to content

Instantly share code, notes, and snippets.

@nremond
Created Jun 22, 2012
Embed
What would you like to do?
Account feeder
class AccountFeeder() extends com.excilys.ebi.gatling.core.feeder.Feeder {
import org.joda.time.DateTime
import scala.util.Random
private val RNG = new Random()
// random number in between [a...b]
def randInt(a:Int, b:Int) = RNG.nextInt(b-a) + a
def daysOfMonth(year:Int, month:Int) = new DateTime(year, month, 1, 0, 0, 0, 000).dayOfMonth().getMaximumValue()
def next: Map[String, String] = {
val email = scala.math.abs(java.util.UUID.randomUUID().getMostSignificantBits()) + "_gatling@ne-pas-envoyer.com"
val year = randInt(1945, 1994)
val month = randInt(1, 12)
val day = randInt(1, daysOfMonth(year, month))
Map("contactEmail" -> email,
"birthdayYear" -> year.toString,
"birthdayMonth" -> month.toString,
"birthdayDay" -> day.toString)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment