This is an automated email from the ASF dual-hosted git repository.
yamer pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git
The following commit(s) were added to refs/heads/main by this push:
new cd6919f6c7 [incubator-kie-issues#2283] Fix `TaskIT` test to ensure it
tests the User Tasks created by the associated process instance (#4253)
cd6919f6c7 is described below
commit cd6919f6c7d84574a6abdb722ae6205a7668293d
Author: Pere Fernández <[email protected]>
AuthorDate: Wed Apr 15 15:31:55 2026 +0200
[incubator-kie-issues#2283] Fix `TaskIT` test to ensure it tests the User
Tasks created by the associated process instance (#4253)
* [incubator-kie-issues#2283] Fix `TaskIT` test to ensure it tests the User
Tasks created by the associated process instance
* - cleaning up BasicRest tests
---
.../integrationtests/quarkus/BasicRestIT.java | 7 ++
.../kogito/integrationtests/quarkus/ProcessIT.java | 7 ++
.../kogito/integrationtests/quarkus/TaskIT.java | 19 +++--
.../integrationtests/springboot/BasicRestTest.java | 7 ++
.../integrationtests/springboot/TaskTest.java | 84 ++++++++++++----------
5 files changed, 79 insertions(+), 45 deletions(-)
diff --git
a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java
b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java
index 60377d50b2..48fc895af4 100644
---
a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java
+++
b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java
@@ -128,6 +128,13 @@ class BasicRestIT {
.statusCode(200);
assertExpectedUnitOfWorkEvents(1);
+
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/approvals/{processId}", processId)
+ .then()
+ .statusCode(200);
}
@Test
diff --git
a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ProcessIT.java
b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ProcessIT.java
index f90b74e5a7..bc1f768781 100644
---
a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ProcessIT.java
+++
b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ProcessIT.java
@@ -74,6 +74,13 @@ public class ProcessIT {
.body("traveller.lastName", equalTo(traveller.getLastName()))
.body("traveller.email", equalTo(traveller.getEmail()))
.body("traveller.nationality",
equalTo(traveller.getNationality()));
+
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/approvals/{processId}", processId)
+ .then()
+ .statusCode(200);
}
private void testProcessSchema(String processId, String schemaFileName)
throws IOException {
diff --git
a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/TaskIT.java
b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/TaskIT.java
index 6b0243f50a..a84c584591 100644
---
a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/TaskIT.java
+++
b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/TaskIT.java
@@ -51,6 +51,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@QuarkusIntegrationTest
class TaskIT {
+ public static final String TASK_ID_BY_PROCESS_INSTANCE_ID_JSONPATH = "find
{ it.processInfo.processInstanceId == \"%s\" }.id";
+
static {
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
}
@@ -116,7 +118,7 @@ class TaskIT {
public void testInputOutputsViaJsonTypeProperty() throws Exception {
Traveller traveller = new Traveller("pepe", "rubiales",
"[email protected]", "Spanish", null);
- given()
+ String processId = given()
.contentType(ContentType.JSON)
.when()
.body(Collections.singletonMap("traveller", traveller))
@@ -135,7 +137,8 @@ class TaskIT {
.then()
.statusCode(200)
.extract()
- .path("[0].id");
+ .jsonPath()
+
.getString(TASK_ID_BY_PROCESS_INSTANCE_ID_JSONPATH.formatted(processId));
traveller = new Traveller("pepe2", "rubiales2",
"[email protected]", "Spanish2", null);
ObjectMapper mapper = new ObjectMapper();
@@ -229,7 +232,7 @@ class TaskIT {
void testCommentAndAttachment() {
Traveller traveller = new Traveller("pepe", "rubiales",
"[email protected]", "Spanish", null);
- given()
+ String processId = given()
.contentType(ContentType.JSON)
.when()
.body(Collections.singletonMap("traveller", traveller))
@@ -248,7 +251,8 @@ class TaskIT {
.then()
.statusCode(200)
.extract()
- .path("[0].id");
+ .jsonPath()
+
.getString(TASK_ID_BY_PROCESS_INSTANCE_ID_JSONPATH.formatted(processId));
final String commentId = given().contentType(ContentType.JSON)
.when()
@@ -374,7 +378,7 @@ class TaskIT {
void testUpdateTaskInfo() {
Traveller traveller = new Traveller("pepe", "rubiales",
"[email protected]", "Spanish");
- given()
+ String processId = given()
.contentType(ContentType.JSON)
.when()
.body(Collections.singletonMap("traveller", traveller))
@@ -393,7 +397,8 @@ class TaskIT {
.then()
.statusCode(200)
.extract()
- .path("[0].id");
+ .jsonPath()
+
.getString(TASK_ID_BY_PROCESS_INSTANCE_ID_JSONPATH.formatted(processId));
traveller.setEmail("[email protected]");
@@ -401,7 +406,7 @@ class TaskIT {
Collections.singleton("managers"),
Collections.singleton("Javierito"), Collections.emptySet(),
Collections.emptySet(), Collections.emptyMap());
- //at first we try with user that doesn't have rights
+ //at first, we try with user that doesn't have rights
given().contentType(ContentType.JSON)
.when()
.queryParam("user", "admin")
diff --git
a/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java
b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java
index c8001ee2bb..db13274bf8 100644
---
a/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java
+++
b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java
@@ -112,6 +112,13 @@ class BasicRestTest extends BaseRestTest {
.statusCode(200);
assertExpectedUnitOfWorkEvents(1);
+
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/approvals/{processId}", processId)
+ .then()
+ .statusCode(200);
}
@Test
diff --git
a/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java
b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java
index e4dac5b69f..ef87163543 100644
---
a/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java
+++
b/springboot/integration-tests/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/TaskTest.java
@@ -26,6 +26,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
@@ -58,32 +59,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = KogitoSpringbootApplication.class)
public class TaskTest extends BaseRestTest {
- @AfterEach
- public void cleanUp() {
- String processId = "";
- do {
- processId = given()
- .when()
- .contentType(ContentType.JSON)
- .queryParam("user", "admin")
- .queryParam("group", "managers")
- .get("/approvals")
- .then()
- .statusCode(200)
- .extract()
- .path("[0].id");
- if (processId != null && !processId.isBlank()) {
- given()
- .when()
- .contentType(ContentType.JSON)
- .queryParam("user", "admin")
- .queryParam("group", "managers")
- .pathParam("processId", processId)
- .delete("/approvals/{processId}")
- .then();
- }
- } while (processId != null && !processId.isBlank());
- }
+ public static final String TASK_ID_BY_PROCESS_INSTANCE_ID_JSONPATH = "find
{ it.processInfo.processInstanceId == \"%s\" }.id";
@Test
void testJsonSchema() {
@@ -148,7 +124,7 @@ public class TaskTest extends BaseRestTest {
public void testInputOutputsViaJsonTypeProperty() throws Exception {
Traveller traveller = new Traveller("pepe", "rubiales",
"[email protected]", "Spanish", null);
- given()
+ String processId = given()
.contentType(ContentType.JSON)
.when()
.body(Collections.singletonMap("traveller", traveller))
@@ -167,7 +143,8 @@ public class TaskTest extends BaseRestTest {
.then()
.statusCode(200)
.extract()
- .path("[0].id");
+ .jsonPath()
+
.getString(TASK_ID_BY_PROCESS_INSTANCE_ID_JSONPATH.formatted(processId));
traveller = new Traveller("pepe2", "rubiales2",
"[email protected]", "Spanish2", null);
ObjectMapper mapper = new ObjectMapper();
@@ -208,7 +185,7 @@ public class TaskTest extends BaseRestTest {
void testCommentAndAttachment() {
Traveller traveller = new Traveller("pepe", "rubiales",
"[email protected]", "Spanish", null);
- given()
+ String processId = given()
.contentType(ContentType.JSON)
.when()
.body(Collections.singletonMap("traveller", traveller))
@@ -227,7 +204,8 @@ public class TaskTest extends BaseRestTest {
.then()
.statusCode(200)
.extract()
- .path("[0].id");
+ .jsonPath()
+
.getString(TASK_ID_BY_PROCESS_INSTANCE_ID_JSONPATH.formatted(processId));
final String commentId = given().contentType(ContentType.JSON)
.when()
@@ -403,9 +381,9 @@ public class TaskTest extends BaseRestTest {
@Test
void testUpdateTaskInfo() {
- Traveller traveller = new Traveller("pepe", "rubiales",
"[email protected]", "Spanish", new Address("Alfredo Di Stefano",
"Madrid", "28033", "Spain"));
+ Traveller traveller = new Traveller("pepe", "rubiales",
"[email protected]", "Spanish");
- given()
+ String processId = given()
.contentType(ContentType.JSON)
.when()
.body(Collections.singletonMap("traveller", traveller))
@@ -417,14 +395,17 @@ public class TaskTest extends BaseRestTest {
String taskId = given()
.contentType(ContentType.JSON)
- .queryParam("user", "manager")
+ .queryParam("user", "admin")
.queryParam("group", "managers")
.when()
.get("/usertasks/instance")
.then()
.statusCode(200)
.extract()
- .path("[0].id");
+ .jsonPath()
+
.getString(TASK_ID_BY_PROCESS_INSTANCE_ID_JSONPATH.formatted(processId));
+
+ traveller.setEmail("[email protected]");
TaskInfo upTaskInfo = new TaskInfo("firstAproval", "high",
Collections.singleton("admin"),
Collections.singleton("managers"),
Collections.singleton("Javierito"), Collections.emptySet(),
@@ -433,18 +414,17 @@ public class TaskTest extends BaseRestTest {
//at first, we try with user that doesn't have rights
given().contentType(ContentType.JSON)
.when()
- .queryParam("user", "jsnow")
+ .queryParam("user", "admin")
.pathParam("taskId", taskId)
.body(upTaskInfo)
.put("/management/usertasks/{taskId}")
.then()
- .statusCode(403); //should fail, because there is not an
"jsnow" user assigned to User Task
+ .statusCode(403); //should fail, because there is not an
"admin" user assigned to User Task
- //"managers" should have rights
+ //"manager" should have rights
given().contentType(ContentType.JSON)
.when()
.queryParam("user", "manager")
- .queryParam("group", "managers")
.pathParam("taskId", taskId)
.body(upTaskInfo)
.put("/management/usertasks/{taskId}")
@@ -476,4 +456,32 @@ public class TaskTest extends BaseRestTest {
assertThat(downTaskInfo.getInputParams().get("traveller")).isNull();
}
+ @AfterEach
+ public void cleanUp() {
+ List<String> staleProcessInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/approvals")
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ staleProcessInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/approvals/{processInstanceId}",
processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/approvals")
+ .then()
+ .statusCode(200)
+ .body("$.size()", equalTo(0));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]