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.infrastructure;
23 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
24 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
25 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
26 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
27 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
28 import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut;
30 import java.io.IOException;
31 import java.util.HashMap;
33 import java.util.UUID;
35 import org.camunda.bpm.engine.test.Deployment;
36 import org.junit.Test;
37 import org.openecomp.mso.bpmn.common.WorkflowTest;
38 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
39 import org.openecomp.mso.bpmn.mock.FileUtil;
42 * Unit test cases for UpdateVfModule.bpmn
44 public class UpdateVfModuleInfraTest extends WorkflowTest {
46 private final CallbackSet callbacks = new CallbackSet();
48 public UpdateVfModuleInfraTest() throws IOException {
49 callbacks.put("changeassign", FileUtil.readResourceFile(
50 "__files/VfModularity/SDNCTopologyChangeAssignCallback.xml"));
51 callbacks.put("query", FileUtil.readResourceFile(
52 "__files/VfModularity/SDNCTopologyQueryCallback.xml"));
53 callbacks.put("activate", FileUtil.readResourceFile(
54 "__files/VfModularity/SDNCTopologyActivateCallback.xml"));
55 callbacks.put("vnfUpdate", FileUtil.readResourceFile(
56 "__files/VfModularity/VNFAdapterRestUpdateCallback.xml"));
66 @Deployment(resources = {
67 "process/UpdateVfModuleInfra.bpmn",
68 "subprocess/DoUpdateVfModule.bpmn",
69 "subprocess/PrepareUpdateAAIVfModule.bpmn",
70 "subprocess/ConfirmVolumeGroupTenant.bpmn",
71 "subprocess/SDNCAdapterV1.bpmn",
72 "subprocess/VnfAdapterRestV1.bpmn",
73 "subprocess/UpdateAAIGenericVnf.bpmn",
74 "subprocess/UpdateAAIVfModule.bpmn",
75 "subprocess/CompleteMsoProcess.bpmn",
76 "subprocess/FalloutHandler.bpmn"
78 public void sunnyDay() throws Exception {
82 MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
83 MockPutVfModuleIdNoResponse("skask", "PCRF", "supercool");
84 MockGetGenericVnfByIdWithPriority("skask", "supercool", 200, "VfModularity/VfModule-supercool.xml", 1);
85 mockSDNCAdapter("/SDNCAdapter", "SvcInstanceId><", 200, "VfModularity/StandardSDNCSynchResponse.xml");
86 mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml");
87 mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml");
88 mockVNFPut("skask", "/supercool", 202);
89 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
91 String businessKey = UUID.randomUUID().toString();
92 String updaetVfModuleRequest =
93 FileUtil.readResourceFile("__files/InfrastructureFlows/UpdateVfModule_VID_request.json");
95 Map<String, Object> variables = setupVariablesSunnyDayVID();
98 TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleInfra",
99 "v1", businessKey, updaetVfModuleRequest, variables);
101 WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000);
103 String responseBody = response.getResponse();
104 System.out.println("Workflow (Synch) Response:\n" + responseBody);
106 injectSDNCCallbacks(callbacks, "changeassign, query");
107 injectVNFRestCallbacks(callbacks, "vnfUpdate");
108 injectSDNCCallbacks(callbacks, "activate");
110 // TODO add appropriate assertions
112 waitForProcessEnd(businessKey, 10000);
113 checkVariable(businessKey, "UpdateVfModuleInfraSuccessIndicator", true);
119 private Map<String, Object> setupVariablesSunnyDayVID() {
120 Map<String, Object> variables = new HashMap<String, Object>();
122 // variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
124 //catch (Exception e) {
127 //variables.put("mso-request-id", "testRequestId");
128 variables.put("requestId", "testRequestId");
129 variables.put("isBaseVfModule", false);
130 variables.put("isDebugLogEnabled", "true");
131 variables.put("recipeTimeout", "0");
132 variables.put("requestAction", "UPDATE_VF_MODULE");
133 variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4");
134 variables.put("vnfId", "skask");
135 variables.put("vnfType", "vSAMP12");
136 variables.put("vfModuleId", "supercool");
137 variables.put("volumeGroupId", "");
138 variables.put("serviceType", "MOG");
139 variables.put("vfModuleType", "");