2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.common;
23 import static org.junit.Assert.assertEquals;
24 import java.util.HashMap;
26 import java.util.UUID;
27 import org.camunda.bpm.engine.test.Deployment;
28 import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
29 import org.junit.Ignore;
30 import org.junit.Test;
31 import org.onap.so.bpmn.common.workflow.context.WorkflowResponse;
32 import org.onap.so.bpmn.common.workflow.service.WorkflowAsyncResource;
35 public class WorkflowAsyncResourceTest extends WorkflowTest {
38 @Deployment(resources = {"testAsyncResource.bpmn"})
39 public void asyncRequestSuccess() throws InterruptedException {
40 // it can be any request which asynchronously processed by the workflow
42 "<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns5=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>";
44 Map<String, String> variables = new HashMap<>();
45 variables.put("testAsyncRequestMsg", request);
46 variables.put("mso-request-id", UUID.randomUUID().toString());
47 variables.put("mso-service-request-timeout", "5");
49 WorkflowResponse workflowResponse =
50 BPMNUtil.executeAsyncWorkflow(processEngineRule, "testAsyncProcess", variables);
52 "Received the request, the process is getting executed, request message<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns5=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>",
53 workflowResponse.getResponse());
54 assertEquals(200, workflowResponse.getMessageCode());
57 private void executeWorkflow(String request, String requestId, String processKey) throws InterruptedException {
58 WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
59 VariableMapImpl variableMap = new VariableMapImpl();
61 Map<String, Object> variableValueType = new HashMap<>();
63 Map<String, Object> requestMsg = new HashMap<>();
64 requestMsg.put("value", request);
65 requestMsg.put("type", "String");
67 Map<String, Object> msorequestId = new HashMap<>();
68 msorequestId.put("type", "String");
69 msorequestId.put("value", requestId);
71 Map<String, Object> timeout = new HashMap<>();
72 timeout.put("type", "String");
73 timeout.put("value", "5");
75 variableValueType.put("testAsyncRequestMsg", requestMsg);
76 variableValueType.put("mso-request-id", msorequestId);
77 variableValueType.put("mso-service-request-timeout", timeout);
79 variableMap.put("variables", variableValueType);
81 workflowResource.setProcessEngineServices4junit(processEngineRule);
82 workflowResource.startProcessInstanceByKey(processKey, variableMap);