2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 package org.onap.so.bpmn.servicedecomposition.tasks;
24 import static org.junit.Assert.*;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.mockito.Mock;
28 import org.mockito.junit.MockitoJUnitRunner;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
31 import org.onap.so.db.catalog.beans.OrchestrationStatus;
32 import org.onap.so.serviceinstancebeans.ModelInfo;
33 import org.onap.so.serviceinstancebeans.Pnfs;
34 import static org.mockito.Mockito.doReturn;
36 @RunWith(MockitoJUnitRunner.class)
37 public class BBInputSetupPnfTest {
43 private ModelInfo modelInfo;
46 public void populatePnfShouldSetRequiredFields() {
47 final String pnfId = "PNF_id1";
48 final String pnfName = "PNF_name1";
49 final String modelCustomizationId = "8421fe03-fd1b-4bf7-845a-c3fe91edb031";
50 final String modelInvariantId = "3360a2a5-22ff-44c7-8935-08c8e5ecbd06";
51 final String modelVersionId = "b80c3a52-abd4-436c-a22e-9c5da768781a";
53 doReturn(modelCustomizationId).when(modelInfo).getModelCustomizationId();
54 doReturn(modelInvariantId).when(modelInfo).getModelInvariantId();
55 doReturn(modelVersionId).when(modelInfo).getModelVersionId();
56 doReturn(pnfName).when(pnfs).getInstanceName();
57 doReturn(modelInfo).when(pnfs).getModelInfo();
59 ServiceInstance serviceInstance = new ServiceInstance();
60 BBInputSetupPnf.populatePnfToServiceInstance(pnfs, pnfId, serviceInstance);
62 assertEquals(1, serviceInstance.getPnfs().size());
64 Pnf pnf = serviceInstance.getPnfs().get(0);
66 assertEquals(pnfId, pnf.getPnfId());
67 assertEquals(pnfName, pnf.getPnfName());
68 assertEquals(modelCustomizationId, pnf.getModelInfoPnf().getModelCustomizationUuid());
69 assertEquals(modelInvariantId, pnf.getModelInfoPnf().getModelInvariantUuid());
70 assertEquals(modelVersionId, pnf.getModelInfoPnf().getModelUuid());
71 assertEquals(OrchestrationStatus.PRECREATED, pnf.getOrchestrationStatus());