Created
June 22, 2012 12:10
-
-
Save nremond/2972382 to your computer and use it in GitHub Desktop.
Account feeder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) + "[email protected]" | |
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