Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-48 Try reproduce Start or End Event Listener on the Start Event seems to break the Accelerator #74

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions camunda-formio-bpmn/formio-example.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<camunda:property name="formio.file" value="formio-example.formio" />
<camunda:property name="formio.form" value="start-form-poc" />
</camunda:properties>
<camunda:executionListener event="start">
<camunda:script scriptFormat="groovy">execution.setVariable("startVariable", true);</camunda:script>
</camunda:executionListener>
<camunda:executionListener event="end">
<camunda:script scriptFormat="groovy">execution.setVariable("endVariable", true);</camunda:script>
</camunda:executionListener>
</bpmn:extensionElements>
<bpmn:outgoing>Flow_11l28i0</bpmn:outgoing>
<bpmn:dataOutputAssociation id="DataOutputAssociation_1qig1ru">
Expand Down
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 @@ -166,4 +166,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 @@ -108,6 +108,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