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;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNull;
25 import static org.onap.so.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid;
26 import static org.onap.so.bpmn.mock.StubResponseOof.mockOof;
27 import static org.onap.so.bpmn.mock.StubResponseOof.mockOof_500;
29 import java.io.IOException;
30 import java.util.ArrayList;
31 import java.util.HashMap;
32 import java.util.List;
34 import java.util.UUID;
36 import org.junit.Ignore;
37 import org.junit.Test;
38 import org.onap.so.BaseIntegrationTest;
39 import org.onap.so.bpmn.core.WorkflowException;
40 import org.onap.so.bpmn.core.domain.AllottedResource;
41 import org.onap.so.bpmn.core.domain.HomingSolution;
42 import org.onap.so.bpmn.core.domain.ModelInfo;
43 import org.onap.so.bpmn.core.domain.NetworkResource;
44 import org.onap.so.bpmn.core.domain.Resource;
45 import org.onap.so.bpmn.core.domain.ServiceDecomposition;
46 import org.onap.so.bpmn.core.domain.ServiceInstance;
47 import org.onap.so.bpmn.core.domain.VnfResource;
48 import org.onap.so.bpmn.mock.FileUtil;
52 * Test the OOF Homing subflow building block.
55 public class OofHomingIT extends BaseIntegrationTest {
57 ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
58 String subscriber = "";
59 String subscriber2 = "";
61 private final CallbackSet callbacks = new CallbackSet();
63 public OofHomingIT() throws IOException {
64 String oofCallback = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackInfraVnf.json");
65 String oofCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf.json");
66 String oofCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf2Net.json");
68 String oofCallbackNoSolution = FileUtil.
69 readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound.json");
70 String oofCallbackPolicyException = FileUtil.
71 readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException.json");
72 String oofCallbackServiceException = FileUtil.
73 readResourceFile("__files/BuildingBlocks/oofCallbackServiceException.json");
75 callbacks.put("oof", JSON, "oofResponse", oofCallback);
76 callbacks.put("oof2", JSON, "oofResponse", oofCallback2);
77 callbacks.put("oof3", JSON, "oofResponse", oofCallback3);
78 callbacks.put("oofNoSol", JSON, "oofResponse", oofCallbackNoSolution);
79 callbacks.put("oofPolicyEx", JSON, "oofResponse", oofCallbackPolicyException);
80 callbacks.put("oofServiceEx", JSON, "oofResponse", oofCallbackServiceException);
83 ModelInfo sModel = new ModelInfo();
84 sModel.setModelCustomizationName("testModelCustomizationName");
85 sModel.setModelInstanceName("testModelInstanceName");
86 sModel.setModelInvariantUuid("testModelInvariantId");
87 sModel.setModelName("testModelName");
88 sModel.setModelUuid("testModelUuid");
89 sModel.setModelVersion("testModelVersion");
91 ServiceInstance si = new ServiceInstance();
92 si.setInstanceId("testServiceInstanceId123");
94 List<AllottedResource> arList = new ArrayList<AllottedResource>();
95 AllottedResource ar = new AllottedResource();
96 ar.setResourceId("testResourceIdAR");
97 ar.setNfFunction("testARFunctionName");
98 ModelInfo arModel = new ModelInfo();
99 arModel.setModelCustomizationUuid("testModelCustomizationUuidAR");
100 arModel.setModelInvariantUuid("testModelInvariantIdAR");
101 arModel.setModelName("testModelNameAR");
102 arModel.setModelVersion("testModelVersionAR");
103 arModel.setModelUuid("testARModelUuid");
104 arModel.setModelType("testModelTypeAR");
105 ar.setModelInfo(arModel);
106 AllottedResource ar2 = new AllottedResource();
107 ar2.setResourceId("testResourceIdAR2");
108 ar2.setNfFunction("testAR2FunctionName");
109 ModelInfo arModel2 = new ModelInfo();
110 arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2");
111 arModel2.setModelInvariantUuid("testModelInvariantIdAR2");
112 arModel2.setModelName("testModelNameAR2");
113 arModel2.setModelVersion("testModelVersionAR2");
114 arModel2.setModelUuid("testAr2ModelUuid");
115 arModel2.setModelType("testModelTypeAR2");
116 ar2.setModelInfo(arModel2);
120 List<VnfResource> vnfList = new ArrayList<VnfResource>();
121 VnfResource vnf = new VnfResource();
122 vnf.setResourceId("testResourceIdVNF");
123 vnf.setNfFunction("testVnfFunctionName");
124 vnf.getHomingSolution().setOofDirectives(
126 " \"directives\":[ \n" +
128 " \"vnfc_directives\":[ \n" +
130 " \"vnfc_id\":\"<ID of VNFC>\",\n" +
131 " \"directives\":[ \n" +
133 " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
134 " \"attributes\":[ \n" +
136 " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
137 " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
142 " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
143 " \"attributes\":[ \n" +
145 " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
146 " \"attribute_value\":\"<value such as direct/normal>\"\n" +
149 " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
150 " \"attribute_value\":\"<value such as physnet>\"\n" +
159 " \"vnf_directives\":{ \n" +
160 " \"directives\":[ \n" +
162 " \"directive_name\":\"<Name of directive>\",\n" +
163 " \"attributes\":[ \n" +
165 " \"attribute_name\":\"<name of attribute>\",\n" +
166 " \"attribute_value\":\"<value>\"\n" +
171 " \"directive_name\":\"<Name of directive>\",\n" +
172 " \"attributes\":[ \n" +
174 " \"attribute_name\":\"<name of attribute>\",\n" +
175 " \"attribute_value\":\"<value >\"\n" +
178 " \"attribute_name\":\"<name of attribute>\",\n" +
179 " \"attribute_value\":\"<value >\"\n" +
188 " \"sdnc_directives\":{ \n" +
189 " \"directives\":[ \n" +
191 " \"vnfc_directives\":[ \n" +
193 " \"vnfc_id\":\"<ID of VNFC>\",\n" +
194 " \"directives\":[ \n" +
196 " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
197 " \"attributes\":[ \n" +
199 " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
200 " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
205 " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
206 " \"attributes\":[ \n" +
208 " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
209 " \"attribute_value\":\"<value such as direct/normal>\"\n" +
212 " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
213 " \"attribute_value\":\"<value such as physnet>\"\n" +
222 " \"vnf_directives\":{ \n" +
223 " \"directives\":[ \n" +
225 " \"directive_name\":\"<Name of directive>\",\n" +
226 " \"attributes\":[ \n" +
228 " \"attribute_name\":\"<name of attribute>\",\n" +
229 " \"attribute_value\":\"<value>\"\n" +
234 " \"directive_name\":\"<Name of directive>\",\n" +
235 " \"attributes\":[ \n" +
237 " \"attribute_name\":\"<name of attribute>\",\n" +
238 " \"attribute_value\":\"<value >\"\n" +
241 " \"attribute_name\":\"<name of attribute>\",\n" +
242 " \"attribute_value\":\"<value >\"\n" +
251 ModelInfo vnfModel = new ModelInfo();
252 vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
253 vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
254 vnfModel.setModelName("testModelNameVNF");
255 vnfModel.setModelVersion("testModelVersionVNF");
256 vnfModel.setModelUuid("testVnfModelUuid");
257 vnfModel.setModelType("testModelTypeVNF");
258 vnf.setModelInfo(vnfModel);
260 System.out.println("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString());
261 serviceDecomposition.setModelInfo(sModel);
262 serviceDecomposition.setAllottedResources(arList);
263 serviceDecomposition.setVnfResources(vnfList);
264 serviceDecomposition.setServiceInstance(si);
267 subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
268 subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
272 public void testHoming_success_2AR1Vnf() throws Exception {
276 String businessKey = UUID.randomUUID().toString();
277 Map<String, Object> variables = new HashMap<>();
278 setVariables(variables);
280 invokeSubProcess("Homing", businessKey, variables);
282 injectWorkflowMessages(callbacks, "oof2");
284 waitForProcessEnd(businessKey, 10000);
287 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
288 "WorkflowException");
289 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
290 "serviceDecomposition");
291 String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
293 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
294 HomingSolution resourceARHoming = resourceAR.getHomingSolution();
295 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
296 HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
297 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
298 HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
299 String resourceARHomingString = resourceARHoming.toString();
300 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
301 String resourceARHoming2String = resourceARHoming2.toString();
302 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
303 String resourceVNFHomingString = resourceVNFHoming.toString();
304 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
305 expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
307 assertNull(workflowException);
308 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
309 resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
310 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
311 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
312 resourceARHomingString);
313 assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
314 resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
315 null, null), resourceARHoming2String);
316 assertEquals(homingSolutionCloud("cloud","aic", "testCloudRegionId3",
317 true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
318 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
319 resourceVNFHomingString);
320 assertEquals(verifyOofRequest(), expectedOofRequest);
324 public void testHoming_success_2AR1Vnf2Net() throws Exception {
328 String businessKey = UUID.randomUUID().toString();
329 Map<String, Object> variables = new HashMap<>();
330 setVariables2(variables);
332 invokeSubProcess("Homing", businessKey, variables);
334 injectWorkflowMessages(callbacks, "oof3");
336 waitForProcessEnd(businessKey, 10000);
339 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
340 "WorkflowException");
341 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
342 "serviceDecomposition");
343 String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
345 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
346 HomingSolution resourceARHoming = resourceAR.getHomingSolution();
347 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
348 HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
349 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
350 HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
351 Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet");
352 HomingSolution resourceNetHoming = resourceNet.getHomingSolution();
353 Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2");
354 HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution();
356 String resourceARHomingString = resourceARHoming.toString();
357 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
358 String resourceARHoming2String = resourceARHoming2.toString();
359 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
360 String resourceVNFHomingString = resourceVNFHoming.toString();
361 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
362 String resourceNetHomingString = resourceNetHoming.toString();
363 resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " ");
364 String resourceNetHoming2String = resourceNetHoming2.toString();
365 resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " ");
366 expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
369 assertNull(workflowException);
370 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
371 resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
372 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
373 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
374 resourceARHomingString);
375 assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
376 resourceARHoming2.getVnf().getResourceId(),
377 "aic", "testCloudRegionId2",
378 null, null), resourceARHoming2String);
379 assertEquals(homingSolutionCloud("cloud","aic",
380 "testCloudRegionId3",
381 true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
382 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
383 resourceVNFHomingString);
384 assertEquals(homingSolutionService("service", "testServiceInstanceIdNet",
385 "testVnfHostNameNet", resourceNetHoming.getVnf().getResourceId(),"aic",
386 "testCloudRegionIdNet",
387 null, null), resourceNetHomingString);
388 assertEquals(homingSolutionCloud("cloud", "aic",
389 "testCloudRegionIdNet2",
390 false, "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"",
391 "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""),
392 resourceNetHoming2String);
393 assertEquals(verifyOofRequest(), expectedOofRequest);
398 public void testHoming_success_vnfResourceList() throws Exception {
400 // Create a Service Decomposition
401 MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4",
402 "/BuildingBlocks/oofCatalogResp.json");
403 String busKey = UUID.randomUUID().toString();
404 Map<String, Object> vars = new HashMap<>();
405 setVariablesForServiceDecomposition(vars, "testRequestId123",
406 "ff5256d2-5a33-55df-13ab-12abad84e7ff");
407 invokeSubProcess("DecomposeService", busKey, vars);
409 ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition");
410 System.out.println("In testHoming_success_vnfResourceList, ServiceDecomposition = " + sd);
411 List<VnfResource> vnfResourceList = sd.getVnfResources();
412 vnfResourceList.get(0).setResourceId("test-resource-id-000");
418 String businessKey = UUID.randomUUID().toString();
419 Map<String, Object> variables = new HashMap<>();
420 variables.put("homingService", "oof");
421 variables.put("isDebugLogEnabled", "true");
422 variables.put("msoRequestId", "testRequestId");
423 variables.put("serviceInstanceId", "testServiceInstanceId");
424 variables.put("serviceDecomposition", sd);
425 variables.put("subscriberInfo", subscriber2);
426 HashMap customerLocation = new HashMap<String, Object>();
427 customerLocation.put("customerLatitude", "32.89748");
428 customerLocation.put("customerLongitude", "-97.040443");
429 customerLocation.put("customerName", "xyz");
430 variables.put("customerLatitude", "32.89748");
431 variables.put("customerLongitude", "-97.040443");
432 variables.put("customerName", "xyz");
433 variables.put("customerLocation", customerLocation);
434 variables.put("cloudOwner", "amazon");
435 variables.put("cloudRegionId", "TNZED");
437 invokeSubProcess("Homing", businessKey, variables);
438 injectWorkflowMessages(callbacks, "oof3");
439 waitForProcessEnd(businessKey, 10000);
443 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
444 "WorkflowException");
445 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
446 "serviceDecomposition");
447 System.out.println("serviceDecompositionExp is: " + serviceDecompositionExp);
449 Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
450 System.out.println("resourceVnf is: " + resourceVnf);
451 HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution();
453 String resourceVnfHomingString = resourceVnfHoming.toString();
454 System.out.println("resourceVnfHomingString is: " + resourceVnfHomingString);
455 resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " ");
456 System.out.println("Now resourceVnfHomingString is: " + resourceVnfHomingString);
458 assertNull(workflowException);
461 String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
462 System.out.println("oofRequest is: " + oofRequest);
463 assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").
464 replaceAll("\n", "").replaceAll("\r", "").
465 replaceAll("\t", ""), oofRequest.replaceAll("\n", "").
466 replaceAll("\r", "").replaceAll("\t", ""));
468 //System.out.println("resourceVnfHoming.getVnf().getResourceId() is: " + resourceVnfHoming.getVnf().getResourceId());
470 assertEquals(homingSolutionService("service", "service-instance-01234",
471 "MDTNJ01", "test-resource-id-000","CloudOwner",
473 "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," +
474 " \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
475 "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," +
476 " \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString);
480 public void testHoming_success_existingLicense() throws Exception {
484 String businessKey = UUID.randomUUID().toString();
485 Map<String, Object> variables = new HashMap<String, Object>();
486 setVariablesExistingLicense(variables);
488 invokeSubProcess("Homing", businessKey, variables);
490 injectWorkflowMessages(callbacks, "sniro");
492 waitForProcessEnd(businessKey, 10000);
495 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
496 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
497 String oofRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
499 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
500 HomingSolution resourceARHoming = (HomingSolution) resourceAR.getHomingSolution();
501 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
502 HomingSolution resourceARHoming2 = (HomingSolution) resourceAR2.getHomingSolution();
503 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
504 HomingSolution resourceVNFHoming = (HomingSolution) resourceVNF.getHomingSolution();
505 String resourceARHomingString = resourceARHoming.toString();
506 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
507 String resourceARHoming2String = resourceARHoming2.toString();
508 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
509 String resourceVNFHomingString = resourceVNFHoming.toString();
510 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
511 oofRequest = oofRequest.replaceAll("\\s+", "");
513 assertNull(workflowException);
514 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
515 "aic", "dfwtx", "KDTNJ01",
516 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
517 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
518 resourceARHomingString);
519 assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
520 resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
521 null, null), resourceARHoming2String);
522 assertEquals(homingSolutionCloud("cloud", "aic",
523 "testCloudRegionId3",
524 false, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
525 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
526 resourceVNFHomingString);
527 assertEquals(verifyOofRequestExistingLicense(), oofRequest);
532 public void testHoming_error_inputVariable() throws Exception {
534 String businessKey = UUID.randomUUID().toString();
535 Map<String, Object> variables = new HashMap<>();
536 setVariables3(variables);
538 invokeSubProcess("Homing", businessKey, variables);
540 waitForProcessEnd(businessKey, 10000);
543 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
544 "WorkflowException");
546 assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required " +
547 "input variable is missing or null,workStep=*]", workflowException.toString());
551 public void testHoming_error_badResponse() throws Exception {
554 String businessKey = UUID.randomUUID().toString();
555 Map<String, Object> variables = new HashMap<>();
556 setVariables(variables);
558 invokeSubProcess("Homing", businessKey, variables);
560 waitForProcessEnd(businessKey, 10000);
563 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
564 "WorkflowException");
566 assertEquals("WorkflowException[processKey=Homing,errorCode=401,errorMessage=Internal Error - BasicAuth value null,workStep=*]", workflowException.toString());
570 public void testHoming_error_oofNoSolution() throws Exception {
573 String businessKey = UUID.randomUUID().toString();
574 Map<String, Object> variables = new HashMap<>();
575 setVariables(variables);
577 invokeSubProcess("Homing", businessKey, variables);
579 injectWorkflowMessages(callbacks, "oofNoSol");
581 waitForProcessEnd(businessKey, 10000);
584 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
585 "WorkflowException");
586 Boolean errorMatch = workflowException.toString().contains("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
587 "Response contains error: Unable to find any candidate for demand *** Response:");
592 public void testHoming_error_oofPolicyException() throws Exception {
595 String businessKey = UUID.randomUUID().toString();
596 Map<String, Object> variables = new HashMap<>();
597 setVariables(variables);
599 invokeSubProcess("Homing", businessKey, variables);
601 injectWorkflowMessages(callbacks, "oofPolicyEx");
603 waitForProcessEnd(businessKey, 10000);
606 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
607 "WorkflowException");
609 assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
610 "Response contains a Request Error Policy Exception: Message content size exceeds the allowable " +
611 "limit]", workflowException.toString());
615 public void testHoming_error_oofServiceException() throws Exception {
618 String businessKey = UUID.randomUUID().toString();
619 Map<String, Object> variables = new HashMap<>();
620 setVariables(variables);
622 invokeSubProcess("Homing", businessKey, variables);
623 injectWorkflowMessages(callbacks, "oofServiceEx");
624 waitForProcessEnd(businessKey, 10000);
627 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
628 "WorkflowException");
630 assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
631 "Response contains a Request Error Service Exception: OOF PlacementError: " +
632 "requests.exceptions.HTTPError: 404 Client Error: Not Found for " +
633 "url: http://192.168.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]",
634 workflowException.toString());
638 private void setVariables(Map<String, Object> variables) {
639 variables.put("homingService", "oof");
640 HashMap customerLocation = new HashMap<String, Object>();
641 customerLocation.put("customerLatitude", "32.89748");
642 customerLocation.put("customerLongitude", "-97.040443");
643 customerLocation.put("customerName", "xyz");
644 variables.put("customerLatitude", "32.89748");
645 variables.put("customerLongitude", "-97.040443");
646 variables.put("customerName", "xyz");
647 variables.put("customerLocation", customerLocation);
648 variables.put("cloudOwner", "amazon");
649 variables.put("cloudRegionId", "TNZED");
650 variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR");
651 variables.put("vgMuxInfraModelId", "testArModelUuid");
652 // variables.put("mso-request-id", "testRequestId");
653 variables.put("msoRequestId", "testRequestId");
654 variables.put("serviceInstanceId", "testServiceInstanceId123");
655 variables.put("serviceInstanceName", "testServiceName");
656 variables.put("serviceDecomposition", serviceDecomposition);
657 variables.put("subscriberInfo", subscriber2);
660 private void setVariables2(Map<String, Object> variables) {
661 List<NetworkResource> netList = new ArrayList<NetworkResource>();
662 NetworkResource net = new NetworkResource();
663 net.setResourceId("testResourceIdNet");
664 ModelInfo netModel = new ModelInfo();
665 netModel.setModelCustomizationUuid("testModelCustomizationUuidNet");
666 netModel.setModelInvariantUuid("testModelInvariantIdNet");
667 netModel.setModelName("testModelNameNet");
668 netModel.setModelVersion("testModelVersionNet");
669 net.setModelInfo(netModel);
671 NetworkResource net2 = new NetworkResource();
672 net2.setResourceId("testResourceIdNet2");
673 ModelInfo netModel2 = new ModelInfo();
674 netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2");
675 netModel2.setModelCustomizationName("testModelCustomizationNameNet2");
676 netModel2.setModelInvariantUuid("testModelInvariantIdNet2");
677 netModel2.setModelName("testModelNameNet2");
678 netModel2.setModelVersion("testModelVersionNet2");
679 net2.setModelInfo(netModel2);
681 serviceDecomposition.setNetworkResources(netList);
683 variables.put("homingService", "oof");
684 HashMap customerLocation = new HashMap<String, Object>();
685 customerLocation.put("customerLatitude", "32.89748");
686 customerLocation.put("customerLongitude", "-97.040443");
687 customerLocation.put("customerName", "xyz");
688 variables.put("customerLatitude", "32.89748");
689 variables.put("customerLongitude", "-97.040443");
690 variables.put("customerName", "xyz");
691 variables.put("customerLocation", customerLocation);
692 variables.put("cloudOwner", "amazon");
693 variables.put("cloudRegionId", "TNZED");
694 variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR");
695 variables.put("vgMuxInfraModelId", "testArModelUuid");
696 variables.put("isDebugLogEnabled", "true");
697 variables.put("msoRequestId", "testRequestId");
698 variables.put("serviceInstanceId", "testServiceInstanceId123");
699 variables.put("serviceInstanceName", "testServiceName");
700 variables.put("serviceDecomposition", serviceDecomposition);
701 variables.put("subscriberInfo", subscriber2);
704 private void setVariables3(Map<String, Object> variables) {
705 variables.put("homingService", "oof");
706 HashMap customerLocation = new HashMap<String, Object>();
707 customerLocation.put("customerLatitude", "32.89748");
708 customerLocation.put("customerLongitude", "-97.040443");
709 customerLocation.put("customerName", "xyz");
710 variables.put("customerLatitude", "32.89748");
711 variables.put("customerLongitude", "-97.040443");
712 variables.put("customerName", "xyz");
713 variables.put("customerLocation", customerLocation);
714 variables.put("cloudOwner", "amazon");
715 variables.put("cloudRegionId", "TNZED");
716 variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR");
717 variables.put("vgMuxInfraModelId", "testArModelUuid");
718 variables.put("isDebugLogEnabled", "true");
719 // variables.put("mso-request-id", "testRequestId");
720 variables.put("msoRequestId", "testRequestId");
721 variables.put("serviceInstanceId", "testServiceInstanceId123");
722 variables.put("serviceInstanceName", "testServiceName");
723 variables.put("serviceDecomposition", null);
724 variables.put("subscriberInfo", subscriber2);
727 private void setVariablesExistingLicense(Map<String, Object> variables) {
728 HomingSolution currentHomingSolution = new HomingSolution();
729 serviceDecomposition.getVnfResources().get(0).setCurrentHomingSolution(currentHomingSolution);
730 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1");
731 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2");
733 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1");
734 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2");
736 variables.put("isDebugLogEnabled", "true");
737 variables.put("msoRequestId", "testRequestId");
738 variables.put("serviceInstanceId", "testServiceInstanceId");
739 variables.put("serviceDecomposition", serviceDecomposition);
740 variables.put("subscriberInfo", subscriber2);
744 private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname,
745 String vnfResourceId, String cloudOwner,
746 String cloudRegionId, String enList,
749 String solution = "";
751 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
752 serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
753 cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId +
754 "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :" +
755 " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { }," +
756 " \"rehome\" : false } }";
759 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
760 serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
761 cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :" +
762 " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :" +
763 " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :" +
764 " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
769 private String homingSolutionCloud(String type, String cloudOwner,
770 String cloudRegionId, Boolean flavors, String enList,
772 String solution = "";
774 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
775 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
776 "\", \"license\" : { }, \"rehome\" : false } }";
777 } else if (flavors && enList == null){
778 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
779 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
780 "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
781 "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
782 "\"license\" : { }, \"rehome\" : false } }";
783 } else if (flavors) {
784 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
785 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
786 "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
787 "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
788 "\"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
789 licenseList + " ] }, \"rehome\" : false } }";
791 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
792 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
793 "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
794 licenseList + " ] }, \"rehome\" : false } }";
799 private void setVariablesForServiceDecomposition(Map<String, Object> variables, String requestId, String siId) {
800 variables.put("homingService", "oof");
801 variables.put("isDebugLogEnabled", "true");
802 variables.put("mso-request-id", requestId);
803 variables.put("msoRequestId", requestId);
804 variables.put("serviceInstanceId", siId);
805 HashMap customerLocation = new HashMap<String, Object>();
806 customerLocation.put("customerLatitude", "32.89748");
807 customerLocation.put("customerLongitude", "-97.040443");
808 customerLocation.put("customerName", "xyz");
809 variables.put("customerLatitude", "32.89748");
810 variables.put("customerLongitude", "-97.040443");
811 variables.put("customerName", "xyz");
812 variables.put("customerLocation", customerLocation);
813 variables.put("cloudOwner", "amazon");
814 variables.put("cloudRegionId", "TNZED");
817 String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":" +
818 "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}";
819 variables.put("serviceModelInfo", serviceModelInfo);
822 private String verifyOofRequest() {
823 String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
824 "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\"," +
825 "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"]," +
826 "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":" +
827 "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":" +
828 "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
829 "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"testARFunctionName\"" +
830 ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":" +
831 "\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\"," +
832 "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\",\"modelType\":" +
833 "\"\",\"modelVersion\":\"\",\"modelCustomizationName\":\"\"}}," +
834 "{\"resourceModuleName\":\"testAR2FunctionName\",\"serviceResourceId\":\"testResourceIdAR2\"," +
835 "\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\"," +
836 "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\"," +
837 "\"modelType\":\"\",\"modelVersion\":\"\"," +
838 "\"modelCustomizationName\":\"\"}},{\"resourceModuleName\":\"testVnfFunctionName\",\"serviceResourceId\":\"" +
839 "testResourceIdVNF\",\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\"" +
840 ":\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":\"" +
841 "testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\"" +
842 ",\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" +
843 "{\"serviceInstanceId\":\"testServiceInstanceId123\"," +
844 "\"serviceName\":\"testServiceName\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" +
845 "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\"," +
846 "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" +
851 private String verifyOofRequestExistingLicense(){
852 String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
853 "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\"," +
854 "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"]," +
855 "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\"," +
856 "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":" +
857 "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":" +
858 "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
859 "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":" +
860 "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\"," +
861 "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\"," +
862 "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\"," +
863 "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":" +
864 "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":" +
865 "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":" +
866 "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\"," +
867 "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\"," +
868 "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\"," +
869 "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":" +
870 "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\"," +
871 "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":" +
872 "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\"," +
873 "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\"," +
874 "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}," +
875 "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\"," +
876 "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\"," +
877 "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":" +
878 "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";