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.infrastructure.bpmn.subprocess;
23 import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
24 import static org.junit.Assert.assertNotNull;
25 import static org.mockito.ArgumentMatchers.any;
26 import static org.mockito.Mockito.doThrow;
27 import org.camunda.bpm.engine.ManagementService;
28 import org.camunda.bpm.engine.TaskService;
29 import org.camunda.bpm.engine.delegate.BpmnError;
30 import org.camunda.bpm.engine.runtime.Job;
31 import org.camunda.bpm.engine.runtime.ProcessInstance;
32 import org.camunda.bpm.engine.task.Task;
33 import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions;
34 import org.junit.Ignore;
35 import org.junit.Test;
36 import org.onap.so.bpmn.BaseBPMNTest;
37 import org.onap.so.bpmn.common.BuildingBlockExecution;
38 import org.springframework.beans.factory.annotation.Autowired;
41 public class PauseForManualTaskRainyDayTest extends BaseBPMNTest {
42 private static final String TIMEOUT_10_S = "PT10S";
45 protected ManagementService managementService;
48 protected TaskService taskService;
51 public void sunnyDayPauseForManualTaskRainyDayTimeout_Test() throws InterruptedException {
52 variables.put("taskTimeout", TIMEOUT_10_S);
53 ProcessInstance pi = runtimeService.startProcessInstanceByKey("PauseForManualTaskRainyDay", variables);
54 assertThat(pi).isNotNull();
55 BpmnAwareAssertions.assertThat(pi).isWaitingAt("ManualUserTask");
56 Task task = taskService.createTaskQuery().active().list().get(0);
57 assertThat(pi).task().isNotNull();
60 Job job = managementService.createJobQuery().activityId("ManualTaskTimer").singleResult();
62 managementService.executeJob(job.getId());
64 assertThat(pi).isStarted().hasPassedInOrder("PauseForManualTaskRainyDay_Start", "InitRainyDayManualHandling",
65 "UpdateDbStatusToPendingManualTask", "CreateExternalTicket", "ManualTaskTimer",
66 "UpdateDBStatusToTimeout", "PauseForManualTaskRainyDay_Timeout");
70 public void sunnyDayPauseForManualTaskCompleted_Test() throws InterruptedException {
71 variables.put("taskTimeout", TIMEOUT_10_S);
72 ProcessInstance pi = runtimeService.startProcessInstanceByKey("PauseForManualTaskRainyDay", variables);
73 assertThat(pi).isNotNull();
74 BpmnAwareAssertions.assertThat(pi).isWaitingAt("ManualUserTask");
75 assertThat(pi).task().isNotNull();
76 Task task = taskService.createTaskQuery().active().list().get(0);
78 taskService.complete(task.getId());
80 assertThat(pi).isStarted().hasPassedInOrder("PauseForManualTaskRainyDay_Start", "InitRainyDayManualHandling",
81 "UpdateDbStatusToPendingManualTask", "CreateExternalTicket", "ManualUserTask",
82 "UpdateDbStatusToInProgress", "PauseForManualTaskRainyDay_End");
83 assertThat(pi).isEnded();
87 public void rainyDayPauseForManualTask_Test() throws Exception {
88 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(manualHandlingTasks)
89 .createExternalTicket((any(BuildingBlockExecution.class)));
90 ProcessInstance pi = runtimeService.startProcessInstanceByKey("PauseForManualTaskRainyDay", variables);
91 assertThat(pi).isNotNull().isStarted()
92 .hasPassedInOrder("PauseForManualTaskRainyDay_Start", "InitRainyDayManualHandling",
93 "UpdateDbStatusToPendingManualTask", "CreateExternalTicket")
94 .hasNotPassed("ManualUserTask", "UpdateDbStatusToInProgress", "PauseForManualTaskRainyDay_End");