Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / mso-infrastructure-bpmn / src / test / java / org / onap / so / bpmn / common / workflow / service / WorkflowAsyncResourceExceptionHandlingTest.java
1 /*- 
2  * ============LICENSE_START======================================================= 
3  * ONAP - SO 
4  * ================================================================================ 
5  * Copyright (C) 2018 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 
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0 
12  * 
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========================================================= 
19  */
20
21 package org.onap.so.bpmn.common.workflow.service;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
26 import java.util.HashMap;
27 import java.util.Map;
28 import java.util.UUID;
29 import javax.ws.rs.core.Response;
30 import org.camunda.bpm.engine.test.Deployment;
31 import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
32 import org.junit.Test;
33 import org.onap.so.bpmn.common.workflow.context.WorkflowResponse;
34
35
36 public class WorkflowAsyncResourceExceptionHandlingTest {
37
38     @Test
39     @Deployment(resources = {"testAsyncResource.bpmn"})
40     public void asyncRequestSuccess() throws InterruptedException {
41         VariableMapImpl variableMap = new VariableMapImpl();
42
43         Map<String, Object> variableValueType = new HashMap<>();
44
45         Map<String, Object> requestMsg = new HashMap<>();
46         requestMsg.put("value", "");
47         requestMsg.put("type", "String");
48
49         Map<String, Object> msorequestId = new HashMap<>();
50         msorequestId.put("type", "String");
51         msorequestId.put("value", UUID.randomUUID().toString());
52
53         Map<String, Object> timeout = new HashMap<>();
54         timeout.put("type", "String");
55         timeout.put("value", "5");
56
57         variableValueType.put("testAsyncRequestMsg", requestMsg);
58         variableValueType.put("mso-request-id", msorequestId);
59         variableValueType.put("mso-service-request-timeout", timeout);
60
61         variableMap.put("variables", variableValueType);
62         WorkflowAsyncResource workflowAsyncResource = new WorkflowAsyncResource();
63         workflowAsyncResource.setProcessor(new WorkflowProcessor());
64         Response res = workflowAsyncResource.startProcessInstanceByKey("randomKey", variableMap);
65         assertEquals(500, res.getStatus());
66         WorkflowResponse workflowResponse = (WorkflowResponse) res.getEntity();
67         assertNotNull(workflowResponse);
68         assertEquals(500, workflowResponse.getMessageCode());
69         assertTrue(workflowResponse.getResponse().startsWith("Error occurred while executing the process:"));
70         assertEquals("Fail", workflowResponse.getMessage());
71
72
73     }
74
75 }