i am new in gettling
i have this code
import io.gatling.javaapi.core.FeederBuilder;
import io.gatling.javaapi.core.ScenarioBuilder;
import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.*;
public class FileExport extends BaseIntegrationSimulation {
private final FeederBuilder.FileBased<Object> credentialsFeeder = jsonFile("path/to/credentials.json").circular();
private static final String baseUrl = "https://example.com";
private static final String postEndpoint = "/api/v1/upload";
private static final String getEndpoint = "/api/v1/download";
private static final String postRequestBody = "{\"param1\":\"value1\",\"param2\":\"value2\"}";
private final ScenarioBuilder scenarioBuilder = scenario("Test upload file ")
.feed(credentialsFeeder)
.exec(http("Call API")
.post(postEndpoint)
.header("accept", "application/json")
.header("content-type", "application/json")
.header("authorization", "Bearer ${jwtToken}")
.body(StringBody(postRequestBody))
.check(status().is(200))
.check(jsonPath("$.fileId").saveAs("fileId")))
.asLongAs(session -> session("fileId").asOption(String.class).isEmpty(),
exec(http("Get Data Request")
.get(baseUrl + getEndpoint)
.header("authorization", "Bearer ${jwtToken}")
.queryParam("timestamp", System.currentTimeMillis())
.check(status().is(200))
.check(jsonPath("$.fileId").saveAs("fileId"))
)
);
{
setUp(
scenarioBuilder.injectOpen(atOnceUsers(1))
).protocols(http.baseUrl(baseUrl));
}
}
i have two calls 1 for pot and second for get
i am trying to create test that call 1 time to the post call and them keep calling the get cal till in the response the filepath will not be empty
i receiving errors in .aslonsAs
call: Cannot resolve method 'asLongAs(<lambda expression>, ChainBuilder)'
.
and i dont understand what i miss
can someone assist ?