[MSO-8] Update the maven dependency
[so.git] / bpmn / MSOInfrastructureBPMN / src / test / java / org / openecomp / mso / bpmn / infrastructure / UpdateVfModuleInfraTest.java
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 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;
29
30 import java.io.IOException;
31 import java.util.HashMap;
32 import java.util.Map;
33 import java.util.UUID;
34
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;
40
41 /**
42  * Unit test cases for UpdateVfModule.bpmn
43  */
44 public class UpdateVfModuleInfraTest extends WorkflowTest {
45         
46         private final CallbackSet callbacks = new CallbackSet();
47
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"));
57         }
58         
59         /**
60          * Sunny day scenario.
61          * 
62          * @throws Exception
63          */
64         @Test
65         
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"
77                 })
78         public void sunnyDay() throws Exception {
79                                 
80                 logStart();
81                 
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");
90                 
91                 String businessKey = UUID.randomUUID().toString();
92                 String updaetVfModuleRequest =
93                         FileUtil.readResourceFile("__files/InfrastructureFlows/UpdateVfModule_VID_request.json");
94                 
95                 Map<String, Object> variables = setupVariablesSunnyDayVID();
96                 
97                 
98                 TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleInfra",
99                         "v1", businessKey, updaetVfModuleRequest, variables);
100                 
101                 WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000);
102                 
103                 String responseBody = response.getResponse();
104                 System.out.println("Workflow (Synch) Response:\n" + responseBody);
105                 
106                 injectSDNCCallbacks(callbacks, "changeassign, query");
107                 injectVNFRestCallbacks(callbacks, "vnfUpdate");
108                 injectSDNCCallbacks(callbacks, "activate");
109                 
110                 // TODO add appropriate assertions
111
112                 waitForProcessEnd(businessKey, 10000);
113                 checkVariable(businessKey, "UpdateVfModuleInfraSuccessIndicator", true);
114                 
115                 logEnd();
116         }
117         
118         // Active Scenario
119         private Map<String, Object> setupVariablesSunnyDayVID() {
120                                 Map<String, Object> variables = new HashMap<String, Object>();
121                                 //try {
122                                 //      variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
123                                 //}
124                                 //catch (Exception e) {
125                                         
126                                 //}
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", "");                      
140                                 return variables;
141                                 
142                         }
143         
144 }