2 * Copyright (C) 2020 CMCC, Inc. and others. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 package org.openecomp.sdc.be.components.impl;
20 import org.junit.jupiter.api.BeforeEach;
21 import org.junit.jupiter.api.Test;
22 import org.junit.jupiter.api.extension.ExtendWith;
23 import org.mockito.InjectMocks;
24 import org.mockito.Mock;
25 import org.mockito.MockitoAnnotations;
26 import org.mockito.junit.jupiter.MockitoExtension;
27 import org.openecomp.sdc.be.model.Service;
28 import org.openecomp.sdc.be.model.UploadServiceInfo;
30 import static org.junit.jupiter.api.Assertions.assertEquals;
31 import static org.junit.jupiter.api.Assertions.assertFalse;
32 import static org.mockito.ArgumentMatchers.anyString;
33 import static org.mockito.Mockito.when;
35 @ExtendWith(MockitoExtension.class)
36 class ServiceImportManagerTest {
39 private ServiceBusinessLogic serviceBusinessLogic;
42 private ServiceImportManager serviceImportManager;
46 MockitoAnnotations.openMocks(this);
47 serviceImportManager = new ServiceImportManager(serviceBusinessLogic, null);
51 void testPopulateServiceMetadata() {
52 UploadServiceInfo serviceMetaData = new UploadServiceInfo();
53 serviceMetaData.setDescription("Description");
54 serviceMetaData.setVendorName("VendorName");
55 serviceMetaData.setVendorRelease("VendorRelease");
56 serviceMetaData.setDerivedFromGenericVersion("derivedFromGenericVersion");
57 Service service = new Service();
58 service.setName("service");
59 serviceImportManager.populateServiceMetadata(serviceMetaData, service);
60 assertEquals("derivedFromGenericVersion", service.getDerivedFromGenericVersion());
64 void testIsServiceExist() {
65 when(serviceBusinessLogic.isServiceExist(anyString())).thenReturn(false);
66 boolean result = serviceImportManager.isServiceExist("no exist");