2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.infrastructure;
\r
25 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
\r
26 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
\r
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleIdNoResponse;
\r
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
\r
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
\r
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
\r
31 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
\r
32 import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut;
\r
34 import java.io.IOException;
\r
35 import java.util.HashMap;
\r
36 import java.util.Map;
\r
37 import java.util.UUID;
\r
39 import org.camunda.bpm.engine.test.Deployment;
\r
40 import org.junit.Assert;
\r
41 import org.junit.Ignore;
\r
42 import org.junit.Test;
\r
43 import org.openecomp.mso.bpmn.common.WorkflowTest;
\r
44 import org.openecomp.mso.bpmn.common.WorkflowTest.CallbackSet;
\r
45 import org.openecomp.mso.bpmn.mock.FileUtil;
\r
48 * Unit tests for DoUpdateVfModule.bpmn.
\r
50 public class DoUpdateVfModuleTest extends WorkflowTest {
\r
52 private final CallbackSet callbacks = new CallbackSet();
\r
54 public DoUpdateVfModuleTest() throws IOException {
\r
55 callbacks.put("changeassign", FileUtil.readResourceFile(
\r
56 "__files/VfModularity/SDNCTopologyChangeAssignCallback.xml"));
\r
57 callbacks.put("query", FileUtil.readResourceFile(
\r
58 "__files/VfModularity/SDNCTopologyQueryCallback.xml"));
\r
59 callbacks.put("activate", FileUtil.readResourceFile(
\r
60 "__files/VfModularity/SDNCTopologyActivateCallback.xml"));
\r
61 callbacks.put("vnfUpdate", FileUtil.readResourceFile(
\r
62 "__files/VfModularity/VNFAdapterRestUpdateCallback.xml"));
\r
66 * Test the happy path through the flow.
\r
70 @Deployment(resources = {
\r
71 "subprocess/DoUpdateVfModule.bpmn",
\r
72 "subprocess/PrepareUpdateAAIVfModule.bpmn",
\r
73 "subprocess/ConfirmVolumeGroupTenant.bpmn",
\r
74 "subprocess/SDNCAdapterV1.bpmn",
\r
75 "subprocess/VnfAdapterRestV1.bpmn",
\r
76 "subprocess/UpdateAAIGenericVnf.bpmn",
\r
77 "subprocess/UpdateAAIVfModule.bpmn"
\r
79 public void happyPath() throws IOException {
\r
83 String doUpdateVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/DoUpdateVfModuleRequest.xml");
\r
84 MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
\r
85 MockGetVfModuleIdNoResponse("skask", "PCRF", "supercool");
\r
86 MockPutVfModuleIdNoResponse("skask", "PCRF", "supercool");
\r
87 MockGetVolumeGroupById("MDTWNJ21", "78987", "VfModularity/VolumeGroup.xml");
\r
88 mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml");
\r
89 mockSDNCAdapter("/SDNCAdapter", "SvcInstanceId><", 200, "VfModularity/StandardSDNCSynchResponse.xml");
\r
90 mockVNFPut("skask", "/supercool", 202);
\r
91 MockPutGenericVnf("skask");
\r
92 MockGetGenericVnfByIdWithPriority("skask", "supercool", 200, "VfModularity/VfModule-supercool.xml", 1);
\r
94 String businessKey = UUID.randomUUID().toString();
\r
95 Map<String, Object> variables = new HashMap<String, Object>();
\r
96 variables.put("mso-request-id", "DEV-VF-0011");
\r
97 variables.put("isDebugLogEnabled","true");
\r
98 variables.put("DoUpdateVfModuleRequest", doUpdateVfModuleRequest);
\r
99 invokeSubProcess("DoUpdateVfModule", businessKey, variables);
\r
101 injectSDNCCallbacks(callbacks, "changeassign, query");
\r
102 injectVNFRestCallbacks(callbacks, "vnfUpdate");
\r
103 injectSDNCCallbacks(callbacks, "activate");
\r
105 waitForProcessEnd(businessKey, 10000);
\r
107 Assert.assertTrue(isProcessEnded(businessKey));
\r
108 checkVariable(businessKey, "DoUpdateVfModuleSuccessIndicator", true);
\r
110 String heatStackId = (String) getVariableFromHistory(businessKey, "DOUPVfMod_heatStackId");
\r
111 System.out.println("Heat stack Id from AAI: " + heatStackId);
\r