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;
22 import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat;
23 import static org.mockito.ArgumentMatchers.any;
24 import static org.mockito.Mockito.doThrow;
26 import org.camunda.bpm.engine.delegate.BpmnError;
27 import org.camunda.bpm.engine.runtime.ProcessInstance;
28 import org.junit.Test;
29 import org.onap.so.bpmn.BaseBPMNTest;
30 import org.onap.so.bpmn.common.BuildingBlockExecution;
32 public class CreateVfModuleBBTest extends BaseBPMNTest{
34 public void sunnyDayCreateVfModule_Test() throws InterruptedException {
35 mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
36 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
37 assertThat(pi).isNotNull();
38 assertThat(pi).isStarted().hasPassedInOrder("CreateVfModuleBB_Start",
43 "CreateNetworkPolicies",
44 "UpdateVnfIpv4OamAddress",
45 "UpdateVnfManagementV6Address",
46 "UpdateVfModuleContrailServiceInstanceFqdn",
47 "UpdateVfModuleHeatStackId",
48 "UpdateVfModuleStatus",
49 "CreateVfModuleBB_End");
50 assertThat(pi).isEnded();
54 public void rainyDayCreateVfModuleSDNCQueryVnfError_Test() throws Exception {
55 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(sdncQueryTasks).queryVnf(any(BuildingBlockExecution.class));
56 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
57 assertThat(pi).isNotNull();
58 assertThat(pi).isStarted()
59 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf")
60 .hasNotPassed("QueryVfModule", "CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", "UpdateVnfIpv4OamAddress",
61 "UpdateVnfManagementV6Address","UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId",
62 "UpdateVfModuleStatus", "CreateVfModuleBB_End");
63 assertThat(pi).isEnded();
67 public void rainyDayCreateVfModuleSDNCQueryVnfModuleError_Test() throws Exception {
68 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(sdncQueryTasks).queryVfModule(any(BuildingBlockExecution.class));
69 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
70 assertThat(pi).isNotNull();
71 assertThat(pi).isStarted()
72 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule")
73 .hasNotPassed("CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address",
74 "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End");
75 assertThat(pi).isEnded();
79 public void rainyDayCreateVfModuleVnfAdapterCreateError_Test() throws Exception {
80 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(vnfAdapterCreateTasks).createVfModule(any(BuildingBlockExecution.class));
81 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
82 assertThat(pi).isNotNull();
83 assertThat(pi).isStarted()
84 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule")
85 .hasNotPassed("VnfAdapter", "CreateNetworkPolicies","UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address",
86 "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End");
87 assertThat(pi).isEnded();
91 public void rainyDayCreateVfModuleUpdateVfModuleHeatStackIdError_Test() throws Exception {
92 mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
94 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateHeatStackIdVfModule(any(BuildingBlockExecution.class));
95 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
96 assertThat(pi).isNotNull();
97 assertThat(pi).isStarted()
98 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "CreateNetworkPolicies",
99 "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId")
100 .hasNotPassed("UpdateVfModuleStatus", "CreateVfModuleBB_End");
101 assertThat(pi).isEnded();
106 public void rainyDayCreateVfModuleUpdateVfModuleStatusError_Test() throws Exception {
107 mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
108 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateOrchestrationStatusCreatedVfModule(any(BuildingBlockExecution.class));
109 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
110 assertThat(pi).isNotNull();
111 assertThat(pi).isStarted()
112 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "CreateNetworkPolicies",
113 "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId",
114 "UpdateVfModuleStatus")
115 .hasNotPassed("CreateVfModuleBB_End");
116 assertThat(pi).isEnded();