[MSO-8] Update the maven dependency
[so.git] / bpmn / MSOInfrastructureBPMN / src / test / java / org / openecomp / mso / bpmn / infrastructure / DoCreateVfModuleTest.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
24 import static org.openecomp.mso.bpmn.common.BPMNUtil.getRawVariable;
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.MockPutGenericVnf;
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
30 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
31 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
32 import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPost;
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 DoCreateVfModuleTest.bpmn.
48  */
49 public class DoCreateVfModuleTest extends WorkflowTest {
50         
51         private final CallbackSet callbacks = new CallbackSet();
52
53         public DoCreateVfModuleTest() throws IOException {
54                 callbacks.put("assign", FileUtil.readResourceFile(
55                         "__files/VfModularity/SDNCTopologyAssignCallback.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("vnfCreate", FileUtil.readResourceFile(
61                         "__files/VfModularity/VNFAdapterRestCreateCallback.xml"));
62         }
63
64         /**
65          * Test the sunny day scenario.
66          */
67         @Test   
68         
69         @Deployment(resources = {
70                         "subprocess/DoCreateVfModule.bpmn",
71                         "subprocess/SDNCAdapterV1.bpmn",
72                         "subprocess/VnfAdapterRestV1.bpmn",
73                         "subprocess/ConfirmVolumeGroupTenant.bpmn",
74                         "subprocess/ConfirmVolumeGroupName.bpmn",
75                         "subprocess/CreateAAIVfModule.bpmn",
76                         "subprocess/UpdateAAIVfModule.bpmn",
77                         "subprocess/CreateAAIVfModuleVolumeGroup.bpmn",
78                         "subprocess/UpdateAAIGenericVnf.bpmn"
79                 })
80         public void sunnyDay() throws IOException {
81                 
82                 logStart();
83                 
84                 MockGetGenericVnfByIdWithPriority("skask", ".*", 200, "VfModularity/VfModule-new.xml", 5);
85                 MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
86                 MockPutVfModuleIdNoResponse("skask", "PCRF", ".*");
87                 MockPutNetwork(".*", "VfModularity/AddNetworkPolicy_AAIResponse_Success.xml", 200);
88                 MockPutGenericVnf("skask");
89                 mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml");
90                 mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml");
91                 mockVNFPost("", 202, "skask");
92                 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
93                 
94                 String businessKey = UUID.randomUUID().toString();
95                 //RuntimeService runtimeService = processEngineRule.getRuntimeService();                                
96                 
97                 Map<String, Object> variables = setupVariablesSunnyDayBuildingBlocks();
98                 //runtimeService.startProcessInstanceByKey("DoCreateVfModule", variables);
99                 invokeSubProcess("DoCreateVfModule", businessKey, variables);
100                 
101                 injectSDNCCallbacks(callbacks, "assign, query");
102                 injectVNFRestCallbacks(callbacks, "vnfCreate");
103                 injectSDNCCallbacks(callbacks, "activate");
104
105                 waitForProcessEnd(businessKey, 10000);
106                 
107                 Assert.assertTrue(isProcessEnded(businessKey));
108                 Assert.assertTrue((boolean) getRawVariable(processEngineRule, "DoCreateVfModule", "DCVFM_SuccessIndicator"));
109                 
110                 logEnd();
111         }
112         
113         private Map<String, Object> setupVariablesSunnyDayBuildingBlocks() {
114                 Map<String, Object> variables = new HashMap<String, Object>();
115                 
116                 variables.put("mso-request-id", "testRequestId");
117                 variables.put("requestId", "testRequestId");            
118                 variables.put("isBaseVfModule", false);
119                 variables.put("isDebugLogEnabled", "true");
120                 variables.put("disableRollback", "true");
121                 //variables.put("recipeTimeout", "0");          
122                 //variables.put("requestAction", "CREATE_VF_MODULE");
123                 variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4");
124                 variables.put("vnfId", "skask");
125                 variables.put("vfModuleName", "PCRF::module-0-2");
126                 variables.put("vnfType", "vSAMP12");
127                 variables.put("vfModuleId", "");
128                 variables.put("volumeGroupId", "");                     
129                 variables.put("serviceType", "MOG");    
130                 variables.put("vfModuleType", "");
131                 variables.put("isVidRequest", "true");
132                 variables.put("asdcServiceModelVersion", "1.0");
133                                         
134                 String vfModuleModelInfo = "{" + "\"modelInfo\": { "+ "\"modelType\": \"vfModule\"," +
135                         "\"modelInvariantId\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + 
136                         "\"modelNameVersionId\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," +
137                         "\"modelName\": \"STMTN5MMSC21-MMSC::model-1-0\"," +
138                         "\"modelVersion\": \"1\"," + 
139                         "\"modelCustomizationId\": \"MODEL-123\"" + "}}";
140                 variables.put("vfModuleModelInfo", vfModuleModelInfo);
141                 
142                 String cloudConfiguration = "{" + "\"cloudConfiguration\": { " + 
143                                 "\"lcpCloudRegionId\": \"MDTWNJ21\"," +         
144                                 "\"tenantId\": \"fba1bd1e195a404cacb9ce17a9b2b421\"" + "}}";
145                 variables.put("cloudConfiguration", cloudConfiguration);
146                 return variables;
147                 
148         }
149 }