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 "UpdateVfModuleStatus",
46 "CreateVfModuleBB_End");
47 assertThat(pi).isEnded();
51 public void rainyDayCreateVfModuleSDNCQueryVnfError_Test() throws Exception {
52 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(sdncQueryTasks).queryVnf(any(BuildingBlockExecution.class));
53 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
54 assertThat(pi).isNotNull();
55 assertThat(pi).isStarted()
56 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf")
57 .hasNotPassed("QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleStatus", "CreateVfModuleBB_End");
58 assertThat(pi).isEnded();
62 public void rainyDayCreateVfModuleSDNCQueryVnfModuleError_Test() throws Exception {
63 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(sdncQueryTasks).queryVfModule(any(BuildingBlockExecution.class));
64 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
65 assertThat(pi).isNotNull();
66 assertThat(pi).isStarted()
67 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule")
68 .hasNotPassed("CreateVfModule", "VnfAdapter", "UpdateVfModuleStatus", "CreateVfModuleBB_End");
69 assertThat(pi).isEnded();
73 public void rainyDayCreateVfModuleVnfAdapterCreateError_Test() throws Exception {
74 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(vnfAdapterCreateTasks).createVfModule(any(BuildingBlockExecution.class));
75 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
76 assertThat(pi).isNotNull();
77 assertThat(pi).isStarted()
78 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule")
79 .hasNotPassed("VnfAdapter", "UpdateVfModuleStatus", "CreateVfModuleBB_End");
80 assertThat(pi).isEnded();
84 public void rainyDayCreateVfModuleUpdateVfModuleStatusError_Test() throws Exception {
85 mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
86 doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateOrchestrationStatusCreatedVfModule(any(BuildingBlockExecution.class));
87 ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables);
88 assertThat(pi).isNotNull();
89 assertThat(pi).isStarted()
90 .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleStatus")
91 .hasNotPassed("CreateVfModuleBB_End");
92 assertThat(pi).isEnded();