1550df1f98c25a1a7df6d1cefb135cb016021e87
[so.git] /
1 package org.openecomp.mso.bpmn.infrastructure.scripts\r
2 \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
16 \r
17 import static org.junit.Assert.*;\r
18 import static org.mockito.Mockito.*\r
19 \r
20 import com.github.tomakehurst.wiremock.junit.WireMockRule\r
21 \r
22 class CreateGenericAlaCarteServiceInstanceTest  {\r
23         \r
24         @Rule\r
25         public WireMockRule wireMockRule = new WireMockRule(8090);\r
26         \r
27                 String Prefix="CRENI_"\r
28                 def utils = new MsoUtils()\r
29                 JsonUtils jsonUtil = new JsonUtils()\r
30                 VidUtils vidUtils = new VidUtils()\r
31         \r
32 \r
33 String jsonIncomingRequest =\r
34 """{\r
35   "service": {\r
36     "name": "so_test4",\r
37     "description": "so_test2",\r
38     "serviceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561519",\r
39     "templateId": "592f9437-a9c0-4303-b9f6-c445bb7e9814",\r
40     "parameters": {\r
41       "globalSubscriberId": "123457",\r
42       "subscriberName": "Customer1",\r
43       "serviceType": "voLTE",\r
44       "templateName": "voLTE Service:1.0",\r
45       "resources": [\r
46         {\r
47           "resourceName": "vIMS",\r
48           "resourceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561516",\r
49           "resourceId": "60c3e96e-0970-4871-b6e0-3b6de7561512",\r
50           "nsParameters": {\r
51             "locationConstraints": [\r
52               {\r
53                 "vnfProfileId": "zte-vBAS-1.0",\r
54                 "locationConstraints": {\r
55                   "vimId": "4050083f-465f-4838-af1e-47a545222ad0"\r
56                 }\r
57               },\r
58               {\r
59                 "vnfProfileId": "zte-vMME-1.0",\r
60                 "locationConstraints": {\r
61                   "vimId": "4050083f-465f-4838-af1e-47a545222ad0"\r
62                 }\r
63               }\r
64             ],\r
65             "additionalParamForNs": {}\r
66           }\r
67         },\r
68         {\r
69           "resourceName": "vEPC",\r
70           "resourceDefId": "61c3e96e-0970-4871-b6e0-3b6de7561516",\r
71           "resourceId": "62c3e96e-0970-4871-b6e0-3b6de7561512",\r
72           "nsParameters": {\r
73             "locationConstraints": [\r
74               {\r
75                 "vnfProfileId": "zte-CSCF-1.0",\r
76                 "locationConstraints": {\r
77                   "vimId": "4050083f-465f-4838-af1e-47a545222ad1"\r
78                 }\r
79               }\r
80             ],\r
81             "additionalParamForNs": {}\r
82           }\r
83         },\r
84         {\r
85           "resourceName": "underlayvpn",\r
86           "resourceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561513",\r
87           "resourceId": "60c3e96e-0970-4871-b6e0-3b6de7561514",\r
88           "nsParameters": {\r
89             "locationConstraints": [],\r
90             "additionalParamForNs": {\r
91               "externalDataNetworkName": "Flow_out_net",\r
92               "m6000_mng_ip": "181.18.20.2",\r
93               "externalCompanyFtpDataNetworkName": "Flow_out_net",\r
94               "externalPluginManageNetworkName": "plugin_net_2014",\r
95               "externalManageNetworkName": "mng_net_2017",\r
96               "sfc_data_network": "sfc_data_net_2016",\r
97               "NatIpRange": "210.1.1.10-210.1.1.20",\r
98               "location": "4050083f-465f-4838-af1e-47a545222ad0",\r
99               "sdncontroller": "9b9f02c0-298b-458a-bc9c-be3692e4f35e"\r
100             }\r
101           }\r
102         },\r
103         {\r
104           "resourceName": "overlayvpn",\r
105           "resourceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561517",\r
106           "resourceId": "60c3e96e-0970-4871-b6e0-3b6de7561518",\r
107           "nsParameters": {\r
108             "locationConstraints": [],\r
109             "additionalParamForNs": {\r
110               "externalDataNetworkName": "Flow_out_net",\r
111               "m6000_mng_ip": "181.18.20.2",\r
112               "externalCompanyFtpDataNetworkName": "Flow_out_net",\r
113               "externalPluginManageNetworkName": "plugin_net_2014",\r
114               "externalManageNetworkName": "mng_net_2017",\r
115               "sfc_data_network": "sfc_data_net_2016",\r
116               "NatIpRange": "210.1.1.10-210.1.1.20",\r
117               "location": "4050083f-465f-4838-af1e-47a545222ad0",\r
118               "sdncontroller": "9b9f02c0-298b-458a-bc9c-be3692e4f35e"\r
119             }\r
120           }\r
121         }\r
122       ]\r
123     }\r
124   }\r
125 }"""\r
126 \r
127             @Before\r
128                 public void init()\r
129                 {\r
130                         MockitoAnnotations.initMocks(this)\r
131                         \r
132                 }\r
133 \r
134                 public void initializeVariables(Execution mockExecution) {\r
135                         \r
136                         verify(mockExecution).setVariable(Prefix + "Success", false)\r
137                         \r
138                         verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "")\r
139                         verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "")\r
140                         verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false)\r
141                                 \r
142                 }\r
143                                 \r
144                 @Test\r
145                 //@Ignore  \r
146                 public void preProcessRequest() {\r
147                         \r
148                         println "************ preProcessRequest() ************* " \r
149                         ExecutionEntity mockExecution = mock(ExecutionEntity.class)\r
150                         // Initialize prerequisite variables\r
151                         when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")\r
152                         when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest)\r
153                         try{\r
154                                                                         \r
155                                 // preProcessRequest(Execution execution)                                               \r
156                                 CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance()\r
157                                 createGenericALaCarteServiceInstance.preProcessRequest(mockExecution)\r
158 \r
159                                 verify(mockExecution).getVariable("isDebugLogEnabled")\r
160                                 verify(mockExecution).setVariable("prefix", Prefix)\r
161                         \r
162                                 initializeVariables(mockExecution)\r
163                                 //verify(mockExecution).setVariable(Prefix + "Success", false)\r
164                         }catch(Exception e){\r
165                                 //ignore\r
166                         }                       \r
167                 }\r
168                 }