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;
28 import java.io.IOException;
29 import java.util.ArrayList;
30 import java.util.HashMap;
31 import java.util.List;
33 import java.util.UUID;
34 import org.junit.Ignore;
35 import org.junit.Test;
36 import org.onap.so.BaseIntegrationTest;
37 import org.onap.so.bpmn.core.WorkflowException;
38 import org.onap.so.bpmn.core.domain.AllottedResource;
39 import org.onap.so.bpmn.core.domain.HomingSolution;
40 import org.onap.so.bpmn.core.domain.ModelInfo;
41 import org.onap.so.bpmn.core.domain.NetworkResource;
42 import org.onap.so.bpmn.core.domain.Resource;
43 import org.onap.so.bpmn.core.domain.ServiceDecomposition;
44 import org.onap.so.bpmn.core.domain.ServiceInstance;
45 import org.onap.so.bpmn.core.domain.VnfResource;
46 import org.onap.so.bpmn.mock.FileUtil;
50 * Test the OOF Homing subflow building block.
53 public class OofHomingIT extends BaseIntegrationTest {
55 ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
56 String subscriber = "";
57 String subscriber2 = "";
59 private final CallbackSet callbacks = new CallbackSet();
61 public OofHomingIT() throws IOException {
62 String oofCallback = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackInfraVnf.json");
63 String oofCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf.json");
64 String oofCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf2Net.json");
66 String oofCallbackNoSolution =
67 FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound.json");
68 String oofCallbackPolicyException =
69 FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException.json");
70 String oofCallbackServiceException =
71 FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackServiceException.json");
73 callbacks.put("oof", JSON, "oofResponse", oofCallback);
74 callbacks.put("oof2", JSON, "oofResponse", oofCallback2);
75 callbacks.put("oof3", JSON, "oofResponse", oofCallback3);
76 callbacks.put("oofNoSol", JSON, "oofResponse", oofCallbackNoSolution);
77 callbacks.put("oofPolicyEx", JSON, "oofResponse", oofCallbackPolicyException);
78 callbacks.put("oofServiceEx", JSON, "oofResponse", oofCallbackServiceException);
81 ModelInfo sModel = new ModelInfo();
82 sModel.setModelCustomizationName("testModelCustomizationName");
83 sModel.setModelInstanceName("testModelInstanceName");
84 sModel.setModelInvariantUuid("testModelInvariantId");
85 sModel.setModelName("testModelName");
86 sModel.setModelUuid("testModelUuid");
87 sModel.setModelVersion("testModelVersion");
89 ServiceInstance si = new ServiceInstance();
90 si.setInstanceId("testServiceInstanceId123");
92 List<AllottedResource> arList = new ArrayList<AllottedResource>();
93 AllottedResource ar = new AllottedResource();
94 ar.setResourceId("testResourceIdAR");
95 ar.setNfFunction("testARFunctionName");
96 ModelInfo arModel = new ModelInfo();
97 arModel.setModelCustomizationUuid("testModelCustomizationUuidAR");
98 arModel.setModelInvariantUuid("testModelInvariantIdAR");
99 arModel.setModelName("testModelNameAR");
100 arModel.setModelVersion("testModelVersionAR");
101 arModel.setModelUuid("testARModelUuid");
102 arModel.setModelType("testModelTypeAR");
103 ar.setModelInfo(arModel);
104 AllottedResource ar2 = new AllottedResource();
105 ar2.setResourceId("testResourceIdAR2");
106 ar2.setNfFunction("testAR2FunctionName");
107 ModelInfo arModel2 = new ModelInfo();
108 arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2");
109 arModel2.setModelInvariantUuid("testModelInvariantIdAR2");
110 arModel2.setModelName("testModelNameAR2");
111 arModel2.setModelVersion("testModelVersionAR2");
112 arModel2.setModelUuid("testAr2ModelUuid");
113 arModel2.setModelType("testModelTypeAR2");
114 ar2.setModelInfo(arModel2);
118 List<VnfResource> vnfList = new ArrayList<VnfResource>();
119 VnfResource vnf = new VnfResource();
120 vnf.setResourceId("testResourceIdVNF");
121 vnf.setNfFunction("testVnfFunctionName");
122 vnf.getHomingSolution().setOofDirectives("{ \n" + " \"directives\":[ \n" + " { \n"
123 + " \"vnfc_directives\":[ \n" + " { \n"
124 + " \"vnfc_id\":\"<ID of VNFC>\",\n" + " \"directives\":[ \n"
126 + " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n"
127 + " \"attributes\":[ \n" + " { \n"
128 + " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n"
129 + " \"attribute_value\":\"<value such as cloud specific flavor>\"\n"
130 + " }\n" + " ]\n" + " },\n"
132 + " \"directive_name\":\"<Name of directive,example vnic-info>\",\n"
133 + " \"attributes\":[ \n" + " { \n"
134 + " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n"
135 + " \"attribute_value\":\"<value such as direct/normal>\"\n"
137 + " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n"
138 + " \"attribute_value\":\"<value such as physnet>\"\n"
139 + " }\n" + " ]\n" + " }\n"
140 + " ]\n" + " }\n" + " ]\n" + " },\n" + " { \n"
141 + " \"vnf_directives\":{ \n" + " \"directives\":[ \n"
142 + " { \n" + " \"directive_name\":\"<Name of directive>\",\n"
143 + " \"attributes\":[ \n" + " { \n"
144 + " \"attribute_name\":\"<name of attribute>\",\n"
145 + " \"attribute_value\":\"<value>\"\n" + " }\n"
146 + " ]\n" + " },\n" + " { \n"
147 + " \"directive_name\":\"<Name of directive>\",\n"
148 + " \"attributes\":[ \n" + " { \n"
149 + " \"attribute_name\":\"<name of attribute>\",\n"
150 + " \"attribute_value\":\"<value >\"\n" + " },\n"
152 + " \"attribute_name\":\"<name of attribute>\",\n"
153 + " \"attribute_value\":\"<value >\"\n" + " }\n"
154 + " ]\n" + " }\n" + " ]\n" + " }\n"
155 + " }\n" + " ]\n" + " },\n" + " \"sdnc_directives\":{ \n" + " \"directives\":[ \n"
156 + " { \n" + " \"vnfc_directives\":[ \n" + " { \n"
157 + " \"vnfc_id\":\"<ID of VNFC>\",\n" + " \"directives\":[ \n"
159 + " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n"
160 + " \"attributes\":[ \n" + " { \n"
161 + " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n"
162 + " \"attribute_value\":\"<value such as cloud specific flavor>\"\n"
163 + " }\n" + " ]\n" + " },\n"
165 + " \"directive_name\":\"<Name of directive,example vnic-info>\",\n"
166 + " \"attributes\":[ \n" + " { \n"
167 + " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n"
168 + " \"attribute_value\":\"<value such as direct/normal>\"\n"
170 + " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n"
171 + " \"attribute_value\":\"<value such as physnet>\"\n"
172 + " }\n" + " ]\n" + " }\n"
173 + " ]\n" + " }\n" + " ]\n" + " },\n" + " { \n"
174 + " \"vnf_directives\":{ \n" + " \"directives\":[ \n"
175 + " { \n" + " \"directive_name\":\"<Name of directive>\",\n"
176 + " \"attributes\":[ \n" + " { \n"
177 + " \"attribute_name\":\"<name of attribute>\",\n"
178 + " \"attribute_value\":\"<value>\"\n" + " }\n"
179 + " ]\n" + " },\n" + " { \n"
180 + " \"directive_name\":\"<Name of directive>\",\n"
181 + " \"attributes\":[ \n" + " { \n"
182 + " \"attribute_name\":\"<name of attribute>\",\n"
183 + " \"attribute_value\":\"<value >\"\n" + " },\n"
185 + " \"attribute_name\":\"<name of attribute>\",\n"
186 + " \"attribute_value\":\"<value >\"\n" + " }\n"
187 + " ]\n" + " }\n" + " ]\n" + " }\n"
188 + " }\n" + " ]\n" + " }");
189 ModelInfo vnfModel = new ModelInfo();
190 vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
191 vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
192 vnfModel.setModelName("testModelNameVNF");
193 vnfModel.setModelVersion("testModelVersionVNF");
194 vnfModel.setModelUuid("testVnfModelUuid");
195 vnfModel.setModelType("testModelTypeVNF");
196 vnf.setModelInfo(vnfModel);
198 System.out.println("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString());
199 serviceDecomposition.setModelInfo(sModel);
200 serviceDecomposition.setAllottedResources(arList);
201 serviceDecomposition.setVnfResources(vnfList);
202 serviceDecomposition.setServiceInstance(si);
206 "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
207 subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
211 public void testHoming_success_2AR1Vnf() throws Exception {
213 mockOof(wireMockServer);
215 String businessKey = UUID.randomUUID().toString();
216 Map<String, Object> variables = new HashMap<>();
217 setVariables(variables);
219 invokeSubProcess("Homing", businessKey, variables);
221 injectWorkflowMessages(callbacks, "oof2");
223 waitForProcessEnd(businessKey, 10000);
226 WorkflowException workflowException =
227 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
228 ServiceDecomposition serviceDecompositionExp =
229 (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
230 String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
232 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
233 HomingSolution resourceARHoming = resourceAR.getHomingSolution();
234 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
235 HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
236 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
237 HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
238 String resourceARHomingString = resourceARHoming.toString();
239 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
240 String resourceARHoming2String = resourceARHoming2.toString();
241 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
242 String resourceVNFHomingString = resourceVNFHoming.toString();
243 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
244 expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
246 assertNull(workflowException);
247 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", resourceARHoming.getVnf().getResourceId(),
248 "aic", "dfwtx", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
249 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
250 resourceARHomingString);
252 homingSolutionService("service", "testSIID2", "testVnfHostname2",
253 resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null),
254 resourceARHoming2String);
256 homingSolutionCloud("cloud", "aic", "testCloudRegionId3", true,
257 "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
258 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
259 resourceVNFHomingString);
260 assertEquals(verifyOofRequest(), expectedOofRequest);
264 public void testHoming_success_2AR1Vnf2Net() throws Exception {
266 mockOof(wireMockServer);
268 String businessKey = UUID.randomUUID().toString();
269 Map<String, Object> variables = new HashMap<>();
270 setVariables2(variables);
272 invokeSubProcess("Homing", businessKey, variables);
274 injectWorkflowMessages(callbacks, "oof3");
276 waitForProcessEnd(businessKey, 10000);
279 WorkflowException workflowException =
280 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
281 ServiceDecomposition serviceDecompositionExp =
282 (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
283 String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
285 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
286 HomingSolution resourceARHoming = resourceAR.getHomingSolution();
287 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
288 HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
289 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
290 HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
291 Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet");
292 HomingSolution resourceNetHoming = resourceNet.getHomingSolution();
293 Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2");
294 HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution();
296 String resourceARHomingString = resourceARHoming.toString();
297 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
298 String resourceARHoming2String = resourceARHoming2.toString();
299 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
300 String resourceVNFHomingString = resourceVNFHoming.toString();
301 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
302 String resourceNetHomingString = resourceNetHoming.toString();
303 resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " ");
304 String resourceNetHoming2String = resourceNetHoming2.toString();
305 resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " ");
306 expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
309 assertNull(workflowException);
310 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", resourceARHoming.getVnf().getResourceId(),
311 "aic", "dfwtx", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
312 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
313 resourceARHomingString);
315 homingSolutionService("service", "testSIID2", "testVnfHostname2",
316 resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null),
317 resourceARHoming2String);
319 homingSolutionCloud("cloud", "aic", "testCloudRegionId3", true,
320 "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
321 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
322 resourceVNFHomingString);
324 homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet",
325 resourceNetHoming.getVnf().getResourceId(), "aic", "testCloudRegionIdNet", null, null),
326 resourceNetHomingString);
328 homingSolutionCloud("cloud", "aic", "testCloudRegionIdNet2", false,
329 "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"",
330 "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""),
331 resourceNetHoming2String);
332 assertEquals(verifyOofRequest(), expectedOofRequest);
337 public void testHoming_success_vnfResourceList() throws Exception {
339 // Create a Service Decomposition
340 MockGetServiceResourcesCatalogDataByModelUuid(wireMockServer, "2f7f309d-c842-4644-a2e4-34167be5eeb4",
341 "/BuildingBlocks/oofCatalogResp.json");
342 String busKey = UUID.randomUUID().toString();
343 Map<String, Object> vars = new HashMap<>();
344 setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
345 invokeSubProcess("DecomposeService", busKey, vars);
347 ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition");
348 System.out.println("In testHoming_success_vnfResourceList, ServiceDecomposition = " + sd);
349 List<VnfResource> vnfResourceList = sd.getVnfResources();
350 vnfResourceList.get(0).setResourceId("test-resource-id-000");
354 mockOof(wireMockServer);
356 String businessKey = UUID.randomUUID().toString();
357 Map<String, Object> variables = new HashMap<>();
358 variables.put("homingService", "oof");
359 variables.put("isDebugLogEnabled", "true");
360 variables.put("msoRequestId", "testRequestId");
361 variables.put("serviceInstanceId", "testServiceInstanceId");
362 variables.put("serviceDecomposition", sd);
363 variables.put("subscriberInfo", subscriber2);
364 HashMap customerLocation = new HashMap<String, Object>();
365 customerLocation.put("customerLatitude", "32.89748");
366 customerLocation.put("customerLongitude", "-97.040443");
367 customerLocation.put("customerName", "xyz");
368 variables.put("customerLatitude", "32.89748");
369 variables.put("customerLongitude", "-97.040443");
370 variables.put("customerName", "xyz");
371 variables.put("customerLocation", customerLocation);
372 variables.put("cloudOwner", "amazon");
373 variables.put("cloudRegionId", "TNZED");
375 invokeSubProcess("Homing", businessKey, variables);
376 injectWorkflowMessages(callbacks, "oof3");
377 waitForProcessEnd(businessKey, 10000);
381 WorkflowException workflowException =
382 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
383 ServiceDecomposition serviceDecompositionExp =
384 (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
385 System.out.println("serviceDecompositionExp is: " + serviceDecompositionExp);
387 Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
388 System.out.println("resourceVnf is: " + resourceVnf);
389 HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution();
391 String resourceVnfHomingString = resourceVnfHoming.toString();
392 System.out.println("resourceVnfHomingString is: " + resourceVnfHomingString);
393 resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " ");
394 System.out.println("Now resourceVnfHomingString is: " + resourceVnfHomingString);
396 assertNull(workflowException);
399 String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
400 System.out.println("oofRequest is: " + oofRequest);
402 FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").replaceAll("\n", "")
403 .replaceAll("\r", "").replaceAll("\t", ""),
404 oofRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""));
406 // System.out.println("resourceVnfHoming.getVnf().getResourceId() is: " +
407 // resourceVnfHoming.getVnf().getResourceId());
410 homingSolutionService("service", "service-instance-01234", "MDTNJ01", "test-resource-id-000",
411 "CloudOwner", "mtmnj1a",
412 "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
413 "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
414 resourceVnfHomingString);
418 public void testHoming_success_existingLicense() throws Exception {
420 mockOof(wireMockServer);
422 String businessKey = UUID.randomUUID().toString();
423 Map<String, Object> variables = new HashMap<String, Object>();
424 setVariablesExistingLicense(variables);
426 invokeSubProcess("Homing", businessKey, variables);
428 injectWorkflowMessages(callbacks, "sniro");
430 waitForProcessEnd(businessKey, 10000);
433 WorkflowException workflowException =
434 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
435 ServiceDecomposition serviceDecompositionExp =
436 (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
437 String oofRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
439 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
440 HomingSolution resourceARHoming = (HomingSolution) resourceAR.getHomingSolution();
441 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
442 HomingSolution resourceARHoming2 = (HomingSolution) resourceAR2.getHomingSolution();
443 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
444 HomingSolution resourceVNFHoming = (HomingSolution) resourceVNF.getHomingSolution();
445 String resourceARHomingString = resourceARHoming.toString();
446 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
447 String resourceARHoming2String = resourceARHoming2.toString();
448 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
449 String resourceVNFHomingString = resourceVNFHoming.toString();
450 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
451 oofRequest = oofRequest.replaceAll("\\s+", "");
453 assertNull(workflowException);
455 homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01",
456 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
457 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
458 resourceARHomingString);
460 homingSolutionService("service", "testSIID2", "testVnfHostname2",
461 resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null),
462 resourceARHoming2String);
464 homingSolutionCloud("cloud", "aic", "testCloudRegionId3", false,
465 "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
466 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
467 resourceVNFHomingString);
468 assertEquals(verifyOofRequestExistingLicense(), oofRequest);
473 public void testHoming_error_inputVariable() throws Exception {
475 String businessKey = UUID.randomUUID().toString();
476 Map<String, Object> variables = new HashMap<>();
477 setVariables3(variables);
479 invokeSubProcess("Homing", businessKey, variables);
481 waitForProcessEnd(businessKey, 10000);
484 WorkflowException workflowException =
485 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
487 assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required "
488 + "input variable is missing or null,workStep=*]", workflowException.toString());
492 public void testHoming_error_badResponse() throws Exception {
493 mockOof_500(wireMockServer);
495 String businessKey = UUID.randomUUID().toString();
496 Map<String, Object> variables = new HashMap<>();
497 setVariables(variables);
499 invokeSubProcess("Homing", businessKey, variables);
501 waitForProcessEnd(businessKey, 10000);
504 WorkflowException workflowException =
505 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
508 "WorkflowException[processKey=Homing,errorCode=401,errorMessage=Internal Error - BasicAuth value null,workStep=*]",
509 workflowException.toString());
513 public void testHoming_error_oofNoSolution() throws Exception {
514 mockOof(wireMockServer);
516 String businessKey = UUID.randomUUID().toString();
517 Map<String, Object> variables = new HashMap<>();
518 setVariables(variables);
520 invokeSubProcess("Homing", businessKey, variables);
522 injectWorkflowMessages(callbacks, "oofNoSol");
524 waitForProcessEnd(businessKey, 10000);
527 WorkflowException workflowException =
528 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
529 Boolean errorMatch = workflowException.toString()
530 .contains("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback "
531 + "Response contains error: Unable to find any candidate for demand *** Response:");
536 public void testHoming_error_oofPolicyException() throws Exception {
537 mockOof(wireMockServer);
539 String businessKey = UUID.randomUUID().toString();
540 Map<String, Object> variables = new HashMap<>();
541 setVariables(variables);
543 invokeSubProcess("Homing", businessKey, variables);
545 injectWorkflowMessages(callbacks, "oofPolicyEx");
547 waitForProcessEnd(businessKey, 10000);
550 WorkflowException workflowException =
551 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
553 assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback "
554 + "Response contains a Request Error Policy Exception: Message content size exceeds the allowable "
555 + "limit]", workflowException.toString());
559 public void testHoming_error_oofServiceException() throws Exception {
560 mockOof(wireMockServer);
562 String businessKey = UUID.randomUUID().toString();
563 Map<String, Object> variables = new HashMap<>();
564 setVariables(variables);
566 invokeSubProcess("Homing", businessKey, variables);
567 injectWorkflowMessages(callbacks, "oofServiceEx");
568 waitForProcessEnd(businessKey, 10000);
571 WorkflowException workflowException =
572 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
575 "WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback "
576 + "Response contains a Request Error Service Exception: OOF PlacementError: "
577 + "requests.exceptions.HTTPError: 404 Client Error: Not Found for "
578 + "url: http://192.168.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]",
579 workflowException.toString());
583 private void setVariables(Map<String, Object> variables) {
584 variables.put("homingService", "oof");
585 HashMap customerLocation = new HashMap<String, Object>();
586 customerLocation.put("customerLatitude", "32.89748");
587 customerLocation.put("customerLongitude", "-97.040443");
588 customerLocation.put("customerName", "xyz");
589 variables.put("customerLatitude", "32.89748");
590 variables.put("customerLongitude", "-97.040443");
591 variables.put("customerName", "xyz");
592 variables.put("customerLocation", customerLocation);
593 variables.put("cloudOwner", "amazon");
594 variables.put("cloudRegionId", "TNZED");
595 variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR");
596 variables.put("vgMuxInfraModelId", "testArModelUuid");
597 // variables.put("mso-request-id", "testRequestId");
598 variables.put("msoRequestId", "testRequestId");
599 variables.put("serviceInstanceId", "testServiceInstanceId123");
600 variables.put("serviceInstanceName", "testServiceName");
601 variables.put("serviceDecomposition", serviceDecomposition);
602 variables.put("subscriberInfo", subscriber2);
605 private void setVariables2(Map<String, Object> variables) {
606 List<NetworkResource> netList = new ArrayList<NetworkResource>();
607 NetworkResource net = new NetworkResource();
608 net.setResourceId("testResourceIdNet");
609 ModelInfo netModel = new ModelInfo();
610 netModel.setModelCustomizationUuid("testModelCustomizationUuidNet");
611 netModel.setModelInvariantUuid("testModelInvariantIdNet");
612 netModel.setModelName("testModelNameNet");
613 netModel.setModelVersion("testModelVersionNet");
614 net.setModelInfo(netModel);
616 NetworkResource net2 = new NetworkResource();
617 net2.setResourceId("testResourceIdNet2");
618 ModelInfo netModel2 = new ModelInfo();
619 netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2");
620 netModel2.setModelCustomizationName("testModelCustomizationNameNet2");
621 netModel2.setModelInvariantUuid("testModelInvariantIdNet2");
622 netModel2.setModelName("testModelNameNet2");
623 netModel2.setModelVersion("testModelVersionNet2");
624 net2.setModelInfo(netModel2);
626 serviceDecomposition.setNetworkResources(netList);
628 variables.put("homingService", "oof");
629 HashMap customerLocation = new HashMap<String, Object>();
630 customerLocation.put("customerLatitude", "32.89748");
631 customerLocation.put("customerLongitude", "-97.040443");
632 customerLocation.put("customerName", "xyz");
633 variables.put("customerLatitude", "32.89748");
634 variables.put("customerLongitude", "-97.040443");
635 variables.put("customerName", "xyz");
636 variables.put("customerLocation", customerLocation);
637 variables.put("cloudOwner", "amazon");
638 variables.put("cloudRegionId", "TNZED");
639 variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR");
640 variables.put("vgMuxInfraModelId", "testArModelUuid");
641 variables.put("isDebugLogEnabled", "true");
642 variables.put("msoRequestId", "testRequestId");
643 variables.put("serviceInstanceId", "testServiceInstanceId123");
644 variables.put("serviceInstanceName", "testServiceName");
645 variables.put("serviceDecomposition", serviceDecomposition);
646 variables.put("subscriberInfo", subscriber2);
649 private void setVariables3(Map<String, Object> variables) {
650 variables.put("homingService", "oof");
651 HashMap customerLocation = new HashMap<String, Object>();
652 customerLocation.put("customerLatitude", "32.89748");
653 customerLocation.put("customerLongitude", "-97.040443");
654 customerLocation.put("customerName", "xyz");
655 variables.put("customerLatitude", "32.89748");
656 variables.put("customerLongitude", "-97.040443");
657 variables.put("customerName", "xyz");
658 variables.put("customerLocation", customerLocation);
659 variables.put("cloudOwner", "amazon");
660 variables.put("cloudRegionId", "TNZED");
661 variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR");
662 variables.put("vgMuxInfraModelId", "testArModelUuid");
663 variables.put("isDebugLogEnabled", "true");
664 // variables.put("mso-request-id", "testRequestId");
665 variables.put("msoRequestId", "testRequestId");
666 variables.put("serviceInstanceId", "testServiceInstanceId123");
667 variables.put("serviceInstanceName", "testServiceName");
668 variables.put("serviceDecomposition", null);
669 variables.put("subscriberInfo", subscriber2);
672 private void setVariablesExistingLicense(Map<String, Object> variables) {
673 HomingSolution currentHomingSolution = new HomingSolution();
674 serviceDecomposition.getVnfResources().get(0).setCurrentHomingSolution(currentHomingSolution);
675 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
676 .addEntitlementPool("testEntitlementPoolId1");
677 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
678 .addEntitlementPool("testEntitlementPoolId2");
680 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
681 .addLicenseKeyGroup("testLicenseKeyGroupId1");
682 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
683 .addLicenseKeyGroup("testLicenseKeyGroupId2");
685 variables.put("isDebugLogEnabled", "true");
686 variables.put("msoRequestId", "testRequestId");
687 variables.put("serviceInstanceId", "testServiceInstanceId");
688 variables.put("serviceDecomposition", serviceDecomposition);
689 variables.put("subscriberInfo", subscriber2);
693 private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname,
694 String vnfResourceId, String cloudOwner, String cloudRegionId, String enList, String licenseList) {
696 String solution = "";
697 if (enList == null) {
698 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \""
699 + serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \""
700 + cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId
701 + "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :"
702 + " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { },"
703 + " \"rehome\" : false } }";
706 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \""
707 + serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \""
708 + cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :"
709 + " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :"
710 + " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :"
711 + " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList
712 + " ] }, \"rehome\" : false } }";
717 private String homingSolutionCloud(String type, String cloudOwner, String cloudRegionId, Boolean flavors,
718 String enList, String licenseList) {
719 String solution = "";
720 if (enList == null) {
721 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
722 + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"license\" : { }, \"rehome\" : false } }";
723 } else if (flavors && enList == null) {
724 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
725 + "\", \"cloudRegionId\" : \"" + cloudRegionId
726 + "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, "
727 + "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], "
728 + "\"license\" : { }, \"rehome\" : false } }";
729 } else if (flavors) {
730 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
731 + "\", \"cloudRegionId\" : \"" + cloudRegionId
732 + "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, "
733 + "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], "
734 + "\"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ "
735 + licenseList + " ] }, \"rehome\" : false } }";
737 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
738 + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"license\" : { \"entitlementPoolList\" : [ "
739 + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
744 private void setVariablesForServiceDecomposition(Map<String, Object> variables, String requestId, String siId) {
745 variables.put("homingService", "oof");
746 variables.put("isDebugLogEnabled", "true");
747 variables.put("mso-request-id", requestId);
748 variables.put("msoRequestId", requestId);
749 variables.put("serviceInstanceId", siId);
750 HashMap customerLocation = new HashMap<String, Object>();
751 customerLocation.put("customerLatitude", "32.89748");
752 customerLocation.put("customerLongitude", "-97.040443");
753 customerLocation.put("customerName", "xyz");
754 variables.put("customerLatitude", "32.89748");
755 variables.put("customerLongitude", "-97.040443");
756 variables.put("customerName", "xyz");
757 variables.put("customerLocation", customerLocation);
758 variables.put("cloudOwner", "amazon");
759 variables.put("cloudRegionId", "TNZED");
762 String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":"
763 + "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}";
764 variables.put("serviceModelInfo", serviceModelInfo);
767 private String verifyOofRequest() {
768 String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\","
769 + "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\","
770 + "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"],"
771 + "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":"
772 + "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":"
773 + "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\","
774 + "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"testARFunctionName\""
775 + ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":"
776 + "\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\","
777 + "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\",\"modelType\":"
778 + "\"\",\"modelVersion\":\"\",\"modelCustomizationName\":\"\"}},"
779 + "{\"resourceModuleName\":\"testAR2FunctionName\",\"serviceResourceId\":\"testResourceIdAR2\","
780 + "\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\","
781 + "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\","
782 + "\"modelType\":\"\",\"modelVersion\":\"\","
783 + "\"modelCustomizationName\":\"\"}},{\"resourceModuleName\":\"testVnfFunctionName\",\"serviceResourceId\":\""
784 + "testResourceIdVNF\",\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\""
785 + ":\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":\""
786 + "testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\""
787 + ",\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":"
788 + "{\"serviceInstanceId\":\"testServiceInstanceId123\","
789 + "\"serviceName\":\"testServiceName\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":"
790 + "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\","
791 + "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" + "\"}}}";
795 private String verifyOofRequestExistingLicense() {
796 String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\","
797 + "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\","
798 + "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"],"
799 + "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\","
800 + "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":"
801 + "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":"
802 + "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\","
803 + "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":"
804 + "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\","
805 + "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\","
806 + "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\","
807 + "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":"
808 + "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":"
809 + "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":"
810 + "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\","
811 + "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\","
812 + "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\","
813 + "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":"
814 + "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\","
815 + "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":"
816 + "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\","
817 + "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\","
818 + "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"},"
819 + "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\","
820 + "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\","
821 + "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":"
822 + "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";