Skip to content

Commit

Permalink
Merge pull request #2 from galax-io/feature/simulation-with-transactions
Browse files Browse the repository at this point in the history
feat: Java SimulationWithTransactions
  • Loading branch information
jigarkhwar authored May 22, 2024
2 parents 8577f73 + 014a82f commit 40c5d27
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/scala/org/galaxio/gatling/transactions/Predef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@ import io.gatling.core.session.Expression
import io.gatling.core.structure.{PopulationBuilder, ScenarioBuilder}
import org.galaxio.gatling.transactions.actions.builders._

import scala.jdk.CollectionConverters._

object Predef {
abstract class SimulationWithTransactions extends Simulation {

override def setUp(populationBuilders: PopulationBuilder*): SetUp = setUp(populationBuilders.toList)

override def setUp(populationBuilders: List[PopulationBuilder]): SetUp = {
super.setUp(populationBuilders)
new SetUpWithTransactions
}

def setUp(populationBuilders: io.gatling.javaapi.core.PopulationBuilder): SetUp =
setUp(populationBuilders.asScala())

def setUp(populationBuilders: java.util.List[io.gatling.javaapi.core.PopulationBuilder]): SetUp = {
super.setUp(populationBuilders.asScala.toList.map(_.asScala()))
new SetUpWithTransactions
}

private final class SetUpWithTransactions extends SetUp {
override def protocols(ps: Iterable[Protocol]): SetUp = super.protocols(ps ++ Seq(new TransactionsProtocol))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.galaxio.gatling.javaapi;

import static org.galaxio.gatling.javaapi.Feeders.*;

import static io.gatling.javaapi.core.CoreDsl.*;

import io.gatling.javaapi.core.ScenarioBuilder;
import org.galaxio.gatling.transactions.Predef;


public class SimulationWithTransactionsTest extends Predef.SimulationWithTransactions {

private final ScenarioBuilder scenario =
scenario("scenario")
.exec(session -> {
System.out.print(session);
return session;
});

{
setUp(scenario.injectOpen(atOnceUsers(1)));
}


}

0 comments on commit 40c5d27

Please sign in to comment.