From c3c55290d033a572c15f7527fa1be53f4748577e Mon Sep 17 00:00:00 2001 From: Jan Rohwer Date: Fri, 19 Aug 2022 14:32:29 +0200 Subject: [PATCH] fix: #249 correctly evaluate single process id passed to query --- ...RuntimeServiceProcessInstanceQueryITest.kt | 30 +++++++++++++++++++ .../query/DelegatingProcessInstanceQuery.kt | 5 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/examples/itest/src/test/kotlin/org/camunda/community/rest/itest/RuntimeServiceProcessInstanceQueryITest.kt b/examples/itest/src/test/kotlin/org/camunda/community/rest/itest/RuntimeServiceProcessInstanceQueryITest.kt index e79afb3a..17498a2c 100644 --- a/examples/itest/src/test/kotlin/org/camunda/community/rest/itest/RuntimeServiceProcessInstanceQueryITest.kt +++ b/examples/itest/src/test/kotlin/org/camunda/community/rest/itest/RuntimeServiceProcessInstanceQueryITest.kt @@ -198,4 +198,34 @@ class RuntimeServiceProcessInstanceQueryITest : } + @Test + fun `find process by single process instance id`() { + val processDefinitionKey = "processDefinitionKey" + val key1 = "businessKey1" + val key2 = "businessKey2" + val key3 = "businessKey3" + + GIVEN.no_deployment_exists() + + GIVEN + .process_with_user_task_is_deployed(processDefinitionKey) + + WHEN + .apply { + localService.startProcessInstanceByKey(processDefinitionKey, key1) + localService.startProcessInstanceByKey(processDefinitionKey, key2) + processInstance = localService.startProcessInstanceByKey(processDefinitionKey, key3) + } + + THEN + .process_instance_query_succeeds { query, _ -> + val result = query + .processInstanceId(GIVEN.processInstance.id) + .count() + assertThat( + result + ).isEqualTo(1) + } + } + } diff --git a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingProcessInstanceQuery.kt b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingProcessInstanceQuery.kt index 7b5e0ba5..85d88ee5 100644 --- a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingProcessInstanceQuery.kt +++ b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingProcessInstanceQuery.kt @@ -70,9 +70,10 @@ class DelegatingProcessInstanceQuery(private val processInstanceApiClient: Proce "processInstanceIds" -> { val ids = this@DelegatingProcessInstanceQuery.processInstanceIds?.toMutableSet() ?: mutableSetOf() if (this@DelegatingProcessInstanceQuery.processInstanceId != null) { - ids.plus(this@DelegatingProcessInstanceQuery.processInstanceId) + ids.plus(this@DelegatingProcessInstanceQuery.processInstanceId).toList() + } else { + if (ids.isEmpty()) null else ids.toList() } - if (ids.isEmpty()) null else ids.toList() } "tenantIdIn" -> this@DelegatingProcessInstanceQuery.tenantIds?.toList() "withoutTenantId" -> this@DelegatingProcessInstanceQuery.isTenantIdSet && (this@DelegatingProcessInstanceQuery.tenantIds == null)