2a5a7390753bf73917fe344267acdf9f0555c77a
[so.git] / adapters / mso-catalog-db-adapter / src / test / java / org / onap / so / adapters / catalogdb / catalogrest / CvnfcCatalogDbQueryTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.adapters.catalogdb.catalogrest;
22
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;
27
28 import java.util.List;
29
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;
42
43 import org.springframework.beans.BeanUtils;
44
45 @RunWith(SpringRunner.class)
46 @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
47 @ActiveProfiles("test")
48 public class CvnfcCatalogDbQueryTest {
49
50         private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CvnfcCatalogDbQueryTest.class);
51
52         @LocalServerPort
53         private int port;
54         boolean isInitialized;
55
56         @Autowired
57         CatalogDbClientPortChanger client;
58
59         @Before
60         public void initialize(){
61                 client.wiremockPort= String.valueOf(port);
62         }
63         
64         @Test
65         public void cVnfcTest() {
66                 
67         CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization();
68         
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);
73                 
74                 CvnfcCustomization templateCvnfcCustomization = new CvnfcCustomization();
75                 BeanUtils.copyProperties(found, templateCvnfcCustomization, "vnfVfmoduleCvnfcConfigurationCustomization");
76                 
77         assertThat(cvnfcCustomization, sameBeanAs(templateCvnfcCustomization)
78                         .ignoring("id")
79                         .ignoring("created")
80                         .ignoring("vnfVfmoduleCvnfcConfigurationCustomization")
81                         .ignoring("vnfResourceCusteModelCustomizationUUID"));
82         }
83         
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;
97     }
98 }