e202b0349b62f16934f236ec9b56fc1ffcc7bec0
[so.git] /
1 /*- 
2  * ============LICENSE_START======================================================= 
3  * OPENECOMP - MSO 
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 
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0 
12  * 
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========================================================= 
19  */ 
20
21 package org.openecomp.mso.bpmn.infrastructure;
22
23
24
25 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
26 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleIdNoResponse;
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
31 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
32 import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut;
33
34 import java.io.IOException;
35 import java.util.HashMap;
36 import java.util.Map;
37 import java.util.UUID;
38
39 import org.camunda.bpm.engine.test.Deployment;
40 import org.junit.Assert;
41 import org.junit.Test;
42 import org.openecomp.mso.bpmn.common.WorkflowTest;
43 import org.openecomp.mso.bpmn.common.WorkflowTest.CallbackSet;
44 import org.openecomp.mso.bpmn.mock.FileUtil;
45
46 /**
47  * Unit tests for DoUpdateVfModule.bpmn.
48  */
49 public class DoUpdateVfModuleTest extends WorkflowTest {
50         
51         private final CallbackSet callbacks = new CallbackSet();
52
53         public DoUpdateVfModuleTest() throws IOException {
54                 callbacks.put("changeassign", FileUtil.readResourceFile(
55                         "__files/VfModularity/SDNCTopologyChangeAssignCallback.xml"));
56                 callbacks.put("query", FileUtil.readResourceFile(
57                         "__files/VfModularity/SDNCTopologyQueryCallback.xml"));
58                 callbacks.put("activate", FileUtil.readResourceFile(
59                         "__files/VfModularity/SDNCTopologyActivateCallback.xml"));
60                 callbacks.put("vnfUpdate", FileUtil.readResourceFile(
61                         "__files/VfModularity/VNFAdapterRestUpdateCallback.xml"));
62         }
63
64         /**
65          * Test the happy path through the flow.
66          */
67         @Test   
68         
69         @Deployment(resources = {
70                         "subprocess/DoUpdateVfModule.bpmn",
71                         "subprocess/PrepareUpdateAAIVfModule.bpmn",
72                         "subprocess/ConfirmVolumeGroupTenant.bpmn",
73                         "subprocess/SDNCAdapterV1.bpmn",
74                         "subprocess/VnfAdapterRestV1.bpmn",
75                         "subprocess/UpdateAAIGenericVnf.bpmn",
76                         "subprocess/UpdateAAIVfModule.bpmn"
77                 })
78         public void happyPath() throws IOException {
79                 
80                 logStart();
81                 
82                 String doUpdateVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/DoUpdateVfModuleRequest.xml");
83                 MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
84                 MockGetVfModuleIdNoResponse("skask", "PCRF", "supercool");
85                 MockPutVfModuleIdNoResponse("skask", "PCRF", "supercool");
86                 MockGetVolumeGroupById("MDTWNJ21", "78987", "VfModularity/VolumeGroup.xml");
87                 mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml");
88                 mockSDNCAdapter("/SDNCAdapter", "SvcInstanceId><", 200, "VfModularity/StandardSDNCSynchResponse.xml");
89                 mockVNFPut("skask", "/supercool", 202);
90                 MockPutGenericVnf("skask");
91                 MockGetGenericVnfByIdWithPriority("skask", "supercool", 200, "VfModularity/VfModule-supercool.xml", 1);
92                 
93                 String businessKey = UUID.randomUUID().toString();
94                 Map<String, Object> variables = new HashMap<String, Object>();
95                 variables.put("mso-request-id", "DEV-VF-0011");
96                 variables.put("isDebugLogEnabled","true");
97                 variables.put("DoUpdateVfModuleRequest", doUpdateVfModuleRequest);
98                 invokeSubProcess("DoUpdateVfModule", businessKey, variables);
99                 
100                 injectSDNCCallbacks(callbacks, "changeassign, query");
101                 injectVNFRestCallbacks(callbacks, "vnfUpdate");
102                 injectSDNCCallbacks(callbacks, "activate");
103
104                 waitForProcessEnd(businessKey, 10000);
105                 
106                 Assert.assertTrue(isProcessEnded(businessKey));
107                 checkVariable(businessKey, "DoUpdateVfModuleSuccessIndicator", true);
108                 
109                 String heatStackId = (String) getVariableFromHistory(businessKey, "DOUPVfMod_heatStackId");
110                 System.out.println("Heat stack Id from AAI: " + heatStackId);
111                 
112                 logEnd();
113         }
114 }
115