Skip to content

Commit

Permalink
add step for test event's variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-vasylchenko committed Oct 24, 2023
1 parent 824c4f1 commit 8e86154
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cucumber-tests/src/test/java/cucumber/api/Methods.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,33 @@ public Map<String, String> getFormVariables(String taskId) {

return submitAndActivityIds;
}

private String getInstanceVariables(String processInstanceId) {
String payload =
"{\"processInstanceIdIn\":[\"" +
processInstanceId +
"\"],\"sorting\":[{\"sortBy\":\"variableName\",\"sortOrder\":\"asc\"}]}";
Map<String, String> params = new HashMap<>();
params.put("deserializeValues", "false");
params.put("maxResults", "50");
params.put("firstResult", "0");

RestAssured.baseURI = this.camundaUrl;
RequestSpecification httpRequest = RestAssured.given();

Response res = httpRequest
.headers(headers)
.cookie(cookiesMap.get("XSRF"))
.cookie(cookiesMap.get("JSESSIONID"))
.body(payload)
.urlEncodingEnabled(false)
.post("camunda/api/engine/engine/default/variable-instance");
return res.getBody().asString();
}

public String getVariableValueByKey(String processInstanceId, String variableKey) {
String valiables = getInstanceVariables(processInstanceId);
JsonPath jpath = new JsonPath(valiables);
return jpath.getString("find{it.name == '" + variableKey + "'}.value");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ public void ensureThatProcessCompleted(Actor actor) {
Assertions.assertEquals(404, respCodeResult, "process instance was not completed");
}

@Then("{actor} can get events variables")
public void checkEventVariables(Actor actor) {
String startVar = methods.getVariableValueByKey(processInstanceId, "startVariable");
Assertions.assertEquals("true", startVar, "variable on start event was not created");
String endVar = methods.getVariableValueByKey(processInstanceId, "endVariable");
Assertions.assertEquals("true", endVar, "variable on end event was not created");
}

@When("{actor} selects start process {string}")
public void startProcess(Actor actor, String processName) {
actor.wasAbleTo(NavigateTo.theTaskListPage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Invoice for Approval
Scenario: Start and complete process with Attachments API test
Given kermit is logged in to Camunda via POST
When he starts an Invoice Process via API
Then he can get events variables
When he completes Invoice Process via API
Then he should see that process not in the list via API
@reset
Expand Down

0 comments on commit 8e86154

Please sign in to comment.