aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
blob: 3290bb3dcef686ae275ea2a5c434dc2c35a82e47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
/*-
 * ============LICENSE_START=======================================================
 * ONAP - SO
 * ================================================================================
 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Modifications Copyright (c) 2020 Nokia
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.so.bpmn.infrastructure.workflow.tasks;

import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.onap.aai.domain.yang.Configuration;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.InstanceGroup;
import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner;
import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.RequestDetails;
import org.springframework.core.env.Environment;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;

public class WorkflowActionBBTasksTest extends BaseTaskTest {

    private static final String SAMPLE_MSO_REQUEST_ID = "00f704ca-c5e5-4f95-a72c-6889db7b0688";
    private static final String SAMPLE_REQUEST_ACTION = "Delete-Network-Collection";
    private static final int SAMPLE_SEQUENCE = 0;
    private static final String EMPTY_STRING = "";
    @Mock
    protected WorkflowAction workflowAction;

    @Mock
    protected WorkflowActionBBFailure workflowActionBBFailure;

    @InjectMocks
    @Spy
    protected WorkflowActionBBTasks workflowActionBBTasks;

    @Mock
    InfraActiveRequests reqMock;

    private DelegateExecution execution;

    @Mock
    protected Environment environment;

    @Mock
    private FlowManipulatorListenerRunner flowManipulatorListenerRunner;

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Before
    public void before() throws Exception {
        execution = new DelegateExecutionFake();
        ServiceInstance servInstance = new ServiceInstance();
        servInstance.setServiceInstanceId("TEST");
        when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
        workflowAction.setBbInputSetupUtils(bbSetupUtils);
        workflowAction.setBbInputSetup(bbInputSetup);
    }

    @Test
    public void selectBBTest() {
        String vnfCustomizationUUID = "1234567";
        String modelUuid = "1234567";
        prepareDelegateExecution();
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();

        BuildingBlock buildingBlock =
                new BuildingBlock().setBpmnFlowName("ConfigAssignVnfBB").setKey(vnfCustomizationUUID);
        RequestDetails rd = new RequestDetails();
        ModelInfo mi = new ModelInfo();
        mi.setModelUuid(modelUuid);
        rd.setModelInfo(mi);
        ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd);
        flowsToExecute.add(ebb);

        List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
        VnfResourceCustomization vrc = new VnfResourceCustomization();
        vrc.setSkipPostInstConf(false);
        vrc.setModelCustomizationUUID(vnfCustomizationUUID);
        vnfResourceCustomizations.add(vrc);
        GenericVnf genericVnf = new GenericVnf();
        genericVnf.setModelCustomizationId(vnfCustomizationUUID);
        doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid);
        doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID,
                vnfResourceCustomizations);

        execution.setVariable("flowsToExecute", flowsToExecute);
        workflowActionBBTasks.selectBB(execution);
        boolean success = (boolean) execution.getVariable("completed");
        int currentSequence = (int) execution.getVariable("gCurrentSequence");
        assertTrue(success);
        assertEquals(1, currentSequence);
    }

    @Test
    public void select2BBTest() {
        String vnfCustomizationUUID = "1234567";
        String modelUuid = "1234567";

        prepareDelegateExecution();
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
        BuildingBlock buildingBlock =
                new BuildingBlock().setBpmnFlowName("ConfigDeployVnfBB").setKey(vnfCustomizationUUID);
        RequestDetails rd = new RequestDetails();
        ModelInfo mi = new ModelInfo();
        mi.setModelUuid(modelUuid);
        rd.setModelInfo(mi);
        ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd);
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();

        flowsToExecute.add(ebb);

        List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
        VnfResourceCustomization vrc = new VnfResourceCustomization();

        vrc.setSkipPostInstConf(false);
        vrc.setModelCustomizationUUID(vnfCustomizationUUID);
        vnfResourceCustomizations.add(vrc);
        GenericVnf genericVnf = new GenericVnf();
        genericVnf.setModelCustomizationId(vnfCustomizationUUID);

        doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid);
        doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID,
                vnfResourceCustomizations);

        flowsToExecute.add(ebb2);
        execution.setVariable("flowsToExecute", flowsToExecute);
        workflowActionBBTasks.selectBB(execution);
        boolean success = (boolean) execution.getVariable("completed");
        int currentSequence = (int) execution.getVariable("gCurrentSequence");
        assertFalse(success);
        assertEquals(1, currentSequence);
    }

    @Test
    public void updateRequestStatusToCompleteTest() {
        String reqId = "reqId123";
        execution.setVariable("mso-request-id", reqId);
        execution.setVariable("requestAction", "createInstance");
        execution.setVariable("resourceName", "Service");
        execution.setVariable("aLaCarte", true);
        InfraActiveRequests req = new InfraActiveRequests();
        doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
        doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
        workflowActionBBTasks.updateRequestStatusToComplete(execution);
        assertEquals("ALaCarte-Service-createInstance request was executed correctly.",
                execution.getVariable("finalStatusMessage"));
    }

    @Test
    public void rollbackExecutionPathTest() {
        execution.setVariable("handlingCode", "Rollback");
        execution.setVariable("isRollback", false);
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 3);
        doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeactivateVfModuleBB");
        assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
        assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
        assertEquals(0, execution.getVariable("gCurrentSequence"));
    }

    @Test
    public void rollbackExecutionPathUnfinishedFlowTest() {
        execution.setVariable("handlingCode", "Rollback");
        execution.setVariable("isRollback", false);
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 2);
        doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
        assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
        assertEquals(0, execution.getVariable("gCurrentSequence"));
        assertEquals(0, execution.getVariable("retryCount"));
    }

    @Test
    public void rollbackExecutionTest() {
        execution.setVariable("handlingCode", "Rollback");
        execution.setVariable("isRollback", false);
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateNetworkCollectionBB");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB");
        ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
        flowsToExecute.add(ebb4);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 3);
        doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "UnassignNetworkBB");
        assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "DeleteNetworkCollectionBB");
        assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(), "UnassignServiceInstanceBB");
        assertEquals(0, execution.getVariable("gCurrentSequence"));
    }

    @Test
    public void rollbackExecutionRollbackToAssignedTest() {
        execution.setVariable("isRollback", false);
        execution.setVariable("handlingCode", "RollbackToAssigned");
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();

        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 2);

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals("DeleteVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
        assertEquals(0, execution.getVariable("gCurrentSequence"));
        assertEquals(1, ebbs.size());
    }

    @Test
    public void rollbackExecutionPathChangeBBForReplaceVFModuleTest() {
        execution.setVariable("handlingCode", "Rollback");
        execution.setVariable("isRollback", false);
        execution.setVariable("requestAction", "replaceInstance");
        execution.setVariable("resourceName", "VfModule");
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);


        BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("ChangeModelVnfBB");
        ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
        flowsToExecute.add(ebb4);

        BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("ChangeModelServiceInstanceBB");
        ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
        flowsToExecute.add(ebb5);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 5);
        doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "ChangeModelVnfBB");
        assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "ChangeModelServiceInstanceBB");
        assertEquals(0, execution.getVariable("gCurrentSequence"));
    }

    @Test
    public void rollbackExecutionRollbackToAssignedWithFabricTest() {
        execution.setVariable("isRollback", false);
        execution.setVariable("handlingCode", "RollbackToAssigned");
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();

        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
        ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
        flowsToExecute.add(ebb4);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 4);

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals(0, execution.getVariable("gCurrentSequence"));
        assertEquals(3, ebbs.size());
        assertEquals("DeleteFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
        assertEquals("DeactivateVfModuleBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
        assertEquals("DeleteVfModuleBB", ebbs.get(2).getBuildingBlock().getBpmnFlowName());

    }

    @Test
    public void rollbackExecutionRollbackToCreatedWithFabricTest() {
        execution.setVariable("isRollback", false);
        execution.setVariable("handlingCode", "RollbackToCreated");
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();

        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
        ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
        flowsToExecute.add(ebb4);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 4);

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals(0, execution.getVariable("gCurrentSequence"));
        assertEquals(2, ebbs.size());
        assertEquals("DeleteFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
        assertEquals("DeactivateVfModuleBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName());

    }

    @Test
    public void rollbackExecutionRollbackToCreatedNoConfigurationWithFabricTest() {
        execution.setVariable("isRollback", false);
        execution.setVariable("handlingCode", "RollbackToCreatedNoConfiguration");
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();

        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
        ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
        flowsToExecute.add(ebb4);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 4);

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals(0, execution.getVariable("gCurrentSequence"));
        assertEquals(1, ebbs.size());
        assertEquals("DeactivateVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
    }

    @Test
    public void rollbackExecutionRollbackToCreatedTest() {
        execution.setVariable("isRollback", false);
        execution.setVariable("handlingCode", "RollbackToCreated");
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 3);

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals("DeactivateVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
        assertEquals(0, execution.getVariable("gCurrentSequence"));
        assertEquals(1, ebbs.size());
    }

    @Test
    public void rollbackExecutionRollbackInPlaceSoftwareUpdateTest() {
        execution.setVariable("isRollback", false);
        execution.setVariable("handlingCode", "Rollback");
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("VNFCheckInMaintFlagActivity");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("VNFSetInMaintFlagActivity");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("VNFCheckClosedLoopDisabledFlagActivity");
        ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
        flowsToExecute.add(ebb4);

        BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("VNFSetClosedLoopDisabledFlagActivity");
        ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
        flowsToExecute.add(ebb5);

        BuildingBlock buildingBlock6 = new BuildingBlock().setBpmnFlowName("VNFLockActivity");
        ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock6);
        flowsToExecute.add(ebb6);

        BuildingBlock buildingBlock7 = new BuildingBlock().setBpmnFlowName("VNFUpgradePreCheckActivity");
        ExecuteBuildingBlock ebb7 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock7);
        flowsToExecute.add(ebb7);

        BuildingBlock buildingBlock8 = new BuildingBlock().setBpmnFlowName("VNFQuiesceTrafficActivity");
        ExecuteBuildingBlock ebb8 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock8);
        flowsToExecute.add(ebb8);

        BuildingBlock buildingBlock9 = new BuildingBlock().setBpmnFlowName("VNFStopActivity");
        ExecuteBuildingBlock ebb9 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock9);
        flowsToExecute.add(ebb9);

        BuildingBlock buildingBlock10 = new BuildingBlock().setBpmnFlowName("VNFSnapShotActivity");
        ExecuteBuildingBlock ebb10 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock10);
        flowsToExecute.add(ebb10);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 10);

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals("VNFStartActivity", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
        assertEquals("VNFResumeTrafficActivity", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
        assertEquals("VNFUnlockActivity", ebbs.get(2).getBuildingBlock().getBpmnFlowName());
        assertEquals("VNFUnsetClosedLoopDisabledFlagActivity", ebbs.get(3).getBuildingBlock().getBpmnFlowName());
        assertEquals("VNFUnsetInMaintFlagActivity", ebbs.get(4).getBuildingBlock().getBpmnFlowName());
        assertEquals(0, execution.getVariable("gCurrentSequence"));
        assertEquals(5, ebbs.size());
    }

    @Test
    public void rollbackExecutionRollbackConfigModifyTest() {
        execution.setVariable("isRollback", false);
        execution.setVariable("handlingCode", "Rollback");
        execution.setVariable("requestAction", EMPTY_STRING);
        execution.setVariable("resourceName", EMPTY_STRING);
        List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
        BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity");
        ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
        flowsToExecute.add(ebb1);

        BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("VNFCheckInMaintFlagActivity");
        ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
        flowsToExecute.add(ebb2);

        BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("VNFSetInMaintFlagActivity");
        ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
        flowsToExecute.add(ebb3);

        BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("VNFCheckClosedLoopDisabledFlagActivity");
        ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
        flowsToExecute.add(ebb4);

        BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("VNFSetClosedLoopDisabledFlagActivity");
        ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
        flowsToExecute.add(ebb5);

        BuildingBlock buildingBlock6 = new BuildingBlock().setBpmnFlowName("VNFHealthCheckActivity");
        ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock6);
        flowsToExecute.add(ebb6);

        execution.setVariable("flowsToExecute", flowsToExecute);
        execution.setVariable("gCurrentSequence", 6);

        workflowActionBBTasks.rollbackExecutionPath(execution);
        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        assertEquals("VNFUnsetClosedLoopDisabledFlagActivity", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
        assertEquals("VNFUnsetInMaintFlagActivity", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
        assertEquals(0, execution.getVariable("gCurrentSequence"));
        assertEquals(2, ebbs.size());
    }

    @Test
    public void postProcessingExecuteBBActivateVfModuleTest() throws CloneNotSupportedException {
        BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
        ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);

        WorkflowResourceIds resourceIdsActivateVfModule = new WorkflowResourceIds();
        resourceIdsActivateVfModule.setServiceInstanceId("test-service-inbstance-id");
        resourceIdsActivateVfModule.setVnfId("test-vnf-id");
        resourceIdsActivateVfModule.setVfModuleId("test-vf-module-id");
        resourceIdsActivateVfModule.setConfigurationId("");

        RequestDetails requestDetails = new RequestDetails();

        ebbActivateVfModule.setApiVersion("7");
        ebbActivateVfModule.setaLaCarte(true);
        ebbActivateVfModule.setRequestAction("createInstance");
        ebbActivateVfModule.setVnfType("test-vnf-type");
        ebbActivateVfModule.setRequestId("f6c00ae2-a205-4cbd-b055-02e553efde12");
        ebbActivateVfModule.setRequestDetails(requestDetails);
        ebbActivateVfModule.setWorkflowResourceIds(resourceIdsActivateVfModule);

        ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
        configurationResourceKeys.setCvnfcCustomizationUUID("07d64cd2-4427-4156-b11d-d14b96b3e4cb");
        configurationResourceKeys.setVfModuleCustomizationUUID("50b61075-6ebb-4aab-a9fc-bedad9a2aa76");
        configurationResourceKeys.setVnfResourceCustomizationUUID("a1d0e36e-34a9-431b-b5ba-4bbb72f63c7c");
        configurationResourceKeys.setVnfcName("rdm54bvbgw5001vm018pim001");

        ExecuteBuildingBlock ebbAddFabricConfig =
                workflowActionBBTasks.getExecuteBBForConfig("AddFabricConfigurationBB", ebbActivateVfModule,
                        "cc7e12f9-967c-4362-8d14-e5b2bf0608a4", configurationResourceKeys);

        assertEquals("7", ebbAddFabricConfig.getApiVersion());
        assertTrue(ebbAddFabricConfig.isaLaCarte());
        assertEquals("createInstance", ebbAddFabricConfig.getRequestAction());
        assertEquals("test-vnf-type", ebbAddFabricConfig.getVnfType());
        assertEquals("f6c00ae2-a205-4cbd-b055-02e553efde12", ebbAddFabricConfig.getRequestId());
        assertEquals(requestDetails, ebbAddFabricConfig.getRequestDetails());
        assertEquals("cc7e12f9-967c-4362-8d14-e5b2bf0608a4",
                ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId());
        assertEquals("test-service-inbstance-id", ebbAddFabricConfig.getWorkflowResourceIds().getServiceInstanceId());
        assertEquals("test-vnf-id", ebbAddFabricConfig.getWorkflowResourceIds().getVnfId());
        assertEquals("test-vf-module-id", ebbAddFabricConfig.getWorkflowResourceIds().getVfModuleId());

        assertThat(ebbAddFabricConfig.getConfigurationResourceKeys()).isEqualTo(configurationResourceKeys);
        assertThat(ebbAddFabricConfig.getWorkflowResourceIds())
                .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds());
        assertThat(ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId())
                .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds().getConfigurationId());
    }

    @Test
    public void checkRetryStatusTest() {
        String reqId = "reqId123";
        execution.setVariable("mso-request-id", reqId);
        doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
        doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
        execution.setVariable("handlingCode", "Retry");
        execution.setVariable("retryCount", 1);
        execution.setVariable("gCurrentSequence", 1);
        InfraActiveRequests req = new InfraActiveRequests();
        doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
        workflowActionBBTasks.checkRetryStatus(execution);
        assertEquals(0, execution.getVariable("gCurrentSequence"));
    }

    @Test
    public void checkRetryStatusTestExceededMaxRetries() {
        String reqId = "reqId123";
        execution.setVariable("mso-request-id", reqId);
        doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
        doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
        execution.setVariable("handlingCode", "Retry");
        execution.setVariable("retryCount", 6);
        execution.setVariable("gCurrentSequence", 1);
        InfraActiveRequests req = new InfraActiveRequests();
        doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
        try {
            workflowActionBBTasks.checkRetryStatus(execution);
        } catch (BpmnError e) {
            WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
            assertEquals("Exceeded maximum retries. Ending flow with status Abort", exception.getErrorMessage());
        }
    }

    @Test
    public void checkRetryStatusNoRetryTest() {
        String reqId = "reqId123";
        execution.setVariable("mso-request-id", reqId);
        execution.setVariable("retryCount", 3);
        execution.setVariable("handlingCode", "Success");
        execution.setVariable("gCurrentSequence", 1);
        InfraActiveRequests req = new InfraActiveRequests();
        doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
        workflowActionBBTasks.checkRetryStatus(execution);
        assertEquals(0, execution.getVariable("retryCount"));
    }

    @Test
    public void updateInstanceId() {
        String reqId = "req123";
        String instanceId = "123123123";
        execution.setVariable("mso-request-id", reqId);
        execution.setVariable("resourceId", instanceId);
        execution.setVariable("resourceType", WorkflowType.SERVICE);
        doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
        doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
        workflowActionBBTasks.updateInstanceId(execution);
        Mockito.verify(reqMock, Mockito.times(1)).setServiceInstanceId(instanceId);
    }

    @Test
    public void getConfigurationId() throws Exception {
        org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
        vnfc.setModelInvariantId("modelInvariantId");
        vnfc.setVnfcName("testVnfcName");
        List<Configuration> configurations = new ArrayList<>();
        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
        configuration.setConfigurationId("configurationId");
        configuration.setModelCustomizationId("modelCustimizationId");
        configuration.setConfigurationName("testConfigurationName");
        configurations.add(configuration);
        doReturn(configurations.get(0).getConfigurationId()).when(workflowActionBBTasks).getConfigurationId(vnfc);
        assertEquals(workflowActionBBTasks.getConfigurationId(vnfc), "configurationId");
    }

    @Test
    public void setServiceInstanceNameTest() {
        String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
        WorkflowType resourceType = WorkflowType.SERVICE;
        InfraActiveRequests request = new InfraActiveRequests();
        ServiceInstance service = new ServiceInstance();
        service.setServiceInstanceName("serviceInstanceName");
        doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById(resourceId);

        workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
        assertEquals("serviceInstanceName", request.getServiceInstanceName());
    }

    @Test
    public void setVnfNameTest() {
        String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
        WorkflowType resourceType = WorkflowType.VNF;
        InfraActiveRequests request = new InfraActiveRequests();
        GenericVnf vnf = new GenericVnf();
        vnf.setVnfName("vnfName");
        doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf(resourceId);

        workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
        assertEquals("vnfName", request.getVnfName());
    }

    @Test
    public void setVfModuleNameTest() {
        String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
        WorkflowType resourceType = WorkflowType.VFMODULE;
        InfraActiveRequests request = new InfraActiveRequests();
        request.setVnfId("ae5cc3e8-c13c-4d88-aaf6-694ab4977b0e");
        VfModule vfModule = new VfModule();
        vfModule.setVfModuleName("vfModuleName");
        doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("ae5cc3e8-c13c-4d88-aaf6-694ab4977b0e", resourceId);

        workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
        assertEquals("vfModuleName", request.getVfModuleName());
    }

    @Test
    public void setNetworkNameTest() {
        String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
        WorkflowType resourceType = WorkflowType.NETWORK;
        InfraActiveRequests request = new InfraActiveRequests();
        L3Network network = new L3Network();
        network.setNetworkName("networkName");
        doReturn(network).when(bbSetupUtils).getAAIL3Network(resourceId);

        workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
        assertEquals("networkName", request.getNetworkName());
    }

    @Test
    public void setConfigurationNameTest() {
        String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
        WorkflowType resourceType = WorkflowType.CONFIGURATION;
        InfraActiveRequests request = new InfraActiveRequests();
        Configuration configuration = new Configuration();
        configuration.setConfigurationName("configurationName");
        doReturn(configuration).when(bbSetupUtils).getAAIConfiguration(resourceId);

        workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
        assertEquals("configurationName", request.getConfigurationName());
    }

    @Test
    public void setInstanceGroupNameTest() {
        String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
        WorkflowType resourceType = WorkflowType.INSTANCE_GROUP;
        InfraActiveRequests request = new InfraActiveRequests();
        InstanceGroup instanceGroup = new InstanceGroup();
        instanceGroup.setInstanceGroupName("instanceGroupName");
        doReturn(instanceGroup).when(bbSetupUtils).getAAIInstanceGroup(resourceId);

        workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
        assertEquals("instanceGroupName", request.getInstanceGroupName());
    }

    @Test
    public void setVolumeGroupNameTest() {
        String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
        WorkflowType resourceType = WorkflowType.VOLUMEGROUP;
        InfraActiveRequests request = new InfraActiveRequests();
        request.setVnfId("4aa72c90-21eb-4465-8847-997e27af6c3e");
        VolumeGroup volumeGroup = new VolumeGroup();
        volumeGroup.setVolumeGroupName("volumeGroupName");
        Optional<VolumeGroup> returnVolumeGroup = Optional.of(volumeGroup);

        doReturn(returnVolumeGroup).when(bbSetupUtils).getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId);
        workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);

        assertEquals("volumeGroupName", request.getVolumeGroupName());
    }

    private void prepareDelegateExecution() {
        execution.setVariable("mso-request-id", SAMPLE_MSO_REQUEST_ID);
        execution.setVariable("requestAction", SAMPLE_REQUEST_ACTION);
        execution.setVariable("gCurrentSequence", SAMPLE_SEQUENCE);
        execution.setVariable("homing", false);
        execution.setVariable("calledHoming", false);
    }
}