2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
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.adapters.catalogdb.catalogrest;
25 import static com.shazam.shazamcrest.MatcherAssert.assertThat;
26 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertTrue;
30 import java.util.HashSet;
31 import java.util.List;
34 import org.junit.Assert;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
39 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
40 import org.onap.so.db.catalog.beans.ConfigurationResource;
41 import org.onap.so.db.catalog.beans.CvnfcCustomization;
42 import org.onap.so.db.catalog.beans.VfModule;
43 import org.onap.so.db.catalog.beans.VfModuleCustomization;
44 import org.onap.so.db.catalog.beans.VnfResource;
45 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
46 import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
47 import org.onap.so.db.catalog.beans.VnfcCustomization;
48 import org.onap.so.db.catalog.client.CatalogDbClientPortChanger;
49 import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository;
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
52 import org.springframework.beans.factory.annotation.Autowired;
53 import org.springframework.boot.web.server.LocalServerPort;
54 import org.springframework.boot.test.context.SpringBootTest;
55 import org.springframework.test.context.ActiveProfiles;
56 import org.springframework.test.context.junit4.SpringRunner;
58 import org.springframework.beans.BeanUtils;
60 public class CvnfcCatalogDbQueryTest extends CatalogDbAdapterBaseTest {
63 private CvnfcCustomizationRepository cvnfcCustomizationRepository;
65 private static final Logger logger = LoggerFactory.getLogger(CvnfcCatalogDbQueryTest.class);
69 boolean isInitialized;
72 CatalogDbClientPortChanger client;
75 public void initialize(){
76 client.wiremockPort= String.valueOf(port);
80 public void cVnfcTest() {
82 CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization("dadc2c8c-2bab-11e9-b210-d663bd873d93");
84 List<CvnfcCustomization> foundCvnfcCustomization = client.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671","cb82ffd8-252a-11e7-93ae-92361f002671");
85 assertNotNull(foundCvnfcCustomization);
86 assertTrue(foundCvnfcCustomization.size() > 0);
87 CvnfcCustomization found = foundCvnfcCustomization.get(0);
89 CvnfcCustomization templateCvnfcCustomization = new CvnfcCustomization();
90 BeanUtils.copyProperties(found, templateCvnfcCustomization, "vnfVfmoduleCvnfcConfigurationCustomization", "vfModuleCustomization", "vnfcCustomization", "vnfResourceCustomization");
92 assertThat(cvnfcCustomization, sameBeanAs(templateCvnfcCustomization)
95 .ignoring("vnfVfmoduleCvnfcConfigurationCustomization")
96 .ignoring("vnfResourceCusteModelCustomizationUUID"));
100 public void cVnfcByCustomizationUUID_Test() {
102 CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization("dadc2c8c-2bab-11e9-b210-d663bd873d93");
104 CvnfcCustomization found = client.getCvnfcCustomizationByCustomizationUUID("dadc2c8c-2bab-11e9-b210-d663bd873d93");
105 assertNotNull(found);
107 CvnfcCustomization templateCvnfcCustomization = new CvnfcCustomization();
108 BeanUtils.copyProperties(found, templateCvnfcCustomization, "vnfVfmoduleCvnfcConfigurationCustomization", "vfModuleCustomization", "vnfcCustomization", "vnfResourceCustomization");
110 assertThat(cvnfcCustomization, sameBeanAs(templateCvnfcCustomization)
113 .ignoring("vnfVfmoduleCvnfcConfigurationCustomization")
114 .ignoring("vnfResourceCusteModelCustomizationUUID"));
118 protected CvnfcCustomization setUpCvnfcCustomization(String id){
119 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
120 cvnfcCustomization.setModelCustomizationUUID(id);
121 cvnfcCustomization.setModelInstanceName("testModelInstanceName");
122 cvnfcCustomization.setModelUUID("b25735fe-9b37-11e8-98d0-529269fb1459");
123 cvnfcCustomization.setModelInvariantUUID("ba7e6ef0-9b37-11e8-98d0-529269fb1459");
124 cvnfcCustomization.setModelVersion("testModelVersion");
125 cvnfcCustomization.setModelName("testModelName");
126 cvnfcCustomization.setToscaNodeType("testToscaNodeType");
127 cvnfcCustomization.setDescription("testCvnfcCustomzationDescription");
128 cvnfcCustomization.setNfcFunction("testNfcFunction");
129 cvnfcCustomization.setNfcNamingCode("testNfcNamingCode");
130 return cvnfcCustomization;
133 protected VnfcCustomization setUpVnfcCustomization(){
134 VnfcCustomization vnfcCustomization = new VnfcCustomization();
135 vnfcCustomization.setModelInstanceName("testVnfcCustomizationModelInstanceName");
136 vnfcCustomization.setModelUUID("321228a4-9f15-11e8-98d0-529269fb1459");
137 vnfcCustomization.setModelInvariantUUID("c0659136-9f15-11e8-98d0-529269fb1459");
138 vnfcCustomization.setModelVersion("testModelVersion");
139 vnfcCustomization.setModelName("testModelName");
140 vnfcCustomization.setToscaNodeType("testToscaModelType");
141 vnfcCustomization.setDescription("testVnfcCustomizationDescription");
142 return vnfcCustomization;