Merge "Construct multicloud infra_workload endpoint"
[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 java.util.List;
27 import org.junit.Test;
28 import org.onap.so.db.catalog.BaseTest;
29 import org.onap.so.db.catalog.beans.VnfResource;
30 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.util.CollectionUtils;
33
34
35 public class VnfCustomizationRepositoryTest extends BaseTest {
36
37     @Autowired
38     private VnfCustomizationRepository vnfCustomizationRepository;
39
40     @Test
41     public void findByModelCustomizationUUID_ValidUuid_ExpectedOutput() throws Exception {
42         List<VnfResourceCustomization> vnfCustomizationList = vnfCustomizationRepository
43             .findByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
44         assertFalse(CollectionUtils.isEmpty(vnfCustomizationList));
45         assertEquals("output contains one entity", 1, vnfCustomizationList.size());
46
47         checkVnfResourceCustomization(vnfCustomizationList.get(0));
48     }
49
50     @Test
51     public void findOneByModelCustomizationUUID_ValidUuid_ExpectedOutput() throws Exception {
52         VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepository
53             .findOneByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
54         checkVnfResourceCustomization(vnfResourceCustomization);
55     }
56
57     @Test
58     public void findByModelInstanceNameAndVnfResources_ValidNameAndUuid_ExpectedOutput() throws Exception {
59         VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepository
60             .findByModelInstanceNameAndVnfResources("vSAMP10a 1", "ff2ae348-214a-11e7-93ae-92361f002671");
61         checkVnfResourceCustomization(vnfResourceCustomization);
62     }
63
64     private void checkVnfResourceCustomization(VnfResourceCustomization vnfResourceCustomization) {
65         assertEquals("modelInstanceName", "vSAMP10a 1", vnfResourceCustomization.getModelInstanceName());
66         assertEquals("blueprintName", "test_configuration_restconf", vnfResourceCustomization.getBlueprintName());
67         assertEquals("blueprintVersion", "1.0.0", vnfResourceCustomization.getBlueprintVersion());
68         VnfResource vnfResource = vnfResourceCustomization.getVnfResources();
69         assertNotNull(vnfResource);
70
71         assertEquals("VNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002671", vnfResource.getModelUUID());
72         assertEquals("VNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002671",
73             vnfResource.getModelInvariantUUID());
74         assertEquals("VNFResource modelVersion", "1.0", vnfResource.getModelVersion());
75         assertEquals("VNFResource orchestration mode", "HEAT", vnfResource.getOrchestrationMode());
76     }
77 }