1 package org.openecomp.mso.bpmn.infrastructure.scripts
\r
3 import org.camunda.bpm.engine.ProcessEngineServices
\r
4 import org.camunda.bpm.engine.RepositoryService
\r
5 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
\r
6 import org.camunda.bpm.engine.repository.ProcessDefinition
\r
7 import org.camunda.bpm.engine.runtime.Execution
\r
8 import org.junit.Before
\r
9 import org.junit.Rule
\r
10 import org.junit.Test
\r
11 import org.mockito.MockitoAnnotations
\r
12 import org.openecomp.mso.bpmn.common.scripts.MsoUtils
\r
13 import org.openecomp.mso.bpmn.core.WorkflowException
\r
14 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
15 import org.openecomp.mso.bpmn.common.scripts.VidUtils
\r
17 import static org.junit.Assert.*;
\r
18 import static org.mockito.Mockito.*
\r
20 import com.github.tomakehurst.wiremock.junit.WireMockRule
\r
22 class CreateGenericAlaCarteServiceInstanceTest {
\r
25 public WireMockRule wireMockRule = new WireMockRule(8090);
\r
27 String Prefix="CRENI_"
\r
28 def utils = new MsoUtils()
\r
29 JsonUtils jsonUtil = new JsonUtils()
\r
30 VidUtils vidUtils = new VidUtils()
\r
32 String createDBRequestError =
\r
33 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
\r
36 <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
37 <requestId>88f65519-9a38-4c4b-8445-9eb4a5a5af56</requestId>
\r
38 <lastModifiedBy>BPMN</lastModifiedBy>
\r
39 <statusMessage>Received error from SDN-C: No availability zone available</statusMessage>
\r
40 <responseBody></responseBody>
\r
41 <requestStatus>FAILED</requestStatus>
\r
42 <vnfOutputs><network-id></network-id><network-name></network-names></vnfOutputs>
\r
43 </ns:updateInfraRequest>
\r
45 </soapenv:Envelope>"""
\r
47 String falloutHandlerRequest =
\r
48 """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
49 xmlns:ns="http://org.openecomp/mso/request/types/v1"
\r
50 xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
\r
51 <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
\r
52 <request-id>b69c9054-da09-4a2c-adf5-51042b62bfac</request-id>
\r
53 <action>CREATE</action>
\r
54 <source>VID</source>
\r
56 <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
\r
57 <aetgt:ErrorMessage>Received error from SDN-C: No availability zone available.</aetgt:ErrorMessage>
\r
58 <aetgt:ErrorCode>5300</aetgt:ErrorCode>
\r
59 </aetgt:WorkflowException>
\r
60 </aetgt:FalloutHandlerRequest>"""
\r
62 String jsonIncomingRequest =
\r
66 "description": "so_test2",
\r
67 "serviceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561519",
\r
68 "templateId": "592f9437-a9c0-4303-b9f6-c445bb7e9814",
\r
70 "globalSubscriberId": "123457",
\r
71 "subscriberName": "Customer1",
\r
72 "serviceType": "voLTE",
\r
73 "templateName": "voLTE Service:1.0",
\r
76 "resourceName": "vIMS",
\r
77 "resourceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561516",
\r
78 "resourceId": "60c3e96e-0970-4871-b6e0-3b6de7561512",
\r
80 "locationConstraints": [
\r
82 "vnfProfileId": "zte-vBAS-1.0",
\r
83 "locationConstraints": {
\r
84 "vimId": "4050083f-465f-4838-af1e-47a545222ad0"
\r
88 "vnfProfileId": "zte-vMME-1.0",
\r
89 "locationConstraints": {
\r
90 "vimId": "4050083f-465f-4838-af1e-47a545222ad0"
\r
94 "additionalParamForNs": {}
\r
98 "resourceName": "vEPC",
\r
99 "resourceDefId": "61c3e96e-0970-4871-b6e0-3b6de7561516",
\r
100 "resourceId": "62c3e96e-0970-4871-b6e0-3b6de7561512",
\r
102 "locationConstraints": [
\r
104 "vnfProfileId": "zte-CSCF-1.0",
\r
105 "locationConstraints": {
\r
106 "vimId": "4050083f-465f-4838-af1e-47a545222ad1"
\r
110 "additionalParamForNs": {}
\r
114 "resourceName": "underlayvpn",
\r
115 "resourceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561513",
\r
116 "resourceId": "60c3e96e-0970-4871-b6e0-3b6de7561514",
\r
118 "locationConstraints": [],
\r
119 "additionalParamForNs": {
\r
120 "externalDataNetworkName": "Flow_out_net",
\r
121 "m6000_mng_ip": "181.18.20.2",
\r
122 "externalCompanyFtpDataNetworkName": "Flow_out_net",
\r
123 "externalPluginManageNetworkName": "plugin_net_2014",
\r
124 "externalManageNetworkName": "mng_net_2017",
\r
125 "sfc_data_network": "sfc_data_net_2016",
\r
126 "NatIpRange": "210.1.1.10-210.1.1.20",
\r
127 "location": "4050083f-465f-4838-af1e-47a545222ad0",
\r
128 "sdncontroller": "9b9f02c0-298b-458a-bc9c-be3692e4f35e"
\r
133 "resourceName": "overlayvpn",
\r
134 "resourceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561517",
\r
135 "resourceId": "60c3e96e-0970-4871-b6e0-3b6de7561518",
\r
137 "locationConstraints": [],
\r
138 "additionalParamForNs": {
\r
139 "externalDataNetworkName": "Flow_out_net",
\r
140 "m6000_mng_ip": "181.18.20.2",
\r
141 "externalCompanyFtpDataNetworkName": "Flow_out_net",
\r
142 "externalPluginManageNetworkName": "plugin_net_2014",
\r
143 "externalManageNetworkName": "mng_net_2017",
\r
144 "sfc_data_network": "sfc_data_net_2016",
\r
145 "NatIpRange": "210.1.1.10-210.1.1.20",
\r
146 "location": "4050083f-465f-4838-af1e-47a545222ad0",
\r
147 "sdncontroller": "9b9f02c0-298b-458a-bc9c-be3692e4f35e"
\r
159 MockitoAnnotations.initMocks(this)
\r
163 public void initializeVariables(Execution mockExecution) {
\r
165 verify(mockExecution).setVariable(Prefix + "Success", false)
\r
167 verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "")
\r
168 verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "")
\r
169 verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false)
\r
175 public void preProcessRequest() {
\r
177 println "************ preProcessRequest() ************* "
\r
178 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
\r
179 // Initialize prerequisite variables
\r
180 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
\r
181 when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest)
\r
184 // preProcessRequest(Execution execution)
\r
185 CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance()
\r
186 createGenericALaCarteServiceInstance.preProcessRequest(mockExecution)
\r
188 verify(mockExecution).getVariable("isDebugLogEnabled")
\r
189 verify(mockExecution).setVariable("prefix", Prefix)
\r
191 initializeVariables(mockExecution)
\r
192 //verify(mockExecution).setVariable(Prefix + "Success", false)
\r
193 }catch(Exception e){
\r