Skip to content

Commit

Permalink
Merge pull request #43 from rgdoliveira/sync_main
Browse files Browse the repository at this point in the history
Sync main branch with Apache main branch
  • Loading branch information
rgdoliveira authored Oct 25, 2024
2 parents eacfb2b + eca7df5 commit 3ec8627
Show file tree
Hide file tree
Showing 36 changed files with 677 additions and 158 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.JsonNode;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -92,7 +91,6 @@ protected ValidatableResponse addCheck(ValidatableResponse res) {
}

@Test
@Disabled
public void testProcessInstanceEvents() throws IOException {
String pId = given()
.contentType(ContentType.JSON)
Expand All @@ -113,13 +111,13 @@ public void testProcessInstanceEvents() throws IOException {
.contentType(ContentType.JSON)
.queryParam("user", "admin")
.queryParam("group", "managers")
.pathParam("processId", pId)
.when()
.get("/approvals/{processId}/tasks")
.get("/usertasks/instance")
.then()
.statusCode(200)
.log().body()
.body("$.size()", is(1))
.body("[0].name", is("firstLineApproval"))
.body("[0].taskName", is("firstLineApproval"))
.body("[0].id", notNullValue())
.extract()
.path("[0].id");
Expand Down Expand Up @@ -152,7 +150,7 @@ public void testProcessInstanceEvents() throws IOException {
.body("data.Approvals[0].metadata.userTasks.size()", is(1))
.body("data.Approvals[0].metadata.userTasks[0].id", is(flTaskId))
.body("data.Approvals[0].metadata.userTasks[0].name", is("firstLineApproval"))
.body("data.Approvals[0].metadata.userTasks[0].state", is("Ready")));
.body("data.Approvals[0].metadata.userTasks[0].state", is("Reserved")));
}

await()
Expand Down Expand Up @@ -187,7 +185,22 @@ public void testProcessInstanceEvents() throws IOException {
.body("data.UserTaskInstances.size()", is(1))
.body("data.UserTaskInstances[0].id", is(flTaskId))
.body("data.UserTaskInstances[0].name", is("firstLineApproval"))
.body("data.UserTaskInstances[0].state", is("Ready")));
.body("data.UserTaskInstances[0].state", is("Reserved")));

String workItemId = given()
.contentType(ContentType.JSON)
.queryParam("user", "admin")
.queryParam("group", "managers")
.pathParam("processId", pId)
.when()
.get("/approvals/{processId}/tasks")
.then()
.statusCode(200)
.body("$.size()", is(1))
.body("[0].name", is("firstLineApproval"))
.body("[0].id", notNullValue())
.extract()
.path("[0].id");

