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.mockito.Matchers.any;
25 import static org.mockito.Mockito.doThrow;
27 import org.camunda.bpm.engine.delegate.BpmnError;
28 import org.camunda.bpm.engine.runtime.ProcessInstance;
29 import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests;
30 import org.junit.Test;
31 import org.onap.so.bpmn.BaseBPMNTest;
32 import org.onap.so.bpmn.common.BuildingBlockExecution;
34 public class CreateVfModuleBBTest extends BaseBPMNTest{
36 public void sunnyDayCreateVfModule_Test() throws InterruptedException {
37 mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
38 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
39 assertThat(pi).isNotNull();
40 assertThat(pi).isStarted().hasPassedInOrder("CreateVfModuleBB_Start",
45 "UpdateVfModuleHeatStackId",
46 "UpdateVfModuleStatus",
47 "CreateVfModuleBB_End");
48 assertThat(pi).isEnded();
52 public void rainyDayCreateVfModuleSDNCQueryVnfError_Test() throws Exception {
53 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(sdncQueryTasks).queryVnf(any(BuildingBlockExecution.class));
54 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
55 assertThat(pi).isNotNull();
56 assertThat(pi).isStarted()
57 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf")
58 .hasNotPassed("QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End");
59 assertThat(pi).isEnded();
63 public void rainyDayCreateVfModuleSDNCQueryVnfModuleError_Test() throws Exception {
64 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(sdncQueryTasks).queryVfModule(any(BuildingBlockExecution.class));
65 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
66 assertThat(pi).isNotNull();
67 assertThat(pi).isStarted()
68 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule")
69 .hasNotPassed("CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End");
70 assertThat(pi).isEnded();
74 public void rainyDayCreateVfModuleVnfAdapterCreateError_Test() throws Exception {
75 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(vnfAdapterCreateTasks).createVfModule(any(BuildingBlockExecution.class));
76 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
77 assertThat(pi).isNotNull();
78 assertThat(pi).isStarted()
79 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule")
80 .hasNotPassed("VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End");
81 assertThat(pi).isEnded();
85 public void rainyDayCreateVfModuleUpdateVfModuleHeatStackIdError_Test() throws Exception {
86 mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
88 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateHeatStackIdVfModule(any(BuildingBlockExecution.class));
89 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
90 assertThat(pi).isNotNull();
91 assertThat(pi).isStarted()
92 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId")
93 .hasNotPassed("UpdateVfModuleStatus", "CreateVfModuleBB_End");
94 assertThat(pi).isEnded();
99 public void rainyDayCreateVfModuleUpdateVfModuleStatusError_Test() throws Exception {
100 mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
101 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateOrchestrationStatusCreatedVfModule(any(BuildingBlockExecution.class));
102 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
103 assertThat(pi).isNotNull();
104 assertThat(pi).isStarted()
105 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus")
106 .hasNotPassed("CreateVfModuleBB_End");
107 assertThat(pi).isEnded();