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.openecomp.mso.bpmn.common;
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
25 import org.camunda.bpm.engine.TaskService;
26 import org.camunda.bpm.ProcessEngineService;
27 import org.camunda.bpm.engine.task.TaskQuery;
28 import org.camunda.bpm.engine.task.Task;
29 import org.camunda.bpm.engine.delegate.BpmnError;
30 import org.camunda.bpm.engine.delegate.DelegateTask;
31 import org.camunda.bpm.engine.runtime.Execution;
33 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
34 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
35 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
36 import static com.github.tomakehurst.wiremock.client.WireMock.put;
37 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
38 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
39 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
40 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
41 import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicyAbort;
43 import java.io.DataOutputStream;
44 import java.net.HttpURLConnection;
46 import java.util.HashMap;
48 import java.util.UUID;
49 import java.util.List;
51 import org.camunda.bpm.engine.RuntimeService;
52 import org.camunda.bpm.engine.test.Deployment;
53 import org.junit.Assert;
54 import org.junit.Test;
55 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
56 import org.openecomp.mso.bpmn.core.WorkflowException;
59 * Unit test for RainyDayHandler.bpmn.
61 public class ManualHandlingTest extends WorkflowTest {
64 @Deployment(resources = {
65 "subprocess/BuildingBlock/ManualHandling.bpmn"
67 public void TestManualHandlingSuccess() {
69 RuntimeService runtimeService = processEngineRule.getRuntimeService();
70 Map<String, Object> variables = new HashMap<String, Object>();
71 variables.put("isDebugLogEnabled","true");
72 variables.put("msoRequestId", "testRequestId");
73 variables.put("serviceType", "X");
74 variables.put("vnfType", "Y");
75 variables.put("currentActivity", "BB1");
76 variables.put("workStep", "1");
77 variables.put("failedActivity", "");
78 variables.put("errorCode", "123");
79 variables.put("errorText", "update failed");
80 variables.put("validResponses", "Rollback");
83 String businessKey = UUID.randomUUID().toString();
84 invokeSubProcess("ManualHandling", businessKey, variables);
88 } catch (Exception e) {
92 TaskService taskService = processEngineRule.getTaskService();
94 TaskQuery q = taskService.createTaskQuery();
96 List<Task> tasks = q.orderByTaskCreateTime().asc().list();
99 for (Task task : tasks) {
102 System.out.println("TASK ID: " + task.getId());
103 System.out.println("TASK NAME: " + task.getName());
105 System.out.println("Completing the task");
106 Map<String,Object> completeVariables = new HashMap<String,Object>();
107 completeVariables.put("responseValue", "skip");
108 taskService.complete(task.getId(), completeVariables);
111 System.out.println("GOT EXCEPTION: " + e.getMessage());
115 waitForProcessEnd(businessKey, 100000);
117 Assert.assertTrue(isProcessEnded(businessKey));