From 6fdb6f7e9c30e7b080438919d457f3a694cd4df1 Mon Sep 17 00:00:00 2001 From: SoftCannery Ltd <github@softcannery.com> Date: Tue, 24 Oct 2023 09:47:18 -0700 Subject: [PATCH 1/2] GH-48 Try reproduce Start or End Event Listener on the Start Event seems to break the Accelerator --- camunda-formio-bpmn/formio-example.bpmn | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/camunda-formio-bpmn/formio-example.bpmn b/camunda-formio-bpmn/formio-example.bpmn index f6b63fd5..3d518cd6 100644 --- a/camunda-formio-bpmn/formio-example.bpmn +++ b/camunda-formio-bpmn/formio-example.bpmn @@ -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"> From d4e56e95af5d0e9f6e816225d39baf73a0b6a900 Mon Sep 17 00:00:00 2001 From: Mikhail Vasylchenko <mikhail.vasylchenko@introproventures.com> Date: Tue, 24 Oct 2023 13:23:43 -0700 Subject: [PATCH 2/2] add step for test event's variables --- .../src/test/java/cucumber/api/Methods.java | 29 +++++++++++++++++++ .../stepdefinitions/StepDefinitions.java | 8 +++++ .../submit_invoice_for_approval.feature | 1 + 3 files changed, 38 insertions(+) diff --git a/cucumber-tests/src/test/java/cucumber/api/Methods.java b/cucumber-tests/src/test/java/cucumber/api/Methods.java index d5dd458a..d9a02ae6 100644 --- a/cucumber-tests/src/test/java/cucumber/api/Methods.java +++ b/cucumber-tests/src/test/java/cucumber/api/Methods.java @@ -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"); + } } diff --git a/cucumber-tests/src/test/java/cucumber/stepdefinitions/StepDefinitions.java b/cucumber-tests/src/test/java/cucumber/stepdefinitions/StepDefinitions.java index 6a068ea9..27ff90c6 100644 --- a/cucumber-tests/src/test/java/cucumber/stepdefinitions/StepDefinitions.java +++ b/cucumber-tests/src/test/java/cucumber/stepdefinitions/StepDefinitions.java @@ -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()); diff --git a/cucumber-tests/src/test/resources/features/cucumber/submit_invoice_for_approval.feature b/cucumber-tests/src/test/resources/features/cucumber/submit_invoice_for_approval.feature index 85e58746..75061172 100644 --- a/cucumber-tests/src/test/resources/features/cucumber/submit_invoice_for_approval.feature +++ b/cucumber-tests/src/test/resources/features/cucumber/submit_invoice_for_approval.feature @@ -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