Fix the tests
[clamp.git] / src / test / java / org / onap / clamp / clds / it / config / CldsReferencePropertiesItCase.java
  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 
-package org.onap.clamp.clds.it;
+package org.onap.clamp.clds.it.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 
 import java.io.IOException;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
+import org.onap.clamp.clds.config.CldsReferenceProperties;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
@@ -41,9 +43,23 @@ import org.springframework.test.context.junit4.SpringRunner;
  */
 @RunWith(SpringRunner.class)
 @SpringBootTest
-public class CldsReferencePropertiesItCase extends AbstractItCase {
+public class CldsReferencePropertiesItCase {
+
+    @Autowired
+    private CldsReferenceProperties refProp;
 
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsReferencePropertiesItCase.class);
+    /**
+     * Test getting a value the properties in string.
+     * 
+     * @throws IOException
+     */
+    @Test
+    public void testGetStringValue() throws IOException {
+        assertEquals(refProp.getStringValue("policy.onap.name"), "DCAE");
+        assertEquals(refProp.getStringValue("policy.ms.policyNamePrefix", ""), "Config_MS_");
+        assertEquals(refProp.getStringValue("policy.ms.policyNamePrefix", "testos"), "Config_MS_");
+        assertEquals(refProp.getStringValue("policy.ms", "policyNamePrefix"), "Config_MS_");
+    }
 
     /**
      * Test getting prop value as a JSON Node / template.
@@ -53,11 +69,16 @@ public class CldsReferencePropertiesItCase extends AbstractItCase {
      */
     @Test
     public void testJsonTemplate() throws IOException {
-        ObjectNode root = (ObjectNode) refProp.getJsonTemplate("tca.template");
-        root.put("closedLoopControlName", "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756");
-        ObjectMapper mapper = new ObjectMapper();
-        String jsonText = mapper.writeValueAsString(root);
-        logger.error("Exception caught IllegalArgumentException as expected");
-        // assertEquals(topicsJson, ref.getTopicsToJson());
+        // ui.location.default={"DC1":"Data Center 1","DC2":"Data Center
+        // 2","DC3":"Data Center 3"}
+        ObjectNode root = (ObjectNode) refProp.getJsonTemplate("ui.location.default");
+        assertNotNull(root);
+        assertEquals(root.get("DC1").asText(), "Data Center 1");
+        // Test composite key
+        root = (ObjectNode) refProp.getJsonTemplate("ui.location", "default");
+        assertNotNull(root);
+        assertEquals(root.get("DC1").asText(), "Data Center 1");
+        root = (ObjectNode) refProp.getJsonTemplate("ui.location", "");
+        assertNull(root);
     }
 }