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