Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-catalog-db / src / test / java / org / onap / so / db / catalog / data / repository / PnfCustomizationRepositoryTest.java
1 /*
2  * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix
3  * Foundation. ================================================================================ Licensed under the
4  * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
5  * obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
8  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9  * either express or implied. See the License for the specific language governing permissions and limitations under the
10  * License.
11  *
12  * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
13  */
14
15 package org.onap.so.db.catalog.data.repository;
16
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.assertTrue;
20 import java.util.List;
21 import org.junit.Test;
22 import org.onap.so.db.catalog.BaseTest;
23 import org.onap.so.db.catalog.beans.PnfResource;
24 import org.onap.so.db.catalog.beans.PnfResourceCustomization;
25 import org.onap.so.db.catalog.exceptions.NoEntityFoundException;
26 import org.springframework.beans.factory.annotation.Autowired;
27
28 public class PnfCustomizationRepositoryTest extends BaseTest {
29
30     @Autowired
31     private PnfCustomizationRepository pnfCustomizationRepository;
32
33     @Test
34     public void findById_ValidUuid_ExpectedOutput() throws Exception {
35         PnfResourceCustomization pnfResourceCustomization =
36                 pnfCustomizationRepository.findById("68dc9a92-214c-11e7-93ae-92361f002680")
37                         .orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation"));
38         checkPnfResourceCustomization(pnfResourceCustomization);
39     }
40
41     @Test
42     public void findPnfResourceCustomizationByModelUuid_ValidServiceUuidAndCustomizationUuid_ExpectedOutput() {
43         List<PnfResourceCustomization> pnfResourceCustomizationList = pnfCustomizationRepository
44                 .findPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676");
45         assertEquals("Found the matching resource entity", 1, pnfResourceCustomizationList.size());
46         checkPnfResourceCustomization(pnfResourceCustomizationList.get(0));
47     }
48
49     private void checkPnfResourceCustomization(PnfResourceCustomization pnfResourceCustomization) {
50         assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
51         assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
52         assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
53         assertTrue("skip post instantiation configuration", pnfResourceCustomization.isSkipPostInstConf());
54         PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
55         assertNotNull(pnfResource);
56
57         assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
58         assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
59                 pnfResource.getModelInvariantUUID());
60         assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
61         assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
62     }
63 }