-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refactor random data generation to use RandomProvider trait
Replaced randomDigit and related methods with the generalized RandomProvider trait for a cleaner and more extensible design. Enhanced readability and maintainability by introducing implicit providers for common data types and improving validation logic. Updated feeder implementations and other code references to use the new randomValue abstraction.
- Loading branch information
1 parent
1e94fde
commit 383d58e
Showing
6 changed files
with
37 additions
and
49 deletions.
There are no files selected for viewing
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
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
1 change: 0 additions & 1 deletion
1
src/main/scala/org/galaxio/gatling/utils/IntensityConverter.scala
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
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
7 changes: 0 additions & 7 deletions
7
src/main/scala/org/galaxio/gatling/utils/RandomDataGeneratorsWrapper.scala
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
package org.galaxio.gatling | ||
|
||
import java.util.concurrent.ThreadLocalRandom | ||
import scala.util.Random | ||
|
||
package object utils { | ||
|
||
def getRandomElement[T](seq: Seq[T]): T = seq(Random.nextInt(seq.length)) | ||
|
||
implicit object IntRandomProvider extends RandomProvider[Int] { | ||
|
||
override def random(): Int = ThreadLocalRandom.current().nextInt() | ||
|
||
override def random(max: Int): Int = ThreadLocalRandom.current().nextInt(max) | ||
|
||
override def random(min: Int, max: Int): Int = ThreadLocalRandom.current().nextInt(min, max) | ||
|
||
} | ||
|
||
implicit object LongRandomProvider extends RandomProvider[Long] { | ||
override def random(): Long = ThreadLocalRandom.current().nextLong() | ||
|
||
override def random(max: Long): Long = ThreadLocalRandom.current().nextLong(max) | ||
|
||
override def random(min: Long, max: Long): Long = ThreadLocalRandom.current().nextLong(min, max) | ||
|
||
} | ||
|
||
implicit object FloatRandomProvider extends RandomProvider[Float] { | ||
override def random(): Float = ThreadLocalRandom.current().nextFloat() | ||
|
||
override def random(max: Float): Float = ThreadLocalRandom.current().nextFloat() * max | ||
|
||
override def random(min: Float, max: Float): Float = | ||
min + ThreadLocalRandom.current().nextFloat() * (max - min) | ||
} | ||
|
||
implicit object DoubleRandomProvider extends RandomProvider[Double] { | ||
override def random(): Double = ThreadLocalRandom.current().nextDouble() | ||
|
||
override def random(max: Double): Double = ThreadLocalRandom.current().nextDouble(max) | ||
|
||
override def random(min: Double, max: Double): Double = | ||
min + ThreadLocalRandom.current().nextDouble() * (max - min) | ||
} | ||
} |