2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 AT&T 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=========================================================
21 package org.onap.so.adapters.catalogdb.catalogrest;
23 import static com.shazam.shazamcrest.MatcherAssert.assertThat;
24 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
28 import java.util.List;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
34 import org.onap.so.db.catalog.beans.CvnfcCustomization;
35 import org.onap.so.db.catalog.client.CatalogDbClientPortChanger;
36 import org.onap.so.logger.MsoLogger;
37 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.boot.web.server.LocalServerPort;
39 import org.springframework.boot.test.context.SpringBootTest;
40 import org.springframework.test.context.ActiveProfiles;
41 import org.springframework.test.context.junit4.SpringRunner;
43 import org.springframework.beans.BeanUtils;
45 @RunWith(SpringRunner.class)
46 @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
47 @ActiveProfiles("test")
48 public class CvnfcCatalogDbQueryTest {
50 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CvnfcCatalogDbQueryTest.class);
54 boolean isInitialized;
57 CatalogDbClientPortChanger client;
60 public void initialize(){
61 client.wiremockPort= String.valueOf(port);
65 public void cVnfcTest() {
67 CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization();
69 List<CvnfcCustomization> foundCvnfcCustomization = client.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671","cb82ffd8-252a-11e7-93ae-92361f002671");
70 assertNotNull(foundCvnfcCustomization);
71 assertTrue(foundCvnfcCustomization.size() > 0);
72 CvnfcCustomization found = foundCvnfcCustomization.get(0);
74 CvnfcCustomization templateCvnfcCustomization = new CvnfcCustomization();
75 BeanUtils.copyProperties(found, templateCvnfcCustomization, "vnfVfmoduleCvnfcConfigurationCustomization");
77 assertThat(cvnfcCustomization, sameBeanAs(templateCvnfcCustomization)
80 .ignoring("vnfVfmoduleCvnfcConfigurationCustomization")
81 .ignoring("vnfResourceCusteModelCustomizationUUID"));
84 protected CvnfcCustomization setUpCvnfcCustomization(){
85 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
86 cvnfcCustomization.setModelCustomizationUUID("9bcce658-9b37-11e8-98d0-529269fb1459");
87 cvnfcCustomization.setModelInstanceName("testModelInstanceName");
88 cvnfcCustomization.setModelUUID("b25735fe-9b37-11e8-98d0-529269fb1459");
89 cvnfcCustomization.setModelInvariantUUID("ba7e6ef0-9b37-11e8-98d0-529269fb1459");
90 cvnfcCustomization.setModelVersion("testModelVersion");
91 cvnfcCustomization.setModelName("testModelName");
92 cvnfcCustomization.setToscaNodeType("testToscaNodeType");
93 cvnfcCustomization.setDescription("testCvnfcCustomzationDescription");
94 cvnfcCustomization.setNfcFunction("testNfcFunction");
95 cvnfcCustomization.setNfcNamingCode("testNfcNamingCode");
96 return cvnfcCustomization;