Containerization feature of SO
[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  * 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;
22
23 import static org.onap.so.bpmn.mock.StubResponseDatabase.MockPostRequestDB;
24
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.UUID;
29
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.onap.so.logger.MsoLogger;
37
38 /**
39  * Unit test for RainyDayHandler.bpmn.
40  */
41 public class ManualHandlingIT extends BaseIntegrationTest {
42         MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,ManualHandlingIT.class);
43         
44         @Test
45         public void  TestManualHandlingSuccess() {
46                 MockPostRequestDB();
47                 
48                 Map<String, Object> variables = new HashMap<>();
49                 variables.put("isDebugLogEnabled","true");
50                 variables.put("msoRequestId", "testRequestId");
51                 variables.put("serviceType", "X");
52                 variables.put("vnfType", "Y");
53                 variables.put("currentActivity", "BB1");
54                 variables.put("workStep", "1");
55                 variables.put("failedActivity", "AAI");
56                 variables.put("vnfName", "vSAMP12");
57                 variables.put("errorCode", "123");
58                 variables.put("errorText", "update failed");
59                 variables.put("validResponses", "Rollback");
60                 variables.put("vnfName", "vSAMP1");
61
62
63                 String businessKey = UUID.randomUUID().toString();
64                 invokeSubProcess("ManualHandling", businessKey, variables);
65                 
66                 try {
67                         Thread.sleep(5);
68                 } catch (Exception e) {
69
70                 }
71
72                 TaskService taskService = processEngine.getTaskService();
73
74                 TaskQuery q = taskService.createTaskQuery();
75
76                 List<Task> tasks = q.orderByTaskCreateTime().asc().list();
77                 
78                 for (Task task : tasks) {
79                         logger.debug("TASK ID: " + task.getId());
80                         logger.debug("TASK NAME: " + task.getName());
81                         
82                         try {
83                                 logger.debug("Completing the task");
84                                 Map<String,Object> completeVariables = new HashMap<>();
85                                 completeVariables.put("responseValue", "skip");
86                                 taskService.complete(task.getId(), completeVariables);
87                         } catch(Exception e) {
88                                 logger.debug("GOT EXCEPTION: " + e.getMessage());
89                         }
90                 }
91                 
92                 waitForProcessEnd(businessKey, 100000);
93                 
94                 Assert.assertTrue(isProcessEnded(businessKey));
95         }
96 }