2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.common;
24 import org.junit.Ignore;
25 import org.junit.Test;
26 import org.onap.so.BaseIntegrationTest;
27 import org.onap.so.bpmn.core.WorkflowException;
28 import org.onap.so.bpmn.core.domain.AllottedResource;
29 import org.onap.so.bpmn.core.domain.HomingSolution;
30 import org.onap.so.bpmn.core.domain.ModelInfo;
31 import org.onap.so.bpmn.core.domain.NetworkResource;
32 import org.onap.so.bpmn.core.domain.Resource;
33 import org.onap.so.bpmn.core.domain.ServiceDecomposition;
34 import org.onap.so.bpmn.core.domain.ServiceInstance;
35 import org.onap.so.bpmn.core.domain.VnfResource;
36 import org.onap.so.bpmn.mock.FileUtil;
37 import org.onap.so.logger.MsoLogger;
39 import java.io.IOException;
40 import java.util.ArrayList;
41 import java.util.HashMap;
42 import java.util.List;
44 import java.util.UUID;
46 import static org.junit.Assert.assertEquals;
47 import static org.junit.Assert.assertNull;
48 import static org.onap.so.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid;
49 import static org.onap.so.bpmn.mock.StubResponseOof.mockOof;
50 import static org.onap.so.bpmn.mock.StubResponseOof.mockOof_500;
54 * Test the OOF Homing subflow building block.
57 public class OofHomingTestIT extends BaseIntegrationTest {
59 MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CreateAAIVfModuleIT.class);
61 ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
62 String subscriber = "";
63 String subscriber2 = "";
65 private final CallbackSet callbacks = new CallbackSet();
67 public OofHomingTestIT() throws IOException {
68 String oofCallback = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackInfraVnf");
69 String oofCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf");
70 String oofCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf2Net");
72 String oofCallbackNoSolution = FileUtil.
73 readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound");
74 String oofCallbackPolicyException = FileUtil.
75 readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException");
76 String oofCallbackServiceException = FileUtil.
77 readResourceFile("__files/BuildingBlocks/oofCallbackServiceException");
79 callbacks.put("oof", JSON, "oofResponse", oofCallback);
80 callbacks.put("oof2", JSON, "oofResponse", oofCallback2);
81 callbacks.put("oof3", JSON, "oofResponse", oofCallback3);
82 callbacks.put("oofNoSol", JSON, "oofResponse", oofCallbackNoSolution);
83 callbacks.put("oofPolicyEx", JSON, "oofResponse", oofCallbackPolicyException);
84 callbacks.put("oofServiceEx", JSON, "oofResponse", oofCallbackServiceException);
87 ModelInfo sModel = new ModelInfo();
88 sModel.setModelCustomizationName("testModelCustomizationName");
89 sModel.setModelInstanceName("testModelInstanceName");
90 sModel.setModelInvariantUuid("testModelInvariantId");
91 sModel.setModelName("testModelName");
92 sModel.setModelUuid("testModelUuid");
93 sModel.setModelVersion("testModelVersion");
95 ServiceInstance si = new ServiceInstance();
96 si.setInstanceId("testServiceInstanceId123");
98 List<AllottedResource> arList = new ArrayList<AllottedResource>();
99 AllottedResource ar = new AllottedResource();
100 ar.setResourceId("testResourceIdAR");
101 ar.setResourceInstanceName("testARInstanceName");
102 ModelInfo arModel = new ModelInfo();
103 arModel.setModelCustomizationUuid("testModelCustomizationUuidAR");
104 arModel.setModelInvariantUuid("testModelInvariantIdAR");
105 arModel.setModelName("testModelNameAR");
106 arModel.setModelVersion("testModelVersionAR");
107 arModel.setModelUuid("testARModelUuid");
108 arModel.setModelType("testModelTypeAR");
109 ar.setModelInfo(arModel);
110 AllottedResource ar2 = new AllottedResource();
111 ar2.setResourceId("testResourceIdAR2");
112 ar2.setResourceInstanceName("testAR2InstanceName");
113 ModelInfo arModel2 = new ModelInfo();
114 arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2");
115 arModel2.setModelInvariantUuid("testModelInvariantIdAR2");
116 arModel2.setModelName("testModelNameAR2");
117 arModel2.setModelVersion("testModelVersionAR2");
118 arModel2.setModelUuid("testAr2ModelUuid");
119 arModel2.setModelType("testModelTypeAR2");
120 ar2.setModelInfo(arModel2);
124 List<VnfResource> vnfList = new ArrayList<VnfResource>();
125 VnfResource vnf = new VnfResource();
126 vnf.setResourceId("testResourceIdVNF");
127 vnf.setResourceInstanceName("testVnfInstanceName");
128 vnf.getHomingSolution().setOofDirectives(
130 " \"directives\":[ \n" +
132 " \"vnfc_directives\":[ \n" +
134 " \"vnfc_id\":\"<ID of VNFC>\",\n" +
135 " \"directives\":[ \n" +
137 " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
138 " \"attributes\":[ \n" +
140 " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
141 " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
146 " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
147 " \"attributes\":[ \n" +
149 " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
150 " \"attribute_value\":\"<value such as direct/normal>\"\n" +
153 " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
154 " \"attribute_value\":\"<value such as physnet>\"\n" +
163 " \"vnf_directives\":{ \n" +
164 " \"directives\":[ \n" +
166 " \"directive_name\":\"<Name of directive>\",\n" +
167 " \"attributes\":[ \n" +
169 " \"attribute_name\":\"<name of attribute>\",\n" +
170 " \"attribute_value\":\"<value>\"\n" +
175 " \"directive_name\":\"<Name of directive>\",\n" +
176 " \"attributes\":[ \n" +
178 " \"attribute_name\":\"<name of attribute>\",\n" +
179 " \"attribute_value\":\"<value >\"\n" +
182 " \"attribute_name\":\"<name of attribute>\",\n" +
183 " \"attribute_value\":\"<value >\"\n" +
192 " \"sdnc_directives\":{ \n" +
193 " \"directives\":[ \n" +
195 " \"vnfc_directives\":[ \n" +
197 " \"vnfc_id\":\"<ID of VNFC>\",\n" +
198 " \"directives\":[ \n" +
200 " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
201 " \"attributes\":[ \n" +
203 " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
204 " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
209 " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
210 " \"attributes\":[ \n" +
212 " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
213 " \"attribute_value\":\"<value such as direct/normal>\"\n" +
216 " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
217 " \"attribute_value\":\"<value such as physnet>\"\n" +
226 " \"vnf_directives\":{ \n" +
227 " \"directives\":[ \n" +
229 " \"directive_name\":\"<Name of directive>\",\n" +
230 " \"attributes\":[ \n" +
232 " \"attribute_name\":\"<name of attribute>\",\n" +
233 " \"attribute_value\":\"<value>\"\n" +
238 " \"directive_name\":\"<Name of directive>\",\n" +
239 " \"attributes\":[ \n" +
241 " \"attribute_name\":\"<name of attribute>\",\n" +
242 " \"attribute_value\":\"<value >\"\n" +
245 " \"attribute_name\":\"<name of attribute>\",\n" +
246 " \"attribute_value\":\"<value >\"\n" +
255 ModelInfo vnfModel = new ModelInfo();
256 vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
257 vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
258 vnfModel.setModelName("testModelNameVNF");
259 vnfModel.setModelVersion("testModelVersionVNF");
260 vnfModel.setModelUuid("testVnfModelUuid");
261 vnfModel.setModelType("testModelTypeVNF");
262 vnf.setModelInfo(vnfModel);
264 logger.debug("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString());
265 serviceDecomposition.setModelInfo(sModel);
266 serviceDecomposition.setAllottedResources(arList);
267 serviceDecomposition.setVnfResources(vnfList);
268 serviceDecomposition.setServiceInstance(si);
271 subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
272 subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
277 public void testHoming_success_2AR1Vnf() throws Exception {
281 String businessKey = UUID.randomUUID().toString();
282 Map<String, Object> variables = new HashMap<>();
283 setVariables(variables);
285 invokeSubProcess("Homing", businessKey, variables);
287 injectWorkflowMessages(callbacks, "oof2");
289 waitForProcessEnd(businessKey, 10000);
292 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
293 "WorkflowException");
294 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
295 "serviceDecomposition");
296 String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
298 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
299 HomingSolution resourceARHoming = resourceAR.getHomingSolution();
300 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
301 HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
302 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
303 HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
304 String resourceARHomingString = resourceARHoming.toString();
305 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
306 String resourceARHoming2String = resourceARHoming2.toString();
307 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
308 String resourceVNFHomingString = resourceVNFHoming.toString();
309 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
310 expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
312 assertNull(workflowException);
313 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
314 resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
315 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
316 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
317 resourceARHomingString);
318 assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
319 resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
320 null, null), resourceARHoming2String);
321 assertEquals(homingSolutionCloud("cloud","aic", "testCloudRegionId3",
322 true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
323 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
324 resourceVNFHomingString);
325 assertEquals(verifyOofRequest(), expectedOofRequest);
330 public void testHoming_success_2AR1Vnf2Net() throws Exception {
334 String businessKey = UUID.randomUUID().toString();
335 Map<String, Object> variables = new HashMap<>();
336 setVariables2(variables);
338 invokeSubProcess("Homing", businessKey, variables);
340 injectWorkflowMessages(callbacks, "oof3");
342 waitForProcessEnd(businessKey, 10000);
345 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
346 "WorkflowException");
347 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
348 "serviceDecomposition");
349 String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
351 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
352 HomingSolution resourceARHoming = resourceAR.getHomingSolution();
353 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
354 HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
355 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
356 HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
357 Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet");
358 HomingSolution resourceNetHoming = resourceNet.getHomingSolution();
359 Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2");
360 HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution();
362 String resourceARHomingString = resourceARHoming.toString();
363 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
364 String resourceARHoming2String = resourceARHoming2.toString();
365 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
366 String resourceVNFHomingString = resourceVNFHoming.toString();
367 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
368 String resourceNetHomingString = resourceNetHoming.toString();
369 resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " ");
370 String resourceNetHoming2String = resourceNetHoming2.toString();
371 resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " ");
372 expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
375 assertNull(workflowException);
376 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
377 resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
378 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
379 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
380 resourceARHomingString);
381 assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
382 resourceARHoming2.getVnf().getResourceId(),
383 "aic", "testCloudRegionId2",
384 null, null), resourceARHoming2String);
385 assertEquals(homingSolutionCloud("cloud","aic",
386 "testCloudRegionId3",
387 true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
388 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
389 resourceVNFHomingString);
390 assertEquals(homingSolutionService("service", "testServiceInstanceIdNet",
391 "testVnfHostNameNet", resourceNetHoming.getVnf().getResourceId(),"aic",
392 "testCloudRegionIdNet",
393 null, null), resourceNetHomingString);
394 assertEquals(homingSolutionCloud("cloud", "aic",
395 "testCloudRegionIdNet2",
396 false, "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"",
397 "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""),
398 resourceNetHoming2String);
399 assertEquals(verifyOofRequest(), expectedOofRequest);
406 public void testHoming_success_vnfResourceList() throws Exception {
408 // Create a Service Decomposition
409 MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4",
410 "/BuildingBlocks/oofCatalogResp.json");
411 String busKey = UUID.randomUUID().toString();
412 Map<String, Object> vars = new HashMap<>();
413 setVariablesForServiceDecomposition(vars, "testRequestId123",
414 "ff5256d2-5a33-55df-13ab-12abad84e7ff");
415 invokeSubProcess("DecomposeService", busKey, vars);
417 ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey,
418 "serviceDecomposition");
419 logger.debug("In testHoming_success_vnfResourceList, ServiceDecomposition = " + sd);
420 List<VnfResource> vnfResourceList = sd.getVnfResources();
421 //logger.debug(" vnfResourceList = " + vnfResourceList);
422 vnfResourceList.get(0).setResourceId("test-resource-id-000");
428 String businessKey = UUID.randomUUID().toString();
429 Map<String, Object> variables = new HashMap<>();
430 variables.put("homingService", "oof");
431 variables.put("isDebugLogEnabled", "true");
432 variables.put("msoRequestId", "testRequestId");
433 variables.put("serviceInstanceId", "testServiceInstanceId");
434 variables.put("serviceDecomposition", sd);
435 variables.put("subscriberInfo", subscriber2);
436 HashMap customerLocation = new HashMap<String, Object>();
437 customerLocation.put("customerLatitude", "32.89748");
438 customerLocation.put("customerLongitude", "-97.040443");
439 customerLocation.put("customerName", "xyz");
440 variables.put("customerLatitude", "32.89748");
441 variables.put("customerLongitude", "-97.040443");
442 variables.put("customerName", "xyz");
443 variables.put("customerLocation", customerLocation);
444 variables.put("cloudOwner", "amazon");
445 variables.put("cloudRegionId", "TNZED");
447 invokeSubProcess("Homing", businessKey, variables);
448 injectWorkflowMessages(callbacks, "oof3");
449 waitForProcessEnd(businessKey, 10000);
453 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
454 "WorkflowException");
455 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
456 "serviceDecomposition");
457 logger.debug("serviceDecompositionExp is: " + serviceDecompositionExp);
459 Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
460 logger.debug("resourceVnf is: " + resourceVnf);
461 HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution();
463 String resourceVnfHomingString = resourceVnfHoming.toString();
464 logger.debug("resourceVnfHomingString is: " + resourceVnfHomingString);
465 resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " ");
466 logger.debug("Now resourceVnfHomingString is: " + resourceVnfHomingString);
468 assertNull(workflowException);
471 String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
472 logger.debug("oofRequest is: " + oofRequest);
473 assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").
474 replaceAll("\n", "").replaceAll("\r", "").
475 replaceAll("\t", ""), oofRequest.replaceAll("\n", "").
476 replaceAll("\r", "").replaceAll("\t", ""));
478 //logger.debug("resourceVnfHoming.getVnf().getResourceId() is: " + resourceVnfHoming.getVnf().getResourceId());
480 assertEquals(homingSolutionService("service", "service-instance-01234",
481 "MDTNJ01", "test-resource-id-000","CloudOwner",
483 "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," +
484 " \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
485 "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," +
486 " \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString);
490 public void testHoming_success_existingLicense() throws Exception {
494 String businessKey = UUID.randomUUID().toString();
495 Map<String, Object> variables = new HashMap<String, Object>();
496 setVariablesExistingLicense(variables);
498 invokeSubProcess("Homing", businessKey, variables);
500 injectWorkflowMessages(callbacks, "sniro");
502 waitForProcessEnd(businessKey, 10000);
505 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
506 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
507 String oofRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
509 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
510 HomingSolution resourceARHoming = (HomingSolution) resourceAR.getHomingSolution();
511 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
512 HomingSolution resourceARHoming2 = (HomingSolution) resourceAR2.getHomingSolution();
513 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
514 HomingSolution resourceVNFHoming = (HomingSolution) resourceVNF.getHomingSolution();
515 String resourceARHomingString = resourceARHoming.toString();
516 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
517 String resourceARHoming2String = resourceARHoming2.toString();
518 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
519 String resourceVNFHomingString = resourceVNFHoming.toString();
520 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
521 oofRequest = oofRequest.replaceAll("\\s+", "");
523 assertNull(workflowException);
524 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
525 "aic", "dfwtx", "KDTNJ01",
526 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
527 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
528 resourceARHomingString);
529 assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
530 resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
531 null, null), resourceARHoming2String);
532 assertEquals(homingSolutionCloud("cloud", "aic",
533 "testCloudRegionId3",
534 false, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
535 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
536 resourceVNFHomingString);
537 assertEquals(verifyOofRequestExistingLicense(), oofRequest);
543 public void testHoming_error_inputVariable() throws Exception {
545 String businessKey = UUID.randomUUID().toString();
546 Map<String, Object> variables = new HashMap<>();
547 setVariables3(variables);
549 invokeSubProcess("Homing", businessKey, variables);
551 waitForProcessEnd(businessKey, 10000);
554 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
555 "WorkflowException");
557 assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required " +
558 "input variable is missing or null]", workflowException.toString());
563 public void testHoming_error_badResponse() throws Exception {
566 String businessKey = UUID.randomUUID().toString();
567 Map<String, Object> variables = new HashMap<>();
568 setVariables(variables);
570 invokeSubProcess("Homing", businessKey, variables);
572 waitForProcessEnd(businessKey, 10000);
575 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
576 "WorkflowException");
578 assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a " +
579 "Bad Sync Response from Sniro/OOF.]", workflowException.toString());
584 public void testHoming_error_oofNoSolution() throws Exception {
587 String businessKey = UUID.randomUUID().toString();
588 Map<String, Object> variables = new HashMap<>();
589 setVariables(variables);
591 invokeSubProcess("Homing", businessKey, variables);
593 injectWorkflowMessages(callbacks, "oofNoSol");
595 waitForProcessEnd(businessKey, 10000);
598 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
599 "WorkflowException");
601 assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found " +
602 "for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString());
607 public void testHoming_error_oofPolicyException() throws Exception {
610 String businessKey = UUID.randomUUID().toString();
611 Map<String, Object> variables = new HashMap<>();
612 setVariables(variables);
614 invokeSubProcess("Homing", businessKey, variables);
616 injectWorkflowMessages(callbacks, "oofPolicyEx");
618 waitForProcessEnd(businessKey, 10000);
621 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
622 "WorkflowException");
624 assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
625 "Response contains a Request Error Policy Exception: Message content size exceeds the allowable " +
626 "limit]", workflowException.toString());
631 public void testHoming_error_oofServiceException() throws Exception {
634 String businessKey = UUID.randomUUID().toString();
635 Map<String, Object> variables = new HashMap<>();
636 setVariables(variables);
638 invokeSubProcess("Homing", businessKey, variables);
640 injectWorkflowMessages(callbacks, "oofServiceEx");
642 waitForProcessEnd(businessKey, 10000);
645 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
646 "WorkflowException");
648 assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
649 "Response contains a Request Error Service Exception: OOF PlacementError: " +
650 "requests.exceptions.HTTPError: 404 Client Error: Not Found for " +
651 "url: http://192.168.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]",
652 workflowException.toString());
656 private void setVariables(Map<String, Object> variables) {
657 variables.put("homingService", "oof");
658 HashMap customerLocation = new HashMap<String, Object>();
659 customerLocation.put("customerLatitude", "32.89748");
660 customerLocation.put("customerLongitude", "-97.040443");
661 customerLocation.put("customerName", "xyz");
662 variables.put("customerLatitude", "32.89748");
663 variables.put("customerLongitude", "-97.040443");
664 variables.put("customerName", "xyz");
665 variables.put("customerLocation", customerLocation);
666 variables.put("cloudOwner", "amazon");
667 variables.put("cloudRegionId", "TNZED");
668 variables.put("isDebugLogEnabled", "true");
669 // variables.put("mso-request-id", "testRequestId");
670 variables.put("msoRequestId", "testRequestId");
671 variables.put("serviceInstanceId", "testServiceInstanceId");
672 variables.put("serviceDecomposition", serviceDecomposition);
673 variables.put("subscriberInfo", subscriber2);
676 private void setVariables2(Map<String, Object> variables) {
677 List<NetworkResource> netList = new ArrayList<NetworkResource>();
678 NetworkResource net = new NetworkResource();
679 net.setResourceId("testResourceIdNet");
680 ModelInfo netModel = new ModelInfo();
681 netModel.setModelCustomizationUuid("testModelCustomizationUuidNet");
682 netModel.setModelInvariantUuid("testModelInvariantIdNet");
683 netModel.setModelName("testModelNameNet");
684 netModel.setModelVersion("testModelVersionNet");
685 net.setModelInfo(netModel);
687 NetworkResource net2 = new NetworkResource();
688 net2.setResourceId("testResourceIdNet2");
689 ModelInfo netModel2 = new ModelInfo();
690 netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2");
691 netModel2.setModelCustomizationName("testModelCustomizationNameNet2");
692 netModel2.setModelInvariantUuid("testModelInvariantIdNet2");
693 netModel2.setModelName("testModelNameNet2");
694 netModel2.setModelVersion("testModelVersionNet2");
695 net2.setModelInfo(netModel2);
697 serviceDecomposition.setNetworkResources(netList);
699 variables.put("homingService", "oof");
700 HashMap customerLocation = new HashMap<String, Object>();
701 customerLocation.put("customerLatitude", "32.89748");
702 customerLocation.put("customerLongitude", "-97.040443");
703 customerLocation.put("customerName", "xyz");
704 variables.put("customerLatitude", "32.89748");
705 variables.put("customerLongitude", "-97.040443");
706 variables.put("customerName", "xyz");
707 variables.put("customerLocation", customerLocation);
708 variables.put("cloudOwner", "amazon");
709 variables.put("cloudRegionId", "TNZED");
710 variables.put("isDebugLogEnabled", "true");
711 variables.put("msoRequestId", "testRequestId");
712 variables.put("serviceInstanceId", "testServiceInstanceId");
713 variables.put("serviceDecomposition", serviceDecomposition);
714 variables.put("subscriberInfo", subscriber2);
717 private void setVariables3(Map<String, Object> variables) {
718 variables.put("homingService", "oof");
719 HashMap customerLocation = new HashMap<String, Object>();
720 customerLocation.put("customerLatitude", "32.89748");
721 customerLocation.put("customerLongitude", "-97.040443");
722 customerLocation.put("customerName", "xyz");
723 variables.put("customerLatitude", "32.89748");
724 variables.put("customerLongitude", "-97.040443");
725 variables.put("customerName", "xyz");
726 variables.put("customerLocation", customerLocation);
727 variables.put("cloudOwner", "amazon");
728 variables.put("cloudRegionId", "TNZED");
729 variables.put("isDebugLogEnabled", "true");
730 // variables.put("mso-request-id", "testRequestId");
731 variables.put("msoRequestId", "testRequestId");
732 variables.put("serviceInstanceId", "testServiceInstanceId");
733 variables.put("serviceDecomposition", null);
734 variables.put("subscriberInfo", subscriber2);
737 private void setVariablesExistingLicense(Map<String, Object> variables) {
738 HomingSolution currentHomingSolution = new HomingSolution();
739 serviceDecomposition.getVnfResources().get(0).setCurrentHomingSolution(currentHomingSolution);
740 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1");
741 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2");
743 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1");
744 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2");
746 variables.put("isDebugLogEnabled", "true");
747 variables.put("msoRequestId", "testRequestId");
748 variables.put("serviceInstanceId", "testServiceInstanceId");
749 variables.put("serviceDecomposition", serviceDecomposition);
750 variables.put("subscriberInfo", subscriber2);
754 private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname,
755 String vnfResourceId, String cloudOwner,
756 String cloudRegionId, String enList,
759 String solution = "";
761 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
762 serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
763 cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId +
764 "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :" +
765 " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { }," +
766 " \"rehome\" : false } }";
769 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
770 serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
771 cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :" +
772 " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :" +
773 " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :" +
774 " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
779 private String homingSolutionCloud(String type, String cloudOwner,
780 String cloudRegionId, Boolean flavors, String enList,
782 String solution = "";
784 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
785 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
786 "\", \"license\" : { }, \"rehome\" : false } }";
787 } else if (flavors && enList == null){
788 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
789 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
790 "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
791 "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
792 "\"license\" : { }, \"rehome\" : false } }";
793 } else if (flavors) {
794 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
795 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
796 "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
797 "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
798 "\"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
799 licenseList + " ] }, \"rehome\" : false } }";
801 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
802 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
803 "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
804 licenseList + " ] }, \"rehome\" : false } }";
809 private void setVariablesForServiceDecomposition(Map<String, Object> variables, String requestId, String siId) {
810 variables.put("homingService", "oof");
811 variables.put("isDebugLogEnabled", "true");
812 variables.put("mso-request-id", requestId);
813 variables.put("msoRequestId", requestId);
814 variables.put("serviceInstanceId", siId);
815 HashMap customerLocation = new HashMap<String, Object>();
816 customerLocation.put("customerLatitude", "32.89748");
817 customerLocation.put("customerLongitude", "-97.040443");
818 customerLocation.put("customerName", "xyz");
819 variables.put("customerLatitude", "32.89748");
820 variables.put("customerLongitude", "-97.040443");
821 variables.put("customerName", "xyz");
822 variables.put("customerLocation", customerLocation);
823 variables.put("cloudOwner", "amazon");
824 variables.put("cloudRegionId", "TNZED");
827 String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":" +
828 "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}";
829 variables.put("serviceModelInfo", serviceModelInfo);
832 private String verifyOofRequest() {
833 String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
834 "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\"," +
835 "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"]," +
836 "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":" +
837 "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":" +
838 "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
839 "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"ALLOTTED_RESOURCE\"" +
840 ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":" +
841 "\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR\"," +
842 "\"modelVersionId\":\"testARModelUuid\",\"modelName\":\"testModelNameAR\",\"modelType\":" +
843 "\"testModelTypeAR\",\"modelVersion\":\"testModelVersionAR\",\"modelCustomizationName\":\"\"}}," +
844 "{\"resourceModuleName\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\"," +
845 "\"tenantId\":\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR2\"," +
846 "\"modelVersionId\":\"testAr2ModelUuid\",\"modelName\":\"testModelNameAR2\"," +
847 "\"modelType\":\"testModelTypeAR2\",\"modelVersion\":\"testModelVersionAR2\"," +
848 "\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" +
849 "{\"serviceInstanceId\":\"testServiceInstanceId123\"," +
850 "\"serviceName\":\"null\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" +
851 "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\"," +
852 "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" +
853 "\"}},\"licenseInfo\":{\"licenseDemands\":[{\"resourceModuleName\":\"VNF\",\"serviceResourceId\":" +
854 "\"testResourceIdVNF\",\"resourceInstanceType\":\"VNF\",\"resourceModelInfo\":{\"modelInvariantId\":" +
855 "\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":" +
856 "\"testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\"," +
857 "\"modelCustomizationName\":\"\"}}]}}";
861 private String verifyOofRequestExistingLicense(){
862 String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
863 "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\"," +
864 "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"]," +
865 "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\"," +
866 "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":" +
867 "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":" +
868 "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
869 "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":" +
870 "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\"," +
871 "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\"," +
872 "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\"," +
873 "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":" +
874 "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":" +
875 "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":" +
876 "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\"," +
877 "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\"," +
878 "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\"," +
879 "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":" +
880 "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\"," +
881 "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":" +
882 "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\"," +
883 "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\"," +
884 "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}," +
885 "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\"," +
886 "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\"," +
887 "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":" +
888 "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";