await()
.atMost(TIMEOUT)
Expand All @@ -196,7 +209,7 @@ public void testProcessInstanceEvents() throws IOException {
.queryParam("user", "admin")
.queryParam("group", "managers")
.pathParam("processId", pId)
.pathParam("taskId", flTaskId)
.pathParam("taskId", workItemId)
.body(singletonMap("approved", true))
.post("/approvals/{processId}/firstLineApproval/{taskId}")
.then()
Expand Down Expand Up @@ -324,6 +337,7 @@ public void testProcessGatewayAPI() throws IOException {
.when().post("/graphql")
.then()
.statusCode(200)
.log().body()
.body("data.UserTaskInstances[0].description", nullValue())
.body("data.UserTaskInstances[0].potentialGroups[0]", equalTo("managers"))
.extract().path("data.UserTaskInstances[0].id");
Expand All @@ -335,6 +349,7 @@ public void testProcessGatewayAPI() throws IOException {
.when().post("/graphql")
.then()
.statusCode(200)
.log().body()
.body("errors", nullValue())
.extract().path("data.UserTaskInstances[0].schema");
checkExpectedTaskSchema(taskSchema);
Expand Down Expand Up @@ -474,9 +489,8 @@ public void testProcessGatewayAPIComments(String taskId, String processInstanceI
.when()
.queryParam("user", "manager")
.queryParam("group", "managers")
.pathParam("id", processInstanceId)
.pathParam("taskId", taskId)
.get("/approvals/{id}/firstLineApproval/{taskId}/comments")
.get("/usertasks/instance/{taskId}/comments")
.then()
.statusCode(200)
.body("size()", is(1))
Expand Down Expand Up @@ -585,9 +599,8 @@ public void testProcessGatewayAPIAttachments(String taskId, String processInstan
.when()
.queryParam("user", "manager")
.queryParam("group", "managers")
.pathParam("id", processInstanceId)
.pathParam("taskId", taskId)
.get("/approvals/{id}/firstLineApproval/{taskId}/attachments")
.get("/usertasks/instance/{taskId}/attachments")
.then()
.statusCode(200)
.body("size()", is(1))
Expand Down Expand Up @@ -710,9 +723,8 @@ private void checkExpectedTaskSchema(String taskSchema) throws IOException {
assertEquals("object", schemaJsonNode.at("/type").asText());

// Check Schema phases
assertEquals(4, schemaJsonNode.at("/phases").size());
assertEquals(3, schemaJsonNode.at("/phases").size());
assertTrue(schemaJsonNode.get("phases").toString().contains("abort"));
assertTrue(schemaJsonNode.get("phases").toString().contains("claim"));
assertTrue(schemaJsonNode.get("phases").toString().contains("skip"));
assertTrue(schemaJsonNode.get("phases").toString().contains("complete"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<properties>
<container.image.kogito-service>org.kie.kogito/integration-tests-trusty-service-springboot:${project.version}</container.image.kogito-service>
<sonar.exclusions>**/KogitoApplication.java</sonar.exclusions>
<version.jib-maven-plugin>2.8.0</version.jib-maven-plugin>
<version.jib-maven-plugin>3.3.1</version.jib-maven-plugin>
<jib-maven-plugin.container.image>eclipse-temurin:17-jre</jib-maven-plugin.container.image>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
Expand Down Expand Up @@ -118,8 +118,11 @@ public CompletableFuture sendDeleteClientRequest(WebClient webClient, String req

protected void asyncHttpResponseTreatment(AsyncResult<HttpResponse<Buffer>> res, CompletableFuture future, String logMessage) {
if (res.succeeded() && (res.result().statusCode() == 200 || res.result().statusCode() == 201)) {
future.complete(res.result().bodyAsString() != null ? res.result().bodyAsString() : "Successfully performed: " + logMessage);
String jsonMessage = res.result().bodyAsString();
LOGGER.trace("Result {}", jsonMessage);
future.complete(jsonMessage != null ? jsonMessage : "Successfully performed: " + logMessage);
} else {
LOGGER.trace("Error {}", logMessage);
future.completeExceptionally(new DataIndexServiceException(getErrorMessage(logMessage, res.result())));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,8 @@ public class IndexingService {
public void indexProcessInstanceEvent(ProcessInstanceDataEvent<?> event) {
ProcessInstanceStorage storage = manager.getProcessInstanceStorage();
if (event instanceof MultipleProcessInstanceDataEvent) {
for (ProcessInstanceDataEvent<?> item : ((MultipleProcessInstanceDataEvent) event).getData())
indexProccessInstanceEvent(storage, item);
} else {
indexProccessInstanceEvent(storage, event);
}
}

private void indexProccessInstanceEvent(ProcessInstanceStorage storage, ProcessInstanceDataEvent<?> event) {
if (event instanceof ProcessInstanceErrorDataEvent) {
storage.indexGroup(((MultipleProcessInstanceDataEvent) event));
} else if (event instanceof ProcessInstanceErrorDataEvent) {
storage.indexError((ProcessInstanceErrorDataEvent) event);
} else if (event instanceof ProcessInstanceNodeDataEvent) {
storage.indexNode((ProcessInstanceNodeDataEvent) event);
Expand All @@ -112,16 +105,8 @@ public void indexProcessDefinition(ProcessDefinitionDataEvent definitionDataEven
public <T> void indexUserTaskInstanceEvent(UserTaskInstanceDataEvent<T> event) {
UserTaskInstanceStorage storage = manager.getUserTaskInstanceStorage();
if (event instanceof MultipleUserTaskInstanceDataEvent) {
for (UserTaskInstanceDataEvent<?> item : ((MultipleUserTaskInstanceDataEvent) event).getData()) {
indexUserTaskInstanceEvent(storage, item);
}
} else {
indexUserTaskInstanceEvent(storage, event);
}
}

private void indexUserTaskInstanceEvent(UserTaskInstanceStorage storage, UserTaskInstanceDataEvent<?> event) {
if (event instanceof UserTaskInstanceAssignmentDataEvent) {
storage.indexGroup((MultipleUserTaskInstanceDataEvent) event);
} else if (event instanceof UserTaskInstanceAssignmentDataEvent) {
storage.indexAssignment((UserTaskInstanceAssignmentDataEvent) event);
} else if (event instanceof UserTaskInstanceAttachmentDataEvent) {
storage.indexAttachment((UserTaskInstanceAttachmentDataEvent) event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ type UserTaskInstance {
endpoint: String
comments: [Comment!]
attachments: [Attachment!]
externalReferenceId : String
}

input UserTaskInstanceArgument {
Expand Down
Loading

0 comments on commit 3ec8627

Please sign in to comment.