Eliminated printStackTrace() calls
[so.git] / mso-catalog-db / src / test / java / org / onap / so / db / catalog / data / repository / VnfCustomizationRepositoryTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        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.
15  *
16  *  SPDX-License-Identifier: Apache-2.0
17  *  ============LICENSE_END=========================================================
18  */
19
20 package org.onap.so.db.catalog.data.repository;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertFalse;
24 import static org.junit.Assert.assertNotNull;
25
26 import org.junit.Test;
27 import org.onap.so.db.catalog.BaseTest;
28 import org.onap.so.db.catalog.beans.VnfResource;
29 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.util.CollectionUtils;
32
33 import java.util.List;
34
35
36 public class VnfCustomizationRepositoryTest extends BaseTest {
37
38     @Autowired
39     private VnfCustomizationRepository vnfCustomizationRepository;
40
41     @Test
42     public void findByModelCustomizationUUID_ValidUuid_ExpectedOutput() throws Exception {
43         List<VnfResourceCustomization> vnfCustomizationList = vnfCustomizationRepository
44             .findByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
45         assertFalse(CollectionUtils.isEmpty(vnfCustomizationList));
46         assertEquals("output contains one entity", 1, vnfCustomizationList.size());
47
48         checkVnfResourceCustomization(vnfCustomizationList.get(0));
49     }
50
51     @Test
52     public void findOneByModelCustomizationUUID_ValidUuid_ExpectedOutput() throws Exception {
53         VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepository
54             .findOneByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
55         checkVnfResourceCustomization(vnfResourceCustomization);
56     }
57
58     @Test
59     public void findByModelInstanceNameAndVnfResources_ValidNameAndUuid_ExpectedOutput() throws Exception {
60         VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepository
61             .findByModelInstanceNameAndVnfResources("vSAMP10a 1", "ff2ae348-214a-11e7-93ae-92361f002671");
62         checkVnfResourceCustomization(vnfResourceCustomization);
63     }
64
65     private void checkVnfResourceCustomization(VnfResourceCustomization vnfResourceCustomization) {
66         assertEquals("modelInstanceName", "vSAMP10a 1", vnfResourceCustomization.getModelInstanceName());
67         assertEquals("blueprintName", "test_configuration_restconf", vnfResourceCustomization.getBlueprintName());
68         assertEquals("blueprintVersion", "1.0.0", vnfResourceCustomization.getBlueprintVersion());
69         VnfResource vnfResource = vnfResourceCustomization.getVnfResources();
70         assertNotNull(vnfResource);
71
72         assertEquals("VNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002671", vnfResource.getModelUUID());
73         assertEquals("VNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002671",
74             vnfResource.getModelInvariantUUID());
75         assertEquals("VNFResource modelVersion", "1.0", vnfResource.getModelVersion());
76         assertEquals("VNFResource orchestration mode", "HEAT", vnfResource.getOrchestrationMode());
77     }
78 }