2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2021 Nokia
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Modifications Copyright (c) 2021 Nokia
10 * ================================================================================
11 * Modifications Copyright (c) 2020 Tech Mahindra
12 * ================================================================================
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
17 * http://www.apache.org/licenses/LICENSE-2.0
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 * ============LICENSE_END=========================================================
27 package org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader;
30 import org.camunda.bpm.engine.delegate.DelegateExecution;
31 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
32 import org.javatuples.Pair;
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
36 import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType;
37 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
38 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
39 import org.onap.so.client.exception.ExceptionBuilder;
40 import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource;
41 import java.util.ArrayList;
42 import java.util.List;
43 import static org.junit.Assert.assertEquals;
44 import static org.mockito.Mockito.doReturn;
45 import static org.mockito.Mockito.mock;
48 public class VnfEBBLoaderTest {
50 private String serviceId;
52 private BBInputSetupUtils bbInputSetupUtils;
53 private BBInputSetup bbInputSetup;
54 private WorkflowActionExtractResourcesAAI workflowActionUtils;
55 private ExceptionBuilder exceptionBuilder;
56 private DelegateExecution delegateExecution;
57 private VnfEBBLoader cut;
59 private org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI;
60 private ServiceInstance serviceInstanceMSO;
64 serviceId = "service123";
66 serviceInstanceAAI = mock(org.onap.aai.domain.yang.ServiceInstance.class);
67 serviceInstanceMSO = mock(ServiceInstance.class);
68 bbInputSetupUtils = mock(BBInputSetupUtils.class);
69 bbInputSetup = mock(BBInputSetup.class);
70 workflowActionUtils = mock(WorkflowActionExtractResourcesAAI.class);
71 exceptionBuilder = mock(ExceptionBuilder.class);
72 delegateExecution = new DelegateExecutionFake();
76 public void traverseAAIVnf_shouldAddServiceToResourceList() throws Exception {
77 List<Resource> resourceList = new ArrayList<>();
78 List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
79 doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId);
80 doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
81 cut = new VnfEBBLoader(bbInputSetupUtils, bbInputSetup, workflowActionUtils, exceptionBuilder);
82 cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds);
83 assertEquals(WorkflowType.SERVICE, resourceList.get(0).getResourceType());