in src/main/java/platform/qa/steps/RestApiStepDefinitions.java [204:238]
public void executePostApiWithParameters(String userName,
@NonNull String path,
@NonNull Map<String, String> queryParams) {
var context = convertToRequestsContext(testContext.getScenarioContext().getContext(API_RESULTS));
Map<String, Object> paramsWithIds = getBodyWithIds(queryParams, context);
if (hasCurlyBracketsInQueryParameters(paramsWithIds)) {
log.info("parameters and ids don't match, POST request {} couldn't be send", path);
return;
}
String signature = new SignatureSteps(registryConfig.getDataFactory(userName),
registryConfig.getDigitalSignatureOps(userName),
registryConfig.getRedis()).signRequest(paramsWithIds);
String payload = new ObjectMapper().writeValueAsString(paramsWithIds);
var response = new RestApiClient(registryConfig.getDataFactory(userName), signature)
.post(payload, path)
.then()
.statusCode(in(List.of(201, 409)))
.extract()
.response();
if (response.statusCode() == 409) {return;}
var result = response
.jsonPath()
.getMap("");
var updatedResult = getResultKeyConvertedToCamelCase(path, new HashMap<>(result));
var request = new Request(path, queryParams, singletonList(updatedResult), new Timestamp(currentTimeMillis()));
context.add(request);
testContext.getScenarioContext().setContext(API_RESULTS, context);
}