From b6f329888465336c6a5b1e0a96de80dad31f3634 Mon Sep 17 00:00:00 2001 From: Tommaso D'Alessandro Date: Wed, 4 Dec 2024 15:23:57 +0100 Subject: [PATCH] AAE-29004 Add processDefinitionName field to process instance search endpoint (#1628) * AAE-29004 add missing field * empty-commit --- .../payload/ProcessInstanceSearchRequest.java | 1 + .../ProcessInstanceSpecification.java | 9 + ...ocessInstanceEntitySearchControllerIT.java | 39 +- .../query/util/ProcessInstanceBuilder.java | 5 + .../ProcessInstanceSearchRequestBuilder.java | 7 + .../src/test/resources/swagger-expected.json | 461 +++++++++--------- 6 files changed, 289 insertions(+), 233 deletions(-) diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessInstanceSearchRequest.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessInstanceSearchRequest.java index fc9abc007d..3457a7c55e 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessInstanceSearchRequest.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessInstanceSearchRequest.java @@ -24,6 +24,7 @@ //prettier-ignore public record ProcessInstanceSearchRequest( Set name, + Set processDefinitionName, Set initiator, Set appVersion, Set status, diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/ProcessInstanceSpecification.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/ProcessInstanceSpecification.java index 40d9d70826..5d7dd6a223 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/ProcessInstanceSpecification.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/ProcessInstanceSpecification.java @@ -62,6 +62,7 @@ public Predicate toPredicate( query.distinct(distinct); applyUserRestrictionFilter(root, criteriaBuilder); applyNameFilter(root, criteriaBuilder); + applyProcessDefinitionNameFilter(root); applyInitiatorFilter(root); applyAppVersionFilter(root); applyStatusFilter(root); @@ -91,6 +92,14 @@ private void applyNameFilter(Root root, CriteriaBuilder c } } + private void applyProcessDefinitionNameFilter(Root root) { + if (!CollectionUtils.isEmpty(searchRequest.processDefinitionName())) { + predicates.add( + root.get(ProcessInstanceEntity_.processDefinitionName).in(searchRequest.processDefinitionName()) + ); + } + } + private void applyInitiatorFilter(Root root) { if (!CollectionUtils.isEmpty(searchRequest.initiator())) { predicates.add(root.get(ProcessInstanceEntity_.initiator).in(searchRequest.initiator())); diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractProcessInstanceEntitySearchControllerIT.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractProcessInstanceEntitySearchControllerIT.java index 330b0ccbc2..47644571f4 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractProcessInstanceEntitySearchControllerIT.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractProcessInstanceEntitySearchControllerIT.java @@ -19,7 +19,6 @@ import static io.restassured.module.mockmvc.RestAssuredMockMvc.postProcessors; import static io.restassured.module.mockmvc.RestAssuredMockMvc.webAppContextSetup; import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsInRelativeOrder; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; @@ -32,10 +31,8 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import java.util.stream.IntStream; import org.activiti.QueryRestTestApplication; import org.activiti.api.process.model.ProcessInstance; -import org.activiti.api.task.model.Task; import org.activiti.cloud.alfresco.config.AlfrescoWebAutoConfiguration; import org.activiti.cloud.services.query.model.ProcessInstanceEntity; import org.activiti.cloud.services.query.model.ProcessVariableKey; @@ -44,11 +41,8 @@ import org.activiti.cloud.services.query.rest.filter.VariableType; import org.activiti.cloud.services.query.rest.payload.CloudRuntimeEntitySort; import org.activiti.cloud.services.query.rest.payload.ProcessInstanceSearchRequest; -import org.activiti.cloud.services.query.rest.payload.TaskSearchRequest; import org.activiti.cloud.services.query.util.ProcessInstanceSearchRequestBuilder; import org.activiti.cloud.services.query.util.QueryTestUtils; -import org.activiti.cloud.services.query.util.TaskBuilder; -import org.activiti.cloud.services.query.util.TaskSearchRequestBuilder; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -118,6 +112,39 @@ void should_returnProcessInstances_filteredByNameLike() { .body(PROCESS_INSTANCE_IDS_JSON_PATH, hasItem(processInstance2.getId())); } + @Test + void should_returnProcessInstances_filteredByProcessDefinitionName() { + ProcessInstanceEntity processInstance1 = queryTestUtils + .buildProcessInstance() + .withInitiator(USER) + .withProcessDefinitionName("Process def name one") + .buildAndSave(); + ProcessInstanceEntity processInstance2 = queryTestUtils + .buildProcessInstance() + .withInitiator(USER) + .withProcessDefinitionName("Process def name two") + .buildAndSave(); + queryTestUtils + .buildProcessInstance() + .withInitiator(USER) + .withProcessDefinitionName("Process def name three") + .buildAndSave(); + + ProcessInstanceSearchRequestBuilder requestBuilder = new ProcessInstanceSearchRequestBuilder() + .withProcessDefinitionNames("Process def name one", "Process def name two"); + + given() + .contentType(MediaType.APPLICATION_JSON) + .body(requestBuilder.buildJson()) + .when() + .post(getSearchEndpoint()) + .then() + .statusCode(200) + .body(PROCESS_INSTANCES_JSON_PATH, hasSize(2)) + .body(PROCESS_INSTANCE_IDS_JSON_PATH, hasItem(processInstance1.getId())) + .body(PROCESS_INSTANCE_IDS_JSON_PATH, hasItem(processInstance2.getId())); + } + @Test void should_returnProcessInstances_filteredByAppVersion() { ProcessInstanceEntity processInstance1 = queryTestUtils diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceBuilder.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceBuilder.java index 3a3f941fd0..14e2c92f93 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceBuilder.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceBuilder.java @@ -61,6 +61,11 @@ public ProcessInstanceBuilder withName(String name) { return this; } + public ProcessInstanceBuilder withProcessDefinitionName(String processDefinitionName) { + process.setProcessDefinitionName(processDefinitionName); + return this; + } + public ProcessInstanceBuilder withAppName(String appName) { process.setAppName(appName); return this; diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceSearchRequestBuilder.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceSearchRequestBuilder.java index 78c6f54900..01bec9aead 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceSearchRequestBuilder.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceSearchRequestBuilder.java @@ -31,6 +31,7 @@ public class ProcessInstanceSearchRequestBuilder { private Set names; + private Set processDefinitionNames; private Set initiators; private Set appVersions; private Set statuses; @@ -51,6 +52,11 @@ public ProcessInstanceSearchRequestBuilder withNames(String... names) { return this; } + public ProcessInstanceSearchRequestBuilder withProcessDefinitionNames(String... processDefinitionNames) { + this.processDefinitionNames = Set.of(processDefinitionNames); + return this; + } + public ProcessInstanceSearchRequestBuilder withInitiators(String... initiators) { this.initiators = Set.of(initiators); return this; @@ -137,6 +143,7 @@ public ProcessInstanceSearchRequest build() { } return new ProcessInstanceSearchRequest( names, + processDefinitionNames, initiators, appVersions, statuses, diff --git a/activiti-cloud-query-service/activiti-cloud-starter-query/src/test/resources/swagger-expected.json b/activiti-cloud-query-service/activiti-cloud-starter-query/src/test/resources/swagger-expected.json index cc3730b524..b3d88058dd 100644 --- a/activiti-cloud-query-service/activiti-cloud-starter-query/src/test/resources/swagger-expected.json +++ b/activiti-cloud-query-service/activiti-cloud-starter-query/src/test/resources/swagger-expected.json @@ -6595,19 +6595,19 @@ "title": "CloudVariableInstance_ProcessVariables", "type": "object", "properties": { - "serviceFullName": { + "appName": { "type": "string" }, - "serviceVersion": { + "serviceName": { "type": "string" }, - "appName": { + "serviceType": { "type": "string" }, - "serviceName": { + "serviceFullName": { "type": "string" }, - "serviceType": { + "serviceVersion": { "type": "string" }, "appVersion": { @@ -6622,14 +6622,14 @@ "type": { "type": "string" }, - "processInstanceId": { - "type": "string" - }, "taskId": { "type": "string" }, "taskVariable": { "type": "boolean" + }, + "processInstanceId": { + "type": "string" } } }, @@ -6707,6 +6707,9 @@ ] } }, + "processDefinitionName": { + "type": "string" + }, "processVariables": { "uniqueItems": true, "type": "array", @@ -6714,22 +6717,19 @@ "$ref": "#/components/schemas/CloudVariableInstance_ProcessVariables" } }, - "processDefinitionName": { - "type": "string" - }, - "serviceFullName": { + "appName": { "type": "string" }, - "serviceVersion": { + "serviceName": { "type": "string" }, - "appName": { + "serviceType": { "type": "string" }, - "serviceName": { + "serviceFullName": { "type": "string" }, - "serviceType": { + "serviceVersion": { "type": "string" }, "appVersion": { @@ -6755,43 +6755,19 @@ "standalone": { "type": "boolean" }, - "parentTaskId": { - "type": "string" - }, - "taskDefinitionKey": { - "type": "string" - }, - "processDefinitionId": { - "type": "string" - }, - "completedDate": { - "type": "string", - "format": "date-time" + "processDefinitionVersion": { + "type": "integer", + "format": "int32" }, - "processInstanceId": { + "formKey": { "type": "string" }, - "candidateUsers": { - "type": "array", - "items": { - "type": "string" - } - }, - "candidateGroups": { - "type": "array", - "items": { - "type": "string" - } - }, "businessKey": { "type": "string" }, "assignee": { "type": "string" }, - "formKey": { - "type": "string" - }, "createdDate": { "type": "string", "format": "date-time" @@ -6821,9 +6797,33 @@ "DELETED" ] }, - "processDefinitionVersion": { - "type": "integer", - "format": "int32" + "processInstanceId": { + "type": "string" + }, + "candidateUsers": { + "type": "array", + "items": { + "type": "string" + } + }, + "candidateGroups": { + "type": "array", + "items": { + "type": "string" + } + }, + "processDefinitionId": { + "type": "string" + }, + "parentTaskId": { + "type": "string" + }, + "taskDefinitionKey": { + "type": "string" + }, + "completedDate": { + "type": "string", + "format": "date-time" } } }, @@ -6838,6 +6838,13 @@ "type": "string" } }, + "processDefinitionName": { + "uniqueItems": true, + "type": "array", + "items": { + "type": "string" + } + }, "initiator": { "uniqueItems": true, "type": "array", @@ -6921,19 +6928,19 @@ "title": "CloudProcessInstance_ProcessVariables", "type": "object", "properties": { - "serviceFullName": { + "appName": { "type": "string" }, - "serviceVersion": { + "serviceName": { "type": "string" }, - "appName": { + "serviceType": { "type": "string" }, - "serviceName": { + "serviceFullName": { "type": "string" }, - "serviceType": { + "serviceVersion": { "type": "string" }, "appVersion": { @@ -6945,16 +6952,15 @@ "id": { "type": "string" }, - "processDefinitionId": { - "type": "string" + "processDefinitionVersion": { + "type": "integer", + "format": "int32" }, - "completedDate": { - "type": "string", - "format": "date-time" + "processDefinitionName": { + "type": "string" }, - "startDate": { - "type": "string", - "format": "date-time" + "processDefinitionKey": { + "type": "string" }, "businessKey": { "type": "string" @@ -6962,6 +6968,13 @@ "initiator": { "type": "string" }, + "startDate": { + "type": "string", + "format": "date-time" + }, + "parentId": { + "type": "string" + }, "status": { "type": "string", "enum": [ @@ -6972,18 +6985,12 @@ "COMPLETED" ] }, - "parentId": { - "type": "string" - }, - "processDefinitionVersion": { - "type": "integer", - "format": "int32" - }, - "processDefinitionName": { + "processDefinitionId": { "type": "string" }, - "processDefinitionKey": { - "type": "string" + "completedDate": { + "type": "string", + "format": "date-time" } } }, @@ -7070,19 +7077,19 @@ "title": "CloudVariableInstance", "type": "object", "properties": { - "serviceFullName": { + "appName": { "type": "string" }, - "serviceVersion": { + "serviceName": { "type": "string" }, - "appName": { + "serviceType": { "type": "string" }, - "serviceName": { + "serviceFullName": { "type": "string" }, - "serviceType": { + "serviceVersion": { "type": "string" }, "appVersion": { @@ -7097,14 +7104,14 @@ "type": { "type": "string" }, - "processInstanceId": { - "type": "string" - }, "taskId": { "type": "string" }, "taskVariable": { "type": "boolean" + }, + "processInstanceId": { + "type": "string" } } }, @@ -7170,19 +7177,19 @@ "title": "CloudVariableInstance_General", "type": "object", "properties": { - "serviceFullName": { + "appName": { "type": "string" }, - "serviceVersion": { + "serviceName": { "type": "string" }, - "appName": { + "serviceType": { "type": "string" }, - "serviceName": { + "serviceFullName": { "type": "string" }, - "serviceType": { + "serviceVersion": { "type": "string" }, "appVersion": { @@ -7197,14 +7204,14 @@ "type": { "type": "string" }, - "processInstanceId": { - "type": "string" - }, "taskId": { "type": "string" }, "taskVariable": { "type": "boolean" + }, + "processInstanceId": { + "type": "string" } } }, @@ -7233,6 +7240,9 @@ ] } }, + "processDefinitionName": { + "type": "string" + }, "processVariables": { "uniqueItems": true, "type": "array", @@ -7240,22 +7250,19 @@ "$ref": "#/components/schemas/CloudVariableInstance_General" } }, - "processDefinitionName": { - "type": "string" - }, - "serviceFullName": { + "appName": { "type": "string" }, - "serviceVersion": { + "serviceName": { "type": "string" }, - "appName": { + "serviceType": { "type": "string" }, - "serviceName": { + "serviceFullName": { "type": "string" }, - "serviceType": { + "serviceVersion": { "type": "string" }, "appVersion": { @@ -7281,43 +7288,19 @@ "standalone": { "type": "boolean" }, - "parentTaskId": { - "type": "string" - }, - "taskDefinitionKey": { - "type": "string" - }, - "processDefinitionId": { - "type": "string" - }, - "completedDate": { - "type": "string", - "format": "date-time" + "processDefinitionVersion": { + "type": "integer", + "format": "int32" }, - "processInstanceId": { + "formKey": { "type": "string" }, - "candidateUsers": { - "type": "array", - "items": { - "type": "string" - } - }, - "candidateGroups": { - "type": "array", - "items": { - "type": "string" - } - }, "businessKey": { "type": "string" }, "assignee": { "type": "string" }, - "formKey": { - "type": "string" - }, "createdDate": { "type": "string", "format": "date-time" @@ -7347,9 +7330,33 @@ "DELETED" ] }, - "processDefinitionVersion": { - "type": "integer", - "format": "int32" + "processInstanceId": { + "type": "string" + }, + "candidateUsers": { + "type": "array", + "items": { + "type": "string" + } + }, + "candidateGroups": { + "type": "array", + "items": { + "type": "string" + } + }, + "processDefinitionId": { + "type": "string" + }, + "parentTaskId": { + "type": "string" + }, + "taskDefinitionKey": { + "type": "string" + }, + "completedDate": { + "type": "string", + "format": "date-time" } } }, @@ -7357,19 +7364,19 @@ "title": "CloudProcessInstance_General", "type": "object", "properties": { - "serviceFullName": { + "appName": { "type": "string" }, - "serviceVersion": { + "serviceName": { "type": "string" }, - "appName": { + "serviceType": { "type": "string" }, - "serviceName": { + "serviceFullName": { "type": "string" }, - "serviceType": { + "serviceVersion": { "type": "string" }, "appVersion": { @@ -7381,16 +7388,15 @@ "id": { "type": "string" }, - "processDefinitionId": { - "type": "string" + "processDefinitionVersion": { + "type": "integer", + "format": "int32" }, - "completedDate": { - "type": "string", - "format": "date-time" + "processDefinitionName": { + "type": "string" }, - "startDate": { - "type": "string", - "format": "date-time" + "processDefinitionKey": { + "type": "string" }, "businessKey": { "type": "string" @@ -7398,6 +7404,13 @@ "initiator": { "type": "string" }, + "startDate": { + "type": "string", + "format": "date-time" + }, + "parentId": { + "type": "string" + }, "status": { "type": "string", "enum": [ @@ -7408,18 +7421,12 @@ "COMPLETED" ] }, - "parentId": { - "type": "string" - }, - "processDefinitionVersion": { - "type": "integer", - "format": "int32" - }, - "processDefinitionName": { + "processDefinitionId": { "type": "string" }, - "processDefinitionKey": { - "type": "string" + "completedDate": { + "type": "string", + "format": "date-time" } } }, @@ -7485,19 +7492,19 @@ "title": "CloudProcessDefinition", "type": "object", "properties": { - "serviceFullName": { + "appName": { "type": "string" }, - "serviceVersion": { + "serviceName": { "type": "string" }, - "appName": { + "serviceType": { "type": "string" }, - "serviceName": { + "serviceFullName": { "type": "string" }, - "serviceType": { + "serviceVersion": { "type": "string" }, "appVersion": { @@ -7615,21 +7622,20 @@ "id": { "type": "string" }, - "completedDate": { - "type": "string", - "format": "date-time" - }, - "cancelledDate": { - "type": "string", - "format": "date-time" + "processDefinitionVersion": { + "type": "integer", + "format": "int32" }, - "businessKey": { + "processDefinitionKey": { "type": "string" }, "startedDate": { "type": "string", "format": "date-time" }, + "businessKey": { + "type": "string" + }, "status": { "type": "string", "enum": [ @@ -7639,47 +7645,48 @@ "ERROR" ] }, - "processDefinitionVersion": { - "type": "integer", - "format": "int32" + "cancelledDate": { + "type": "string", + "format": "date-time" }, - "processDefinitionKey": { - "type": "string" + "completedDate": { + "type": "string", + "format": "date-time" }, - "serviceFullName": { + "appName": { "type": "string" }, - "serviceVersion": { + "serviceName": { "type": "string" }, - "appName": { + "serviceType": { "type": "string" }, - "serviceName": { + "serviceFullName": { "type": "string" }, - "serviceType": { + "serviceVersion": { "type": "string" }, "appVersion": { "type": "string" }, - "activityName": { + "executionId": { "type": "string" }, - "activityType": { + "activityName": { "type": "string" }, - "executionId": { + "activityType": { "type": "string" }, - "processDefinitionId": { + "elementId": { "type": "string" }, "processInstanceId": { "type": "string" }, - "elementId": { + "processDefinitionId": { "type": "string" } } @@ -7724,6 +7731,29 @@ "errorMessage": { "type": "string" }, + "requestDate": { + "type": "string", + "format": "date-time" + }, + "resultDate": { + "type": "string", + "format": "date-time" + }, + "errorDate": { + "type": "string", + "format": "date-time" + }, + "errorCode": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "INTEGRATION_REQUESTED", + "INTEGRATION_RESULT_RECEIVED", + "INTEGRATION_ERROR_RECEIVED" + ] + }, "errorClassName": { "type": "string" }, @@ -7760,33 +7790,38 @@ } } }, - "requestDate": { - "type": "string", - "format": "date-time" + "id": { + "type": "string" }, - "resultDate": { - "type": "string", - "format": "date-time" + "rootProcessInstanceId": { + "type": "string" }, - "errorDate": { - "type": "string", - "format": "date-time" + "parentProcessInstanceId": { + "type": "string" }, - "errorCode": { + "processDefinitionVersion": { + "type": "integer", + "format": "int32" + }, + "processDefinitionKey": { "type": "string" }, - "status": { - "type": "string", - "enum": [ - "INTEGRATION_REQUESTED", - "INTEGRATION_RESULT_RECEIVED", - "INTEGRATION_ERROR_RECEIVED" - ] + "clientId": { + "type": "string" }, - "id": { + "clientName": { "type": "string" }, - "processDefinitionId": { + "appVersion": { + "type": "string" + }, + "businessKey": { + "type": "string" + }, + "clientType": { + "type": "string" + }, + "executionId": { "type": "string" }, "connectorType": { @@ -7807,35 +7842,16 @@ "processInstanceId": { "type": "string" }, - "businessKey": { - "type": "string" - }, - "executionId": { - "type": "string" - }, - "appVersion": { - "type": "string" - }, - "clientType": { - "type": "string" - }, - "clientId": { - "type": "string" - }, - "clientName": { + "processDefinitionId": { "type": "string" }, - "rootProcessInstanceId": { + "appName": { "type": "string" }, - "parentProcessInstanceId": { + "serviceName": { "type": "string" }, - "processDefinitionVersion": { - "type": "integer", - "format": "int32" - }, - "processDefinitionKey": { + "serviceType": { "type": "string" }, "serviceFullName": { @@ -7843,15 +7859,6 @@ }, "serviceVersion": { "type": "string" - }, - "appName": { - "type": "string" - }, - "serviceName": { - "type": "string" - }, - "serviceType": { - "type": "string" } } },