diff --git a/lib/testing/src/lib/process-services/actions/process.util.ts b/lib/testing/src/lib/process-services/actions/process.util.ts index 9d08867310..ab5b6f265c 100644 --- a/lib/testing/src/lib/process-services/actions/process.util.ts +++ b/lib/testing/src/lib/process-services/actions/process.util.ts @@ -92,15 +92,11 @@ export class ProcessUtil { } } - async getProcessInstanceByName(processInstanceName: string): Promise { + async getProcessInstanceByName(processInstanceName: string, processInstanceStatus?: string, maxNumberOfResults?: number): Promise { try { - const processInstanceList = await this.api.apiService.activiti.processApi.getProcessInstances({state: 'all'}); - const chosenProcessInstance = processInstanceList.data.find( (processInstanace) => { - return processInstanace.name === processInstanceName; - }); - return chosenProcessInstance; + return await this.api.apiService.activiti.processApi.filterProcessInstances({filter: {name: processInstanceName, state: processInstanceStatus}, size: maxNumberOfResults}); } catch (error) { - Logger.error('Get Process Instance by Name - Service error, Response: ', JSON.parse(JSON.stringify(error))); + Logger.error('List process instances using a filter - Service error, Response: ', JSON.parse(JSON.stringify(error))); } }