From 313e535b8d7ff5b03c8b332b5e3018cc40731bae Mon Sep 17 00:00:00 2001 From: Geeta Mandakini Ayyalasomayajula <45559635+gmandakini@users.noreply.github.com> Date: Wed, 16 Oct 2019 21:18:07 +0100 Subject: [PATCH] [DW-1521] added message-events api methods (#5146) * added message events api * added export * added the getProcessInstance method in the queryservice * added form-cloud.service with method to submit the form. * added form-cloud.service with method to submit the form. * returning the error instead of throwing, which can be used in expected negative api assertions in the test. * added getTaskByNAme method to filter a task by unique task-name within a process-instance * linting fix * made correlation key as optional parameter * removed the unnecessary tslint disable statements * removed the unnecessary tslint disable statements and reverted the throw error statement * logging response is not needed * added return type * added return type --- .../core/actions/identity/query.service.ts | 31 +++++++++ .../form-cloud/actions/form-cloud.service.ts | 48 +++++++++++++ .../src/lib/form-cloud/actions/public-api.ts | 18 +++++ lib/testing/src/lib/form-cloud/public-api.ts | 18 +++++ .../actions/message-events.service.ts | 68 +++++++++++++++++++ .../actions/public-api.ts | 1 + lib/testing/src/public-api.ts | 1 + 7 files changed, 185 insertions(+) create mode 100644 lib/testing/src/lib/form-cloud/actions/form-cloud.service.ts create mode 100644 lib/testing/src/lib/form-cloud/actions/public-api.ts create mode 100644 lib/testing/src/lib/form-cloud/public-api.ts create mode 100644 lib/testing/src/lib/process-services-cloud/actions/message-events.service.ts diff --git a/lib/testing/src/lib/core/actions/identity/query.service.ts b/lib/testing/src/lib/core/actions/identity/query.service.ts index c516b795d3..4ac0156c3b 100644 --- a/lib/testing/src/lib/core/actions/identity/query.service.ts +++ b/lib/testing/src/lib/core/actions/identity/query.service.ts @@ -39,6 +39,19 @@ export class QueryService { } } + async getProcessInstance(processInstanceId, appName): Promise { + try { + const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId; + const method = 'GET'; + + const queryParams = {}, postBody = {}; + + return this.api.performBpmOperation(path, method, queryParams, postBody); + } catch (error) { + Logger.error('get process-instance Service error'); + } + } + async getProcessInstanceSubProcesses(processInstanceId, appName): Promise { try { const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/subprocesses'; @@ -52,4 +65,22 @@ export class QueryService { } } + async getTaskByName(taskName, processInstanceId, appName): Promise { + try { + const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks'; + const method = 'GET'; + + const queryParams = {}, postBody = {}; + + const data = await this.api.performBpmOperation(path, method, queryParams, postBody); + for (let i = 0; i < data.list.entries.length; i++) { + if (data.list.entries[i].entry.name === taskName) { + return data.list.entries[i]; + } + } + } catch (error) { + Logger.error('Get Task By Name - Service error'); + } + } + } diff --git a/lib/testing/src/lib/form-cloud/actions/form-cloud.service.ts b/lib/testing/src/lib/form-cloud/actions/form-cloud.service.ts new file mode 100644 index 0000000000..fd83d40877 --- /dev/null +++ b/lib/testing/src/lib/form-cloud/actions/form-cloud.service.ts @@ -0,0 +1,48 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ApiService } from '../../core/actions/api.service'; +import { Logger } from '../../core/utils/logger'; + +export class FormCloudService { + + api: ApiService; + + constructor(api: ApiService) { + this.api = api; + } + + async submitForm(formId, appName, taskId, processInstanceId, values): Promise { + try { + const path = '/' + appName + '/form/v1/forms/' + formId + '/submit'; + const method = 'POST'; + + const queryParams = {}, postBody = { + 'values': values, + 'taskId': taskId, + 'processInstanceId': processInstanceId + }; + + return this.api.performBpmOperation(path, method, queryParams, postBody); + + } catch (error) { + Logger.error('Form Submit Service not working', error.message); + } + + } + +} diff --git a/lib/testing/src/lib/form-cloud/actions/public-api.ts b/lib/testing/src/lib/form-cloud/actions/public-api.ts new file mode 100644 index 0000000000..44d0e7c29c --- /dev/null +++ b/lib/testing/src/lib/form-cloud/actions/public-api.ts @@ -0,0 +1,18 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from './form-cloud.service'; diff --git a/lib/testing/src/lib/form-cloud/public-api.ts b/lib/testing/src/lib/form-cloud/public-api.ts new file mode 100644 index 0000000000..963a643008 --- /dev/null +++ b/lib/testing/src/lib/form-cloud/public-api.ts @@ -0,0 +1,18 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from './actions/public-api'; diff --git a/lib/testing/src/lib/process-services-cloud/actions/message-events.service.ts b/lib/testing/src/lib/process-services-cloud/actions/message-events.service.ts new file mode 100644 index 0000000000..c7cac4d0a1 --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/actions/message-events.service.ts @@ -0,0 +1,68 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ApiService } from '../../core/actions/api.service'; +import { Logger } from '../../core/utils/logger'; + +export class MessageEventsService { + + api: ApiService; + + constructor(api: ApiService) { + this.api = api; + } + + async startMessageEvent(startMessage, appName, options?: any): Promise { + try { + const path = '/' + appName + '/rb/v1/process-instances/message'; + const method = 'POST'; + + const queryParams = {}, postBody = { + 'name': startMessage, + 'variables': {}, + 'payloadType': 'StartMessagePayload', + ...options + }; + + return this.api.performBpmOperation(path, method, queryParams, postBody); + + } catch (error) { + Logger.error('Start Message Event Service not working', error.message); + } + + } + + async receiveMessageEvent(receiveMessage, appName, options?: any): Promise { + try { + const path = '/' + appName + '/rb/v1/process-instances/message'; + const method = 'PUT'; + + const queryParams = {}, postBody = { + 'name': receiveMessage, + 'variables': {}, + 'payloadType': 'ReceiveMessagePayload', + ...options + }; + + return this.api.performBpmOperation(path, method, queryParams, postBody); + + } catch (error) { + Logger.error('Receive Message Event Service not working', error.message); + } + } + +} diff --git a/lib/testing/src/lib/process-services-cloud/actions/public-api.ts b/lib/testing/src/lib/process-services-cloud/actions/public-api.ts index 52277a363a..d9702ee825 100644 --- a/lib/testing/src/lib/process-services-cloud/actions/public-api.ts +++ b/lib/testing/src/lib/process-services-cloud/actions/public-api.ts @@ -19,3 +19,4 @@ export * from './testing-alfresco-api.service'; export * from './testing-app-config.service'; export * from './process-definitions.service'; export * from './process-instances.service'; +export * from './message-events.service'; diff --git a/lib/testing/src/public-api.ts b/lib/testing/src/public-api.ts index aa42f93b28..40f334aee8 100644 --- a/lib/testing/src/public-api.ts +++ b/lib/testing/src/public-api.ts @@ -16,6 +16,7 @@ */ export * from './lib/core/public-api'; +export * from './lib/form-cloud/public-api'; export * from './lib/material/public-api'; export * from './lib/content-services/public-api'; export * from './lib/material/public-api';