aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-01-22 19:37:34 +0000
committerGerrit Code Review <gerrit@onap.org>2019-01-22 19:37:34 +0000
commit47362a73eae4bc63e0999966f125141cf5229e5b (patch)
treeace1925ac831da0f3ac2dd5a68f77a0a14670159
parenta27af17fe8987c4da311e4419a31830d62592f91 (diff)
parente598e9708241430648b553f0d3f3b2a146be1bf2 (diff)
Merge "Increase JUnit Code Coverage for PolicyDBDao"
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java14
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java43
2 files changed, 55 insertions, 2 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
index 75d7645ce..c9c49720d 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -2870,6 +2870,18 @@ public class PolicyDBDao {
String[] getPolicyNameAndVersionFromPolicyFileName(String originalPolicyName) throws PolicyDBException {
return PolicyDBDao.this.getPolicyNameAndVersionFromPolicyFileName(originalPolicyName);
}
+
+ String[] getNameScopeAndVersionFromPdpPolicy(String fileName) {
+ return PolicyDBDao.this.getNameScopeAndVersionFromPdpPolicy(fileName);
+ }
+
+ String getPdpPolicyName(String name, String scope) {
+ return PolicyDBDao.this.getPdpPolicyName(name, scope);
+ }
+
+ Path getPolicySubFile(String inputFileName, String subFileType) {
+ return PolicyDBDao.this.getPolicySubFile(inputFileName, subFileType);
+ }
}
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
index 89ddf84c5..f7dd92a3e 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -143,6 +143,47 @@ public class PolicyDBDaoTest extends Mockito{
configFile = d.getConfigFile("Action_mypolicy.xml", "org.onap", pra);
Assert.assertEquals("org.onap.Action_mypolicy.json", configFile);
}
+
+ @Test
+ public void getPolicyNameAndVersionFromPolicyFileNameTest() throws PolicyDBException {
+ String policyName = "com.Decision_testname.1.xml";
+ String[] expectedNameAndVersion = new String[2];
+ expectedNameAndVersion[0] = "com.Decision_testname";
+ expectedNameAndVersion[1] = "1";
+ String[] actualNameAndVersion = d.getPolicyNameAndVersionFromPolicyFileName(policyName);
+ Assert.assertArrayEquals(expectedNameAndVersion, actualNameAndVersion);
+ }
+
+ @Test
+ public void getNameScopeAndVersionFromPdpPolicyTest() {
+ String fileName = "com.Decision_testname.1.xml";
+ String[] expectedArray = new String[3];
+ expectedArray[0] = "Decision_testname.1.xml";
+ expectedArray[2] = "1";
+ expectedArray[1] = "com";
+
+ String[] returnArray = d.getNameScopeAndVersionFromPdpPolicy(fileName);
+ Assert.assertArrayEquals(expectedArray, returnArray);
+ }
+
+ @Test
+ public void getPdpPolicyNameTest() {
+ String name = "Decision_testname.1.json";
+ String scope = "com";
+ String expectedFinalname = "com.Decision_testname.1.xml";
+
+ String finalname = d.getPdpPolicyName(name, scope);
+ Assert.assertEquals(expectedFinalname, finalname);
+ }
+
+ @Test
+ public void getPolicySubFileTest() {
+ String name = "Config_testname.1.json";
+ String subFileType = "Config";
+
+ Path path = d.getPolicySubFile(name, subFileType);
+ Assert.assertNull(path);
+ }
@Test
public void createFromPolicyObject(){