b73ad7ab1c7bc501120a1eb352ded346939b49ce
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / common / GenericGetServiceTest.java
1 /*\r
2  * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.\r
3  */\r
4 /*- \r
5  * ============LICENSE_START======================================================= \r
6  * OPENECOMP - MSO \r
7  * ================================================================================ \r
8  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. \r
9  * ================================================================================ \r
10  * Licensed under the Apache License, Version 2.0 (the "License"); \r
11  * you may not use this file except in compliance with the License. \r
12  * You may obtain a copy of the License at \r
13  * \r
14  *      http://www.apache.org/licenses/LICENSE-2.0 \r
15  * \r
16  * Unless required by applicable law or agreed to in writing, software \r
17  * distributed under the License is distributed on an "AS IS" BASIS, \r
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
19  * See the License for the specific language governing permissions and \r
20  * limitations under the License. \r
21  * ============LICENSE_END========================================================= \r
22  */ \r
23 \r
24 package org.openecomp.mso.bpmn.common;\r
25 \r
26 import static org.junit.Assert.assertEquals;\r
27 import static org.junit.Assert.assertNotNull;\r
28 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;\r
29 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;\r
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;\r
31 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404;\r
32 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500;\r
33 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription;\r
34 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;\r
35 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_404;\r
36 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_500;\r
37 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName;\r
38 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_404;\r
39 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_500;\r
40 \r
41 import java.util.HashMap;\r
42 import java.util.Map;\r
43 \r
44 import org.camunda.bpm.engine.test.Deployment;\r
45 import org.junit.Test;\r
46 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;\r
47 \r
48 \r
49 /**\r
50  * Unit Test for the GenericGetService Sub Flow\r
51  */\r
52 public class GenericGetServiceTest extends WorkflowTest {\r
53 \r
54 \r
55         @Test\r
56         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
57         public void testGenericGetService_success_serviceInstance() throws Exception{\r
58                 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");\r
59                 Map<String, String> variables = new HashMap<String, String>();\r
60                 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789");\r
61                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
62                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
63                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
64                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
65                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
66                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
67                 String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");\r
68                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
69                 assertEquals("true", successIndicator);\r
70                 assertEquals("true", found);\r
71                 assertEquals("false", obtainUrl);\r
72                 assertEquals("false", byName);\r
73                 assertNotNull(response);\r
74                 assertEquals(null, workflowException);\r
75         }\r
76 \r
77 \r
78         @Test\r
79         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
80         public void testGenericGetService_success_serviceSubscription() throws Exception{\r
81 \r
82                 MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml");\r
83 \r
84                 Map<String, String> variables = new HashMap<String, String>();\r
85                 setVariablesSubscription(variables, "", null , "1604-MVM-26", "SDN-ETHERNET-INTERNET");\r
86 \r
87                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
88                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
89 \r
90                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
91                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
92                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
93                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
94                 String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");\r
95                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
96 \r
97                 assertEquals("true", successIndicator);\r
98                 assertEquals("true", found);\r
99                 assertEquals("false", obtainUrl);\r
100                 assertEquals("false", byName);\r
101                 assertNotNull(response);\r
102                 assertEquals(null, workflowException);\r
103         }\r
104 \r
105         @Test\r
106         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
107         public void testGenericGetService_success_serviceInstance_byName() throws Exception{\r
108 \r
109                 MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByName.xml");\r
110                 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");\r
111 \r
112                 Map<String, String> variables = new HashMap<String, String>();\r
113                 setVariablesInstance(variables, null, "1604-MVM-26", null, null);\r
114 \r
115                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
116                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
117 \r
118                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
119                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
120                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
121                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
122                 String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");\r
123                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
124                 String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");\r
125 \r
126                 assertEquals("true", successIndicator);\r
127                 assertEquals("true", found);\r
128                 assertEquals("true", obtainUrl);\r
129                 assertEquals("true", byName);\r
130                 assertNotNull(response);\r
131                 assertEquals("200", siUrlResponseCode);\r
132                 assertEquals(null, workflowException);\r
133         }\r
134 \r
135         @Test\r
136         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
137         public void testGenericGetService_success_serviceInstance_byId() throws Exception{\r
138 \r
139                 MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlById.xml");\r
140                 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");\r
141 \r
142                 Map<String, String> variables = new HashMap<String, String>();\r
143                 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);\r
144 \r
145                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
146                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
147 \r
148                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
149                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
150                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
151                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
152                 String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");\r
153                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
154                 String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode");\r
155 \r
156                 assertEquals("true", successIndicator);\r
157                 assertEquals("true", found);\r
158                 assertEquals("true", obtainUrl);\r
159                 assertEquals("false", byName);\r
160                 assertNotNull(response);\r
161                 assertEquals("200", siUrlResponseCode);\r
162                 assertEquals(null, workflowException);\r
163         }\r
164 \r
165         @Test\r
166         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
167         public void testGenericGetService_success_serviceInstance_404Response() throws Exception{\r
168 \r
169                 MockGetServiceInstance_404("SDN-ETHERNET-INTERNET", "123456789", "MIS%2F1604%2F0026%2FSW_INTERNET");\r
170 \r
171                 Map<String, String> variables = new HashMap<String, String>();\r
172                 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789");\r
173 \r
174                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
175                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
176 \r
177                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
178                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
179                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
180                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
181                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
182 \r
183                 assertEquals("true", successIndicator);\r
184                 assertEquals("false", found);\r
185                 assertEquals("false", obtainUrl);\r
186                 assertEquals("false", byName);\r
187                 assertEquals(null, workflowException);\r
188         }\r
189 \r
190         @Test\r
191         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
192         public void testGenericGetService_success_serviceSubscription404() throws Exception{\r
193                 MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", 404);\r
194                 \r
195                 Map<String, String> variables = new HashMap<String, String>();\r
196                 setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", "1604-MVM-26");\r
197 \r
198                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
199                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
200 \r
201                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
202                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
203                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
204                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
205                 String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");\r
206                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
207 \r
208                 assertEquals("true", successIndicator);\r
209                 assertEquals("false", found);\r
210                 assertEquals("false", obtainUrl);\r
211                 assertEquals("false", byName);\r
212                 assertNotNull(response);\r
213                 assertEquals(null, workflowException);\r
214         }\r
215 \r
216         @Test\r
217         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
218         public void testGenericGetService_success_serviceInstanceByName404() throws Exception{\r
219 \r
220                 MockNodeQueryServiceInstanceByName_404("1604-MVM-26");\r
221 \r
222                 Map<String, String> variables = new HashMap<String, String>();\r
223                 setVariablesInstance(variables, "", "1604-MVM-26", null, null);\r
224 \r
225                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
226                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
227 \r
228                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
229                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
230                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
231                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
232                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
233                 String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");\r
234 \r
235                 assertEquals("true", successIndicator);\r
236                 assertEquals("false", found);\r
237                 assertEquals("true", obtainUrl);\r
238                 assertEquals("true", byName);\r
239                 assertEquals("404", siUrlResponseCode);\r
240                 assertEquals(null, workflowException);\r
241         }\r
242 \r
243         @Test\r
244         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
245         public void testGenericGetService_success_serviceInstanceById404() throws Exception{\r
246 \r
247                 MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET");\r
248 \r
249                 Map<String, String> variables = new HashMap<String, String>();\r
250                 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);\r
251 \r
252                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
253                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
254 \r
255                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
256                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
257                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
258                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
259                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
260                 String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode");\r
261 \r
262                 assertEquals("true", successIndicator);\r
263                 assertEquals("false", found);\r
264                 assertEquals("true", obtainUrl);\r
265                 assertEquals("false", byName);\r
266                 assertEquals("404", siUrlResponseCode);\r
267                 assertEquals(null, workflowException);\r
268         }\r
269 \r
270         @Test\r
271         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
272         public void testGenericGetService_success_serviceInstanceEmptyResponse() throws Exception{\r
273 \r
274                 MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", " ");\r
275 \r
276                 Map<String, String> variables = new HashMap<String, String>();\r
277                 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789");\r
278 \r
279                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
280                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
281 \r
282                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
283                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
284                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
285                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
286                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
287 \r
288                 assertEquals("true", successIndicator);\r
289                 assertEquals("false", found);\r
290                 assertEquals("false", obtainUrl);\r
291                 assertEquals("false", byName);\r
292                 assertEquals(null, workflowException);\r
293         }\r
294 \r
295         @Test\r
296         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
297         public void testGenericGetService_success_serviceInstanceByNameEmpty() throws Exception{\r
298                 MockNodeQueryServiceInstanceByName("1604-MVM-26", "");\r
299                 \r
300                 Map<String, String> variables = new HashMap<String, String>();\r
301                 setVariablesInstance(variables, "", "1604-MVM-26", null, null);\r
302 \r
303                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
304                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
305 \r
306                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
307                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
308                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
309                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
310                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
311                 String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");\r
312 \r
313                 assertEquals("true", successIndicator);\r
314                 assertEquals("false", found);\r
315                 assertEquals("true", obtainUrl);\r
316                 assertEquals("true", byName);\r
317                 assertEquals("200", siUrlResponseCode);\r
318                 assertEquals(null, workflowException);\r
319         }\r
320 \r
321         @Test\r
322         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
323         public void testGenericGetService_success_serviceInstanceByIdEmpty() throws Exception{\r
324 \r
325                 MockNodeQueryServiceInstanceById("MIS[%]2F1604[%]2F0026[%]2FSW_INTERNET", "");\r
326 \r
327                 Map<String, String> variables = new HashMap<String, String>();\r
328                 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);\r
329 \r
330                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
331                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
332 \r
333                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
334                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
335                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
336                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
337                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
338                 String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode");\r
339 \r
340                 assertEquals("true", successIndicator);\r
341                 assertEquals("false", found);\r
342                 assertEquals("true", obtainUrl);\r
343                 assertEquals("false", byName);\r
344                 assertEquals("200", siUrlResponseCode);\r
345                 assertEquals(null, workflowException);\r
346         }\r
347 \r
348 \r
349         @Test\r
350         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
351         public void testGenericGetService_error_serviceInstanceInvalidVariables() throws Exception{\r
352 \r
353                 Map<String, String> variables = new HashMap<String, String>();\r
354                 setVariablesInstance(variables, null, null, "SDN-ETHERNET-INTERNET", null);\r
355 \r
356                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
357                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
358 \r
359                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
360                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
361                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
362                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
363                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
364 \r
365                 String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.]";\r
366 \r
367                 assertEquals("false", successIndicator);\r
368                 assertEquals("false", found);\r
369                 assertEquals("false", obtainUrl);\r
370                 assertEquals("false", byName);\r
371                 assertEquals(expectedWorkflowException, workflowException);\r
372         }\r
373 \r
374         @Test\r
375         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
376         public void testGenericGetService_success_serviceSubscriptionInvalidVariables() throws Exception{\r
377 \r
378                 Map<String, String> variables = new HashMap<String, String>();\r
379                 setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", null);\r
380 \r
381                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
382                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
383 \r
384                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
385                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
386                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
387                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
388                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
389 \r
390                 String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.]";\r
391 \r
392 \r
393                 assertEquals("false", successIndicator);\r
394                 assertEquals("false", found);\r
395                 assertEquals("false", obtainUrl);\r
396                 assertEquals("false", byName);\r
397                 assertEquals(expectedWorkflowException, workflowException);\r
398         }\r
399 \r
400         @Test\r
401         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
402         public void testGenericGetService_error_serviceInstance_getSIBadResponse() throws Exception{\r
403 \r
404                 MockGetServiceInstance_500("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET");\r
405 \r
406                 Map<String, String> variables = new HashMap<String, String>();\r
407                 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "123456789");\r
408 \r
409                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
410                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
411 \r
412                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
413                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
414                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
415                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
416                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
417 \r
418                 String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]";\r
419 \r
420                 assertEquals("false", successIndicator);\r
421                 assertEquals("false", found);\r
422                 assertEquals("false", obtainUrl);\r
423                 assertEquals("false", byName);\r
424                 assertEquals(expectedWorkflowException, workflowException);\r
425         }\r
426 \r
427         @Test\r
428         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
429         public void testGenericGetService_error_serviceInstance_getUrlByIdBadResponse() throws Exception{\r
430 \r
431                 MockNodeQueryServiceInstanceById_500("MIS%2F1604%2F0026%2FSW_INTERNET");\r
432 \r
433                 Map<String, String> variables = new HashMap<String, String>();\r
434                 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);\r
435 \r
436                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
437                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
438 \r
439                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
440                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
441                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
442                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
443                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
444                 String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode");\r
445 \r
446                 String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]";\r
447 \r
448                 assertEquals("false", successIndicator);\r
449                 assertEquals("false", found);\r
450                 assertEquals("true", obtainUrl);\r
451                 assertEquals("false", byName);\r
452                 assertEquals("500", siUrlResponseCode);\r
453                 assertEquals(expectedWorkflowException, workflowException);\r
454         }\r
455 \r
456         @Test\r
457         @Deployment(resources = {"subprocess/GenericGetService.bpmn"})\r
458         public void testGenericGetService_error_serviceInstance_getUrlByNameBadResponse() throws Exception{\r
459 \r
460                 MockNodeQueryServiceInstanceByName_500("1604-MVM-26");\r
461 \r
462                 Map<String, String> variables = new HashMap<String, String>();\r
463                 setVariablesInstance(variables, null, "1604-MVM-26", null, null);\r
464 \r
465                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);\r
466                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
467 \r
468                 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");\r
469                 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");\r
470                 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");\r
471                 String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");\r
472                 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");\r
473                 String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");\r
474 \r
475                 String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]";\r
476 \r
477                 assertEquals("false", successIndicator);\r
478                 assertEquals("false", found);\r
479                 assertEquals("true", obtainUrl);\r
480                 assertEquals("true", byName);\r
481                 assertEquals("500", siUrlResponseCode);\r
482                 assertEquals(expectedWorkflowException, workflowException);\r
483         }\r
484 \r
485 \r
486         private void setVariablesInstance(Map<String, String> variables, String siId, String siName, String globalCustId, String serviceType) {\r
487                 variables.put("isDebugLogEnabled", "true");\r
488                 variables.put("GENGS_serviceInstanceId", siId);\r
489                 variables.put("GENGS_serviceInstanceName", siName);\r
490                 variables.put("GENGS_globalCustomerId",globalCustId);\r
491                 variables.put("GENGS_serviceType", serviceType);\r
492                 variables.put("GENGS_type", "service-instance");\r
493         }\r
494 \r
495         private void setVariablesSubscription(Map<String, String> variables, String siId, String siName, String globalCustId, String serviceType) {\r
496                 variables.put("isDebugLogEnabled", "true");\r
497                 variables.put("GENGS_serviceInstanceId", siId);\r
498                 variables.put("GENGS_serviceInstanceName", siName);\r
499                 variables.put("GENGS_globalCustomerId",globalCustId);\r
500                 variables.put("GENGS_serviceType", serviceType);\r
501                 variables.put("GENGS_type", "service-subscription");\r
502         }\r
503 \r
504 \r
505 }\r