1 package com.griddynamics.jagger.invoker.scenario;
3 import com.griddynamics.jagger.invoker.v2.JHttpEndpoint;
4 import com.griddynamics.jagger.invoker.v2.JHttpQuery;
5 import com.griddynamics.jagger.invoker.v2.JHttpResponse;
7 import java.util.concurrent.TimeUnit;
8 import java.util.function.BiConsumer;
9 import java.util.function.Function;
17 private int stepNumber;
18 private final String stepId;
20 private JHttpQuery query;
21 private JHttpResponse response;
22 private final long waitAfterExecutionInSeconds;
23 private final String stepDisplayName;
24 private final BiConsumer<JHttpUserScenarioStep, JHttpUserScenarioStep> previousAndCurrentStepConsumer;
25 private final BiConsumer<JHttpUserScenarioStep, JHttpScenarioGlobalContext> previousStepAndContextConsumer;
26 private final Function<JHttpResponse, Boolean> responseFunction;
33 if (previousStepAndContextConsumer != null)
34 previousStepAndContextConsumer.accept(previousStep, scenarioContext);
42 if (previousAndCurrentStepConsumer != null) {
43 previousAndCurrentStepConsumer.accept(previousStep,
this);
52 this.response = response;
53 if (responseFunction != null)
54 return responseFunction.apply(JHttpResponse.copyOf(response));
59 if (waitAfterExecutionInSeconds > 0) {
61 TimeUnit.SECONDS.sleep(waitAfterExecutionInSeconds);
62 }
catch (InterruptedException e) {
63 throw new RuntimeException(
"Error occurred while waiting after execution", e);
69 this.stepId = builder.stepId;
70 this.endpoint = builder.endpoint;
71 this.query = builder.query;
72 this.waitAfterExecutionInSeconds = builder.waitAfterExecutionInSeconds;
73 this.stepDisplayName = (builder.stepDisplayName == null) ? builder.stepId : builder.stepDisplayName;
74 this.previousAndCurrentStepConsumer = builder.previousAndCurrentStepConsumer;
75 this.responseFunction = builder.responseFunction;
76 this.previousStepAndContextConsumer = builder.previousStepAndContextConsumer;
80 return new Builder(
id, endpoint);
91 private final String stepId;
93 private JHttpQuery query;
94 private long waitAfterExecutionInSeconds;
95 private String stepDisplayName;
96 private BiConsumer<JHttpUserScenarioStep, JHttpUserScenarioStep> previousAndCurrentStepConsumer;
97 private BiConsumer<JHttpUserScenarioStep, JHttpScenarioGlobalContext> previousStepAndContextConsumer;
98 private Function<JHttpResponse, Boolean> responseFunction;
101 this.stepId = stepId;
102 this.endpoint = endpoint;
111 this.waitAfterExecutionInSeconds = waitAfterExecutionInSeconds;
116 this.stepDisplayName = displayName;
121 this.previousStepAndContextConsumer = previousStepAndContextConsumer;
126 this.previousAndCurrentStepConsumer = previousAndCurrentStepConsumer;
131 this.responseFunction = responseFunction;
141 return waitAfterExecutionInSeconds;
152 this.endpoint = endpoint;
167 return JHttpResponse.copyOf(response);
171 return stepDisplayName;
183 this.stepNumber = stepNumber;