diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2020-03-14 22:36:22 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2020-03-14 22:36:29 -0400 |
commit | ec20e47d350e16e1bf52f0396b777063b23770c7 (patch) | |
tree | 8e898c1b8c32eeb05e159968dc2d056e7c11fde2 | |
parent | a53a9b9192fbd8c27f2004a096f628243a126ca7 (diff) |
Add code coverage XacmlPolicyUtils
Fix spelling error and add code cover >95% for the
XacmlPolicyUtils.
Issue-ID: POLICY-2242
Change-Id: I21f239e6bd42073ff84883d04f2b8bee1466b8e0
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2 files changed, 33 insertions, 2 deletions
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java index 1e13d529..46ad83b5 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java @@ -27,7 +27,6 @@ import static org.assertj.core.api.Assertions.assertThatCode; import com.att.research.xacml.api.XACML3; import com.att.research.xacml.util.XACMLPolicyWriter; - import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -295,4 +294,36 @@ public class XacmlPolicyUtilsTest { XacmlPolicyUtils.debugDumpPolicyProperties(properties, LOGGER); assertThat(properties.getProperty("refstart3.file")).isNotBlank(); } + + @Test + public void testCopyingProperties() throws Exception { + // + // Copy to this folder + // + File copyFolder = policyFolder.newFolder("copy"); + assertThat(copyFolder.exists()).isTrue(); + // + // Mock up a properties object + // + Properties mockProperties = new Properties(); + XacmlPolicyUtils.addRootPolicy(mockProperties, rootPath); + XacmlPolicyUtils.addReferencedPolicy(mockProperties, path1); + // + // Write the properties out to a file + // + Path fileProperties = XacmlPolicyUtils.getPropertiesPath(policyFolder.getRoot().toPath()); + XacmlPolicyUtils.storeXacmlProperties(mockProperties, fileProperties); + // + // Now we can test the copy method + // + XacmlPolicyUtils.FileCreator myCreator = (String filename) -> policyFolder.newFile("copy/" + filename); + File propertiesFile = XacmlPolicyUtils.copyXacmlPropertiesContents( + fileProperties.toAbsolutePath().toString(), mockProperties, myCreator); + + assertThat(propertiesFile.canRead()).isTrue(); + assertThat(Path.of(copyFolder.getAbsolutePath(), + rootPath.getFileName().toString()).toFile().canRead()).isTrue(); + assertThat(Path.of(copyFolder.getAbsolutePath(), + path1.getFileName().toString()).toFile().canRead()).isTrue(); + } } diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java index a9d58b9e..66f965ff 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java @@ -202,7 +202,7 @@ public class XacmlPdpApplicationManager { // Ideally we shouldn't ever get here if we // are ensuring we are reporting a set of Policy Types and the // pap honors that. The loadPolicy for each application should be - // the own throwing exceptions if there are any errors in the policy type. + // the one throwing exceptions if there are any errors in the policy type. // throw new XacmlApplicationException("Application not found for policy type" + policy.getTypeIdentifier()); } |