Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / mso-infrastructure-bpmn / src / test / java / org / onap / so / bpmn / common / ManualHandlingIT.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.bpmn.common;
24
25 import static org.onap.so.bpmn.mock.StubResponseDatabase.MockPostRequestDB;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.UUID;
30 import org.camunda.bpm.engine.TaskService;
31 import org.camunda.bpm.engine.task.Task;
32 import org.camunda.bpm.engine.task.TaskQuery;
33 import org.junit.Assert;
34 import org.junit.Test;
35 import org.onap.so.BaseIntegrationTest;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 /**
40  * Unit test for RainyDayHandler.bpmn.
41  */
42 public class ManualHandlingIT extends BaseIntegrationTest {
43     Logger logger = LoggerFactory.getLogger(ManualHandlingIT.class);
44
45     @Test
46     public void TestManualHandlingSuccess() {
47         MockPostRequestDB(wireMockServer);
48
49         Map<String, Object> variables = new HashMap<>();
50         variables.put("isDebugLogEnabled", "true");
51         variables.put("msoRequestId", "testRequestId");
52         variables.put("serviceType", "X");
53         variables.put("vnfType", "Y");
54         variables.put("currentActivity", "BB1");
55         variables.put("workStep", "1");
56         variables.put("failedActivity", "AAI");
57         variables.put("vnfName", "vSAMP12");
58         variables.put("errorCode", "123");
59         variables.put("errorText", "update failed");
60         variables.put("validResponses", "Rollback");
61         variables.put("vnfName", "vSAMP1");
62
63
64         String businessKey = UUID.randomUUID().toString();
65         invokeSubProcess("ManualHandling", businessKey, variables);
66
67         try {
68             Thread.sleep(5);
69         } catch (Exception e) {
70
71         }
72
73         TaskService taskService = processEngine.getTaskService();
74
75         TaskQuery q = taskService.createTaskQuery();
76
77         List<Task> tasks = q.orderByTaskCreateTime().asc().list();
78
79         for (Task task : tasks) {
80             logger.debug("TASK ID: {}", task.getId());
81             logger.debug("TASK NAME: {}", task.getName());
82
83             try {
84                 logger.debug("Completing the task");
85                 Map<String, Object> completeVariables = new HashMap<>();
86                 completeVariables.put("responseValue", "skip");
87                 taskService.complete(task.getId(), completeVariables);
88             } catch (Exception e) {
89                 logger.debug("GOT EXCEPTION: {}", e.getMessage());
90             }
91         }
92
93         waitForProcessEnd(businessKey, 100000);
94
95         Assert.assertTrue(isProcessEnded(businessKey));
96     }
97 }