Skip to content

Commit b1c567d

Browse files
author
kopysov
committed
Fix logic randomChoice() for WeightedSwitchController
- Changed the method name to randomChoice() - The method now takes a boolean value - Add javaDoc for method randomChoice()
1 parent d54f0ff commit b1c567d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

jmeter-java-dsl/src/main/java/us/abstracta/jmeter/javadsl/core/controllers/DslWeightedSwitchController.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,18 @@ public DslWeightedSwitchController child(long weight, DslSampler child) {
8181
return addWeightedChild(weight, child);
8282
}
8383

84-
public DslWeightedSwitchController isRandomChoice(){
85-
this.isRandomChoice = true;
84+
/**
85+
* Sets the random choice mode for child elements.
86+
* <p>
87+
* When random choice mode is enabled (randomChoice = true), the controller will select child elements
88+
* randomly, according to their weights. When disabled (randomChoice = false), selection will occur
89+
* sequentially based on weights.
90+
*
91+
* @param randomChoice true - to enable random selection, false - for sequential selection
92+
* @return current controller instance for method chaining
93+
*/
94+
public DslWeightedSwitchController randomChoice(boolean randomChoice){
95+
this.isRandomChoice = randomChoice;
8696
return this;
8797
}
8898

jmeter-java-dsl/src/test/java/us/abstracta/jmeter/javadsl/core/controllers/DslWeightedSwitchControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void shouldHandleRandomChoiceWhenInPlan() throws Exception {
5858
.child(weight1, httpSampler(SAMPLE_1_LABEL, wiremockUri))
5959
.children(httpSampler(SAMPLE_2_LABEL, wiremockUri))
6060
.child(weight2, httpSampler(label3, wiremockUri))
61-
.isRandomChoice()
61+
.randomChoice(true)
6262
)
6363
).run();
6464

0 commit comments

Comments
 (0)