Remove the clds-reference.properties
[clamp.git] / src / test / java / org / onap / clamp / clds / it / config / CldsReferencePropertiesItCase.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.it.config;
25
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertNull;
29
30 import com.fasterxml.jackson.databind.node.ObjectNode;
31
32 import java.io.IOException;
33
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.onap.clamp.clds.config.ClampProperties;
37 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.boot.test.context.SpringBootTest;
39 import org.springframework.test.context.junit4.SpringRunner;
40
41 /**
42  * Test corg.onap.clamp.ClampDesigner.model.refprop package using RefProp.
43  */
44 @RunWith(SpringRunner.class)
45 @SpringBootTest
46 public class CldsReferencePropertiesItCase {
47
48     @Autowired
49     private ClampProperties refProp;
50
51     /**
52      * Test getting a value the properties in string.
53      * 
54      * @throws IOException
55      */
56     @Test
57     public void testGetStringValue() throws IOException {
58         assertEquals(refProp.getStringValue("policy.onap.name"), "DCAE");
59         assertEquals(refProp.getStringValue("policy.ms.policyNamePrefix", ""), "Config_MS_");
60         assertEquals(refProp.getStringValue("policy.ms.policyNamePrefix", "testos"), "Config_MS_");
61         assertEquals(refProp.getStringValue("policy.ms", "policyNamePrefix"), "Config_MS_");
62         assertNull(refProp.getStringValue("does.not.exist"));
63     }
64
65     /**
66      * Test getting prop value as a JSON Node / template.
67      *
68      * @throws IOException
69      *             when JSON parsing fails
70      */
71     @Test
72     public void testGetJsonTemplate() throws IOException {
73         // ui.location.default={"DC1":"Data Center 1","DC2":"Data Center
74         // 2","DC3":"Data Center 3"}
75         ObjectNode root = (ObjectNode) refProp.getJsonTemplate("ui.location.default");
76         assertNotNull(root);
77         assertEquals(root.get("DC1").asText(), "Data Center 1");
78         // Test composite key
79         root = (ObjectNode) refProp.getJsonTemplate("ui.location", "default");
80         assertNotNull(root);
81         assertEquals(root.get("DC1").asText(), "Data Center 1");
82         root = (ObjectNode) refProp.getJsonTemplate("ui.location", "");
83         assertNull(root);
84     }
85
86     /**
87      * Test getting prop value as a JSON Node / template.
88      *
89      * @throws IOException
90      *             when JSON parsing fails
91      */
92     @Test
93     public void testGetFileContent() throws IOException {
94         String content = refProp.getFileContent("sdc.decode.service_ids");
95         assertEquals("{}", content);
96         // Test composite key
97         content = refProp.getFileContent("sdc.decode", "service_ids");
98         assertEquals("{}", content);
99     }
100 }