import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import com.google.gson.JsonElement;
+
import java.io.IOException;
-import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
*/
@Test
public void testGetStringValue() {
- assertEquals("DCAE", refProp.getStringValue("policy.onap.name"));
- assertEquals("Config_MS_", refProp.getStringValue("policy.ms.policyNamePrefix", ""));
- assertEquals("Config_MS_", refProp.getStringValue("policy.ms.policyNamePrefix", "testos"));
- assertEquals("Config_MS_", refProp.getStringValue("policy.ms", "policyNamePrefix"));
- assertNull(refProp.getStringValue("does.not.exist"));
+ assertEquals("healthcheck", refProp.getStringValue("policy.api.userName"));
}
@Test
public void shouldReturnJsonFromTemplate() throws IOException {
- //when
+ // when
JsonElement root = refProp.getJsonTemplate("ui.location.default");
- //then
+ // then
assertNotNull(root);
assertTrue(root.isJsonObject());
assertEquals("Data Center 1", root.getAsJsonObject().get("DC1").getAsString());
@Test
public void shouldReturnJsonFromTemplate_2() throws IOException {
- //when
+ // when
JsonElement root = refProp.getJsonTemplate("ui.location", "default");
- //then
+ // then
assertNotNull(root);
assertTrue(root.isJsonObject());
assertEquals("Data Center 1", root.getAsJsonObject().get("DC1").getAsString());
@Test
public void shouldReturnNullIfPropertyNotFound() throws IOException {
- //when
+ // when
JsonElement root = refProp.getJsonTemplate("ui.location", "");
- //then
+ // then
assertNull(root);
}
/**
* Test getting prop value as a JSON Node / template.
*
- * @throws IOException
- * when JSON parsing fails
+ * @throws IOException when JSON parsing fails
*/
@Test
public void testGetFileContent() throws IOException {
content = refProp.getFileContent("ui.location", "default");
assertEquals(location, content);
}
-
- @Test
- public void testGetStringList() {
- List<String> profileList = refProp.getStringList("policy.pdpUrl1", ",");
- assertEquals(3, profileList.size());
- assertTrue(profileList.get(0).trim().startsWith("http://localhost:"));
- assertEquals("testpdp", profileList.get(1).trim());
- assertEquals("alpha123", profileList.get(2).trim());
- }
}