2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2020 Nokia
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.infrastructure.workflow.tasks;
25 import org.camunda.bpm.engine.delegate.BpmnError;
26 import org.camunda.bpm.engine.delegate.DelegateExecution;
27 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
28 import org.junit.Before;
29 import org.junit.Rule;
30 import org.junit.Test;
31 import org.junit.rules.ExpectedException;
32 import org.mockito.ArgumentCaptor;
33 import org.mockito.InjectMocks;
34 import org.mockito.Mock;
35 import org.mockito.Mockito;
36 import org.mockito.Spy;
37 import org.onap.aai.domain.yang.Configuration;
38 import org.onap.aai.domain.yang.GenericVnf;
39 import org.onap.aai.domain.yang.InstanceGroup;
40 import org.onap.aai.domain.yang.L3Network;
41 import org.onap.aai.domain.yang.ServiceInstance;
42 import org.onap.aai.domain.yang.VfModule;
43 import org.onap.aai.domain.yang.VolumeGroup;
44 import org.onap.so.bpmn.BaseTaskTest;
45 import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner;
46 import org.onap.so.bpmn.core.WorkflowException;
47 import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
48 import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
49 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
50 import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
51 import org.onap.so.client.namingservice.NamingRequestObject;
52 import org.onap.so.db.catalog.beans.ConfigurationResource;
53 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
54 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
55 import org.onap.so.db.request.beans.InfraActiveRequests;
56 import org.onap.so.serviceinstancebeans.ModelInfo;
57 import org.onap.so.serviceinstancebeans.RequestDetails;
58 import org.springframework.core.env.Environment;
59 import java.util.ArrayList;
60 import java.util.Collections;
61 import java.util.List;
62 import java.util.Optional;
63 import static org.assertj.core.api.Assertions.assertThat;
64 import static org.junit.Assert.assertEquals;
65 import static org.junit.Assert.assertFalse;
66 import static org.junit.Assert.assertTrue;
67 import static org.mockito.ArgumentMatchers.any;
68 import static org.mockito.ArgumentMatchers.anyObject;
69 import static org.mockito.ArgumentMatchers.anyString;
70 import static org.mockito.ArgumentMatchers.isA;
71 import static org.mockito.Mockito.doNothing;
72 import static org.mockito.Mockito.doReturn;
73 import static org.mockito.Mockito.times;
74 import static org.mockito.Mockito.verify;
75 import static org.mockito.Mockito.when;
77 public class WorkflowActionBBTasksTest extends BaseTaskTest {
79 private static final String SAMPLE_MSO_REQUEST_ID = "00f704ca-c5e5-4f95-a72c-6889db7b0688";
80 private static final String SAMPLE_REQUEST_ACTION = "Delete-Network-Collection";
81 private static final int SAMPLE_SEQUENCE = 0;
82 private static final String EMPTY_STRING = "";
84 protected WorkflowAction workflowAction;
87 protected WorkflowActionBBFailure workflowActionBBFailure;
91 protected WorkflowActionBBTasks workflowActionBBTasks;
94 InfraActiveRequests reqMock;
96 private DelegateExecution execution;
99 protected Environment environment;
102 private FlowManipulatorListenerRunner flowManipulatorListenerRunner;
105 public ExpectedException thrown = ExpectedException.none();
108 private DelegateExecution mockExecution;
111 public void before() throws Exception {
112 execution = new DelegateExecutionFake();
113 ServiceInstance servInstance = new ServiceInstance();
114 servInstance.setServiceInstanceId("TEST");
115 when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
116 workflowAction.setBbInputSetupUtils(bbSetupUtils);
117 workflowAction.setBbInputSetup(bbInputSetup);
121 public void selectBBTest() {
122 String vnfCustomizationUUID = "1234567";
123 String modelUuid = "1234567";
124 prepareDelegateExecution();
125 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
127 BuildingBlock buildingBlock =
128 new BuildingBlock().setBpmnFlowName("ConfigAssignVnfBB").setKey(vnfCustomizationUUID);
129 RequestDetails rd = new RequestDetails();
130 ModelInfo mi = new ModelInfo();
131 mi.setModelUuid(modelUuid);
133 ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd);
134 flowsToExecute.add(ebb);
136 List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
137 VnfResourceCustomization vrc = new VnfResourceCustomization();
138 vrc.setSkipPostInstConf(false);
139 vrc.setModelCustomizationUUID(vnfCustomizationUUID);
140 vnfResourceCustomizations.add(vrc);
141 GenericVnf genericVnf = new GenericVnf();
142 genericVnf.setModelCustomizationId(vnfCustomizationUUID);
143 doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid);
144 doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID,
145 vnfResourceCustomizations);
147 execution.setVariable("flowsToExecute", flowsToExecute);
148 workflowActionBBTasks.selectBB(execution);
149 boolean success = (boolean) execution.getVariable("completed");
150 int currentSequence = (int) execution.getVariable("gCurrentSequence");
152 assertEquals(1, currentSequence);
156 public void select2BBTest() {
157 String vnfCustomizationUUID = "1234567";
158 String modelUuid = "1234567";
160 prepareDelegateExecution();
161 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
162 BuildingBlock buildingBlock =
163 new BuildingBlock().setBpmnFlowName("ConfigDeployVnfBB").setKey(vnfCustomizationUUID);
164 RequestDetails rd = new RequestDetails();
165 ModelInfo mi = new ModelInfo();
166 mi.setModelUuid(modelUuid);
168 ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd);
169 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
171 flowsToExecute.add(ebb);
173 List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
174 VnfResourceCustomization vrc = new VnfResourceCustomization();
176 vrc.setSkipPostInstConf(false);
177 vrc.setModelCustomizationUUID(vnfCustomizationUUID);
178 vnfResourceCustomizations.add(vrc);
179 GenericVnf genericVnf = new GenericVnf();
180 genericVnf.setModelCustomizationId(vnfCustomizationUUID);
182 doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid);
183 doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID,
184 vnfResourceCustomizations);
186 flowsToExecute.add(ebb2);
187 execution.setVariable("flowsToExecute", flowsToExecute);
188 workflowActionBBTasks.selectBB(execution);
189 boolean success = (boolean) execution.getVariable("completed");
190 int currentSequence = (int) execution.getVariable("gCurrentSequence");
191 assertFalse(success);
192 assertEquals(1, currentSequence);
196 public void updateRequestStatusToCompleteTest() {
197 String reqId = "reqId123";
198 execution.setVariable("mso-request-id", reqId);
199 execution.setVariable("requestAction", "createInstance");
200 execution.setVariable("resourceName", "Service");
201 execution.setVariable("aLaCarte", true);
202 InfraActiveRequests req = new InfraActiveRequests();
203 doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
204 doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
205 workflowActionBBTasks.updateRequestStatusToComplete(execution);
206 assertEquals("ALaCarte-Service-createInstance request was executed correctly.",
207 execution.getVariable("finalStatusMessage"));
211 public void rollbackExecutionPathTest() {
212 execution.setVariable("handlingCode", "Rollback");
213 execution.setVariable("isRollback", false);
214 execution.setVariable("requestAction", EMPTY_STRING);
215 execution.setVariable("resourceName", EMPTY_STRING);
216 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
217 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
218 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
219 flowsToExecute.add(ebb1);
221 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
222 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
223 flowsToExecute.add(ebb2);
225 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
226 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
227 flowsToExecute.add(ebb3);
229 execution.setVariable("flowsToExecute", flowsToExecute);
230 execution.setVariable("gCurrentSequence", 3);
231 doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
233 workflowActionBBTasks.rollbackExecutionPath(execution);
234 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
235 assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeactivateVfModuleBB");
236 assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
237 assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
238 assertEquals(0, execution.getVariable("gCurrentSequence"));
242 public void rollbackExecutionPathUnfinishedFlowTest() {
243 execution.setVariable("handlingCode", "Rollback");
244 execution.setVariable("isRollback", false);
245 execution.setVariable("requestAction", EMPTY_STRING);
246 execution.setVariable("resourceName", EMPTY_STRING);
247 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
248 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
249 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
250 flowsToExecute.add(ebb1);
252 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
253 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
254 flowsToExecute.add(ebb2);
256 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
257 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
258 flowsToExecute.add(ebb3);
260 execution.setVariable("flowsToExecute", flowsToExecute);
261 execution.setVariable("gCurrentSequence", 2);
262 doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
264 workflowActionBBTasks.rollbackExecutionPath(execution);
265 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
266 assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
267 assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
268 assertEquals(0, execution.getVariable("gCurrentSequence"));
269 assertEquals(0, execution.getVariable("retryCount"));
273 public void rollbackExecutionTest() {
274 execution.setVariable("handlingCode", "Rollback");
275 execution.setVariable("isRollback", false);
276 execution.setVariable("requestAction", EMPTY_STRING);
277 execution.setVariable("resourceName", EMPTY_STRING);
278 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
279 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB");
280 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
281 flowsToExecute.add(ebb1);
283 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateNetworkCollectionBB");
284 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
285 flowsToExecute.add(ebb2);
287 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB");
288 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
289 flowsToExecute.add(ebb3);
291 BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB");
292 ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
293 flowsToExecute.add(ebb4);
295 execution.setVariable("flowsToExecute", flowsToExecute);
296 execution.setVariable("gCurrentSequence", 3);
297 doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
299 workflowActionBBTasks.rollbackExecutionPath(execution);
300 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
301 assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "UnassignNetworkBB");
302 assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "DeleteNetworkCollectionBB");
303 assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(), "UnassignServiceInstanceBB");
304 assertEquals(0, execution.getVariable("gCurrentSequence"));
308 public void rollbackExecutionRollbackToAssignedTest() {
309 execution.setVariable("isRollback", false);
310 execution.setVariable("handlingCode", "RollbackToAssigned");
311 execution.setVariable("requestAction", EMPTY_STRING);
312 execution.setVariable("resourceName", EMPTY_STRING);
313 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
315 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
316 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
317 flowsToExecute.add(ebb1);
319 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
320 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
321 flowsToExecute.add(ebb2);
323 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
324 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
325 flowsToExecute.add(ebb3);
327 execution.setVariable("flowsToExecute", flowsToExecute);
328 execution.setVariable("gCurrentSequence", 2);
330 workflowActionBBTasks.rollbackExecutionPath(execution);
331 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
332 assertEquals("DeleteVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
333 assertEquals(0, execution.getVariable("gCurrentSequence"));
334 assertEquals(1, ebbs.size());
338 public void rollbackExecutionPathChangeBBForReplaceVFModuleTest() {
339 execution.setVariable("handlingCode", "Rollback");
340 execution.setVariable("isRollback", false);
341 execution.setVariable("requestAction", "replaceInstance");
342 execution.setVariable("resourceName", "VfModule");
343 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
344 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
345 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
346 flowsToExecute.add(ebb1);
348 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
349 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
350 flowsToExecute.add(ebb2);
352 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
353 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
354 flowsToExecute.add(ebb3);
357 BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("ChangeModelVnfBB");
358 ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
359 flowsToExecute.add(ebb4);
361 BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("ChangeModelServiceInstanceBB");
362 ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
363 flowsToExecute.add(ebb5);
365 execution.setVariable("flowsToExecute", flowsToExecute);
366 execution.setVariable("gCurrentSequence", 5);
367 doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
369 workflowActionBBTasks.rollbackExecutionPath(execution);
370 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
371 assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "ChangeModelVnfBB");
372 assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "ChangeModelServiceInstanceBB");
373 assertEquals(0, execution.getVariable("gCurrentSequence"));
377 public void rollbackExecutionRollbackToAssignedWithFabricTest() {
378 execution.setVariable("isRollback", false);
379 execution.setVariable("handlingCode", "RollbackToAssigned");
380 execution.setVariable("requestAction", EMPTY_STRING);
381 execution.setVariable("resourceName", EMPTY_STRING);
382 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
384 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
385 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
386 flowsToExecute.add(ebb1);
388 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
389 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
390 flowsToExecute.add(ebb2);
392 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
393 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
394 flowsToExecute.add(ebb3);
396 BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
397 ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
398 flowsToExecute.add(ebb4);
400 execution.setVariable("flowsToExecute", flowsToExecute);
401 execution.setVariable("gCurrentSequence", 4);
403 workflowActionBBTasks.rollbackExecutionPath(execution);
404 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
405 assertEquals(0, execution.getVariable("gCurrentSequence"));
406 assertEquals(3, ebbs.size());
407 assertEquals("DeleteFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
408 assertEquals("DeactivateVfModuleBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
409 assertEquals("DeleteVfModuleBB", ebbs.get(2).getBuildingBlock().getBpmnFlowName());
414 public void rollbackExecutionRollbackToCreatedWithFabricTest() {
415 execution.setVariable("isRollback", false);
416 execution.setVariable("handlingCode", "RollbackToCreated");
417 execution.setVariable("requestAction", EMPTY_STRING);
418 execution.setVariable("resourceName", EMPTY_STRING);
419 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
421 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
422 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
423 flowsToExecute.add(ebb1);
425 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
426 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
427 flowsToExecute.add(ebb2);
429 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
430 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
431 flowsToExecute.add(ebb3);
433 BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
434 ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
435 flowsToExecute.add(ebb4);
437 execution.setVariable("flowsToExecute", flowsToExecute);
438 execution.setVariable("gCurrentSequence", 4);
440 workflowActionBBTasks.rollbackExecutionPath(execution);
441 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
442 assertEquals(0, execution.getVariable("gCurrentSequence"));
443 assertEquals(2, ebbs.size());
444 assertEquals("DeleteFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
445 assertEquals("DeactivateVfModuleBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
450 public void rollbackExecutionRollbackToCreatedNoConfigurationWithFabricTest() {
451 execution.setVariable("isRollback", false);
452 execution.setVariable("handlingCode", "RollbackToCreatedNoConfiguration");
453 execution.setVariable("requestAction", EMPTY_STRING);
454 execution.setVariable("resourceName", EMPTY_STRING);
455 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
457 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
458 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
459 flowsToExecute.add(ebb1);
461 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
462 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
463 flowsToExecute.add(ebb2);
465 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
466 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
467 flowsToExecute.add(ebb3);
469 BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
470 ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
471 flowsToExecute.add(ebb4);
473 execution.setVariable("flowsToExecute", flowsToExecute);
474 execution.setVariable("gCurrentSequence", 4);
476 workflowActionBBTasks.rollbackExecutionPath(execution);
477 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
478 assertEquals(0, execution.getVariable("gCurrentSequence"));
479 assertEquals(1, ebbs.size());
480 assertEquals("DeactivateVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
484 public void rollbackExecutionRollbackToCreatedTest() {
485 execution.setVariable("isRollback", false);
486 execution.setVariable("handlingCode", "RollbackToCreated");
487 execution.setVariable("requestAction", EMPTY_STRING);
488 execution.setVariable("resourceName", EMPTY_STRING);
489 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
490 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
491 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
492 flowsToExecute.add(ebb1);
494 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
495 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
496 flowsToExecute.add(ebb2);
498 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
499 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
500 flowsToExecute.add(ebb3);
502 execution.setVariable("flowsToExecute", flowsToExecute);
503 execution.setVariable("gCurrentSequence", 3);
505 workflowActionBBTasks.rollbackExecutionPath(execution);
506 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
507 assertEquals("DeactivateVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
508 assertEquals(0, execution.getVariable("gCurrentSequence"));
509 assertEquals(1, ebbs.size());
513 public void rollbackExecutionRollbackInPlaceSoftwareUpdateTest() {
514 execution.setVariable("isRollback", false);
515 execution.setVariable("handlingCode", "Rollback");
516 execution.setVariable("requestAction", EMPTY_STRING);
517 execution.setVariable("resourceName", EMPTY_STRING);
518 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
519 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity");
520 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
521 flowsToExecute.add(ebb1);
523 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("VNFCheckInMaintFlagActivity");
524 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
525 flowsToExecute.add(ebb2);
527 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("VNFSetInMaintFlagActivity");
528 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
529 flowsToExecute.add(ebb3);
531 BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("VNFCheckClosedLoopDisabledFlagActivity");
532 ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
533 flowsToExecute.add(ebb4);
535 BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("VNFSetClosedLoopDisabledFlagActivity");
536 ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
537 flowsToExecute.add(ebb5);
539 BuildingBlock buildingBlock6 = new BuildingBlock().setBpmnFlowName("VNFLockActivity");
540 ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock6);
541 flowsToExecute.add(ebb6);
543 BuildingBlock buildingBlock7 = new BuildingBlock().setBpmnFlowName("VNFUpgradePreCheckActivity");
544 ExecuteBuildingBlock ebb7 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock7);
545 flowsToExecute.add(ebb7);
547 BuildingBlock buildingBlock8 = new BuildingBlock().setBpmnFlowName("VNFQuiesceTrafficActivity");
548 ExecuteBuildingBlock ebb8 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock8);
549 flowsToExecute.add(ebb8);
551 BuildingBlock buildingBlock9 = new BuildingBlock().setBpmnFlowName("VNFStopActivity");
552 ExecuteBuildingBlock ebb9 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock9);
553 flowsToExecute.add(ebb9);
555 BuildingBlock buildingBlock10 = new BuildingBlock().setBpmnFlowName("VNFSnapShotActivity");
556 ExecuteBuildingBlock ebb10 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock10);
557 flowsToExecute.add(ebb10);
559 execution.setVariable("flowsToExecute", flowsToExecute);
560 execution.setVariable("gCurrentSequence", 10);
562 workflowActionBBTasks.rollbackExecutionPath(execution);
563 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
564 assertEquals("VNFStartActivity", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
565 assertEquals("VNFResumeTrafficActivity", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
566 assertEquals("VNFUnlockActivity", ebbs.get(2).getBuildingBlock().getBpmnFlowName());
567 assertEquals("VNFUnsetClosedLoopDisabledFlagActivity", ebbs.get(3).getBuildingBlock().getBpmnFlowName());
568 assertEquals("VNFUnsetInMaintFlagActivity", ebbs.get(4).getBuildingBlock().getBpmnFlowName());
569 assertEquals(0, execution.getVariable("gCurrentSequence"));
570 assertEquals(5, ebbs.size());
574 public void rollbackExecutionRollbackConfigModifyTest() {
575 execution.setVariable("isRollback", false);
576 execution.setVariable("handlingCode", "Rollback");
577 execution.setVariable("requestAction", EMPTY_STRING);
578 execution.setVariable("resourceName", EMPTY_STRING);
579 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
580 BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity");
581 ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
582 flowsToExecute.add(ebb1);
584 BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("VNFCheckInMaintFlagActivity");
585 ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
586 flowsToExecute.add(ebb2);
588 BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("VNFSetInMaintFlagActivity");
589 ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
590 flowsToExecute.add(ebb3);
592 BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("VNFCheckClosedLoopDisabledFlagActivity");
593 ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
594 flowsToExecute.add(ebb4);
596 BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("VNFSetClosedLoopDisabledFlagActivity");
597 ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
598 flowsToExecute.add(ebb5);
600 BuildingBlock buildingBlock6 = new BuildingBlock().setBpmnFlowName("VNFHealthCheckActivity");
601 ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock6);
602 flowsToExecute.add(ebb6);
604 execution.setVariable("flowsToExecute", flowsToExecute);
605 execution.setVariable("gCurrentSequence", 6);
607 workflowActionBBTasks.rollbackExecutionPath(execution);
608 List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
609 assertEquals("VNFUnsetClosedLoopDisabledFlagActivity", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
610 assertEquals("VNFUnsetInMaintFlagActivity", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
611 assertEquals(0, execution.getVariable("gCurrentSequence"));
612 assertEquals(2, ebbs.size());
616 public void postProcessingExecuteBBActivateVfModuleTest() throws CloneNotSupportedException {
618 BuildingBlock bbAddFabric = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
619 ExecuteBuildingBlock ebbAddFabric = new ExecuteBuildingBlock().setBuildingBlock(bbAddFabric);
620 WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
621 workflowResourceIds.setServiceInstanceId("1");
622 workflowResourceIds.setVnfId("1");
623 ebbAddFabric.setWorkflowResourceIds(workflowResourceIds);
624 ebbAddFabric.setResourceId("1");
626 BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
627 ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
628 ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds);
629 ebbActivateVfModule.setResourceId("1");
630 ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
631 ebbActivateVfModule.setConfigurationResourceKeys(configurationResourceKeys);
633 ServiceInstance service = new ServiceInstance();
634 service.setServiceInstanceName("name");
635 service.setModelVersionId("1");
636 doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1");
638 GenericVnf vnf = new GenericVnf();
639 vnf.setVnfName("name");
640 vnf.setModelCustomizationId("1");
641 doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1");
643 VfModule vfModule = new VfModule();
644 vfModule.setVfModuleName("name");
645 vfModule.setModelCustomizationId("1");
646 doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1");
648 List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
649 org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
650 vnfc.setModelInvariantId("1");
651 vnfc.setVnfcName("name");
652 vnfc.setModelCustomizationId("2");
654 doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
656 CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
657 ConfigurationResource configuration = new ConfigurationResource();
658 configuration.setToscaNodeType("FabricConfiguration");
659 configuration.setModelUUID("1");
660 vfModuleCustomization.setConfigurationResource(configuration);
662 doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2");
664 prepareDelegateExecution();
665 List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
666 flowsToExecute.add(ebbActivateVfModule);
668 ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class);
669 ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class);
670 ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
671 workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbAddFabric, flowsToExecute);
672 verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(),
673 bbCaptor.capture(), listCaptor.capture());
674 assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed"));
675 assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size());
677 ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0)
678 .getVariable("flowsToExecute")).get(0)).getConfigurationResourceKeys()
679 .getCvnfcCustomizationUUID());
682 execution.setVariable("requestAction", "replaceInstance");
683 flowsToExecute = new ArrayList<>();
684 flowsToExecute.add(ebbActivateVfModule);
685 workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute);
686 verify(workflowActionBBTasks, times(2)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(),
687 bbCaptor.capture(), listCaptor.capture());
688 assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed"));
689 assertEquals(1, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size());
691 ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0)
692 .getVariable("flowsToExecute")).get(0)).getConfigurationResourceKeys()
693 .getCvnfcCustomizationUUID());
697 public void getExecuteBBForConfigTest() throws CloneNotSupportedException {
698 BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
699 ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
701 WorkflowResourceIds resourceIdsActivateVfModule = new WorkflowResourceIds();
702 resourceIdsActivateVfModule.setServiceInstanceId("test-service-inbstance-id");
703 resourceIdsActivateVfModule.setVnfId("test-vnf-id");
704 resourceIdsActivateVfModule.setVfModuleId("test-vf-module-id");
705 resourceIdsActivateVfModule.setConfigurationId("");
707 RequestDetails requestDetails = new RequestDetails();
709 ebbActivateVfModule.setApiVersion("7");
710 ebbActivateVfModule.setaLaCarte(true);
711 ebbActivateVfModule.setRequestAction("createInstance");
712 ebbActivateVfModule.setVnfType("test-vnf-type");
713 ebbActivateVfModule.setRequestId("f6c00ae2-a205-4cbd-b055-02e553efde12");
714 ebbActivateVfModule.setRequestDetails(requestDetails);
715 ebbActivateVfModule.setWorkflowResourceIds(resourceIdsActivateVfModule);
717 ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
718 configurationResourceKeys.setCvnfcCustomizationUUID("07d64cd2-4427-4156-b11d-d14b96b3e4cb");
719 configurationResourceKeys.setVfModuleCustomizationUUID("50b61075-6ebb-4aab-a9fc-bedad9a2aa76");
720 configurationResourceKeys.setVnfResourceCustomizationUUID("a1d0e36e-34a9-431b-b5ba-4bbb72f63c7c");
721 configurationResourceKeys.setVnfcName("rdm54bvbgw5001vm018pim001");
723 ExecuteBuildingBlock ebbAddFabricConfig =
724 workflowActionBBTasks.getExecuteBBForConfig("AddFabricConfigurationBB", ebbActivateVfModule,
725 "cc7e12f9-967c-4362-8d14-e5b2bf0608a4", configurationResourceKeys);
727 assertEquals("7", ebbAddFabricConfig.getApiVersion());
728 assertTrue(ebbAddFabricConfig.isaLaCarte());
729 assertEquals("createInstance", ebbAddFabricConfig.getRequestAction());
730 assertEquals("test-vnf-type", ebbAddFabricConfig.getVnfType());
731 assertEquals("f6c00ae2-a205-4cbd-b055-02e553efde12", ebbAddFabricConfig.getRequestId());
732 assertEquals(requestDetails, ebbAddFabricConfig.getRequestDetails());
733 assertEquals("cc7e12f9-967c-4362-8d14-e5b2bf0608a4",
734 ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId());
735 assertEquals("test-service-inbstance-id", ebbAddFabricConfig.getWorkflowResourceIds().getServiceInstanceId());
736 assertEquals("test-vnf-id", ebbAddFabricConfig.getWorkflowResourceIds().getVnfId());
737 assertEquals("test-vf-module-id", ebbAddFabricConfig.getWorkflowResourceIds().getVfModuleId());
739 assertThat(ebbAddFabricConfig.getConfigurationResourceKeys()).isEqualTo(configurationResourceKeys);
740 assertThat(ebbAddFabricConfig.getWorkflowResourceIds())
741 .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds());
742 assertThat(ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId())
743 .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds().getConfigurationId());
747 public void checkRetryStatusTest() {
748 String reqId = "reqId123";
749 execution.setVariable("mso-request-id", reqId);
750 doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
751 doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
752 execution.setVariable("handlingCode", "Retry");
753 execution.setVariable("retryCount", 1);
754 execution.setVariable("gCurrentSequence", 1);
755 InfraActiveRequests req = new InfraActiveRequests();
756 doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
757 workflowActionBBTasks.checkRetryStatus(execution);
758 assertEquals(0, execution.getVariable("gCurrentSequence"));
762 public void checkRetryStatusTestExceededMaxRetries() {
763 String reqId = "reqId123";
764 execution.setVariable("mso-request-id", reqId);
765 doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
766 doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
767 execution.setVariable("handlingCode", "Retry");
768 execution.setVariable("retryCount", 6);
769 execution.setVariable("gCurrentSequence", 1);
770 InfraActiveRequests req = new InfraActiveRequests();
771 doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
773 workflowActionBBTasks.checkRetryStatus(execution);
774 } catch (BpmnError e) {
775 WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
776 assertEquals("Exceeded maximum retries. Ending flow with status Abort", exception.getErrorMessage());
781 public void checkRetryStatusNoRetryTest() {
782 String reqId = "reqId123";
783 execution.setVariable("mso-request-id", reqId);
784 execution.setVariable("retryCount", 3);
785 execution.setVariable("handlingCode", "Success");
786 execution.setVariable("gCurrentSequence", 1);
787 InfraActiveRequests req = new InfraActiveRequests();
788 doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
789 workflowActionBBTasks.checkRetryStatus(execution);
790 assertEquals(0, execution.getVariable("retryCount"));
794 public void updateInstanceId() {
795 String reqId = "req123";
796 String instanceId = "123123123";
797 execution.setVariable("mso-request-id", reqId);
798 execution.setVariable("resourceId", instanceId);
799 execution.setVariable("resourceType", WorkflowType.SERVICE);
800 doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
801 doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
802 workflowActionBBTasks.updateInstanceId(execution);
803 Mockito.verify(reqMock, Mockito.times(1)).setServiceInstanceId(instanceId);
807 public void getConfigurationId() throws Exception {
808 org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
809 vnfc.setModelInvariantId("modelInvariantId");
810 vnfc.setVnfcName("testVnfcName");
811 List<Configuration> configurations = new ArrayList<>();
812 org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
813 configuration.setConfigurationId("configurationId");
814 configuration.setModelCustomizationId("modelCustimizationId");
815 configuration.setConfigurationName("testConfigurationName");
816 configurations.add(configuration);
817 doReturn(configurations.get(0).getConfigurationId()).when(workflowActionBBTasks).getConfigurationId(vnfc);
818 assertEquals(workflowActionBBTasks.getConfigurationId(vnfc), "configurationId");
822 public void setServiceInstanceNameTest() {
823 String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
824 WorkflowType resourceType = WorkflowType.SERVICE;
825 InfraActiveRequests request = new InfraActiveRequests();
826 ServiceInstance service = new ServiceInstance();
827 service.setServiceInstanceName("serviceInstanceName");
828 doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById(resourceId);
830 workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
831 assertEquals("serviceInstanceName", request.getServiceInstanceName());
835 public void setVnfNameTest() {
836 String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
837 WorkflowType resourceType = WorkflowType.VNF;
838 InfraActiveRequests request = new InfraActiveRequests();
839 GenericVnf vnf = new GenericVnf();
840 vnf.setVnfName("vnfName");
841 doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf(resourceId);
843 workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
844 assertEquals("vnfName", request.getVnfName());
848 public void setVfModuleNameTest() {
849 String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
850 WorkflowType resourceType = WorkflowType.VFMODULE;
851 InfraActiveRequests request = new InfraActiveRequests();
852 request.setVnfId("ae5cc3e8-c13c-4d88-aaf6-694ab4977b0e");
853 VfModule vfModule = new VfModule();
854 vfModule.setVfModuleName("vfModuleName");
855 doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("ae5cc3e8-c13c-4d88-aaf6-694ab4977b0e", resourceId);
857 workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
858 assertEquals("vfModuleName", request.getVfModuleName());
862 public void setNetworkNameTest() {
863 String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
864 WorkflowType resourceType = WorkflowType.NETWORK;
865 InfraActiveRequests request = new InfraActiveRequests();
866 L3Network network = new L3Network();
867 network.setNetworkName("networkName");
868 doReturn(network).when(bbSetupUtils).getAAIL3Network(resourceId);
870 workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
871 assertEquals("networkName", request.getNetworkName());
875 public void setConfigurationNameTest() {
876 String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
877 WorkflowType resourceType = WorkflowType.CONFIGURATION;
878 InfraActiveRequests request = new InfraActiveRequests();
879 Configuration configuration = new Configuration();
880 configuration.setConfigurationName("configurationName");
881 doReturn(configuration).when(bbSetupUtils).getAAIConfiguration(resourceId);
883 workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
884 assertEquals("configurationName", request.getConfigurationName());
888 public void setInstanceGroupNameTest() {
889 String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
890 WorkflowType resourceType = WorkflowType.INSTANCE_GROUP;
891 InfraActiveRequests request = new InfraActiveRequests();
892 InstanceGroup instanceGroup = new InstanceGroup();
893 instanceGroup.setInstanceGroupName("instanceGroupName");
894 doReturn(instanceGroup).when(bbSetupUtils).getAAIInstanceGroup(resourceId);
896 workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
897 assertEquals("instanceGroupName", request.getInstanceGroupName());
901 public void setVolumeGroupNameTest() {
902 String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
903 WorkflowType resourceType = WorkflowType.VOLUMEGROUP;
904 InfraActiveRequests request = new InfraActiveRequests();
905 request.setVnfId("4aa72c90-21eb-4465-8847-997e27af6c3e");
906 VolumeGroup volumeGroup = new VolumeGroup();
907 volumeGroup.setVolumeGroupName("volumeGroupName");
908 Optional<VolumeGroup> returnVolumeGroup = Optional.of(volumeGroup);
910 doReturn(returnVolumeGroup).when(bbSetupUtils).getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId);
911 workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
913 assertEquals("volumeGroupName", request.getVolumeGroupName());
916 private void prepareDelegateExecution() {
917 execution.setVariable("mso-request-id", SAMPLE_MSO_REQUEST_ID);
918 execution.setVariable("requestAction", SAMPLE_REQUEST_ACTION);
919 execution.setVariable("gCurrentSequence", SAMPLE_SEQUENCE);
920 execution.setVariable("homing", false);
921 execution.setVariable("calledHoming", false);