X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FPolicyDBDaoTest.java;h=f7dd92a3e470d3c0790bbe390e6e64eb11403f28;hb=e598e9708241430648b553f0d3f3b2a146be1bf2;hp=bdfd8db339435f16c6fc959732659e8b4ff3b1ac;hpb=4068da123ee33b532b4b52f15545c76a978f977e;p=policy%2Fengine.git 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 bdfd8db33..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(){ @@ -156,6 +197,7 @@ public class PolicyDBDaoTest extends Mockito{ policyObject.policyAdapter.setPolicyType("Config"); policyObject.policyAdapter.setDomainDir("com"); policyObject.policyAdapter.setVersion("1"); + policyObject.policyAdapter.setHighestVersion(1); PolicyType policyTypeObject = new PolicyType(); policyObject.policyAdapter.setPolicyData(policyTypeObject); ClassLoader classLoader = getClass().getClassLoader();