summaryrefslogtreecommitdiffstats
path: root/applications/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'applications/common/src')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java2
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java6
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java7
3 files changed, 7 insertions, 8 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java
index 0b9975f7..edd33c0e 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java
@@ -89,7 +89,7 @@ public interface XacmlApplicationServiceProvider {
*
* @param toscaPolicy object
*/
- boolean loadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException;
+ void loadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException;
/**
* unloadPolicy a Tosca Policy.
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
index 12135f4a..5aea3457 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
@@ -116,7 +116,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
}
@Override
- public synchronized boolean loadPolicy(ToscaPolicy toscaPolicy) {
+ public synchronized void loadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException {
try {
//
// Convert the policies first
@@ -165,10 +165,8 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
//
this.mapLoadedPolicies.put(toscaPolicy, refPath);
} catch (IOException | ToscaPolicyConversionException e) {
- LOGGER.error("Failed to loadPolicies {}", e);
- return false;
+ throw new XacmlApplicationException("loadPolicy failed", e);
}
- return true;
}
@Override
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
index 6139a528..e7ea049a 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
@@ -190,10 +190,10 @@ public class StdXacmlApplicationServiceProviderTest {
}
@Test
- public void testLoadPolicy_ConversionError() throws ToscaPolicyConversionException {
+ public void testLoadPolicy_ConversionError() throws XacmlApplicationException, ToscaPolicyConversionException {
when(trans.convertPolicy(policy)).thenReturn(null);
- assertFalse(prov.loadPolicy(policy));
+ assertThatThrownBy(() -> prov.loadPolicy(policy)).isInstanceOf(XacmlApplicationException.class);
}
@Test
@@ -203,7 +203,8 @@ public class StdXacmlApplicationServiceProviderTest {
final Set<String> set = XACMLProperties.getRootPolicyIDs(prov.getProperties());
- assertTrue(prov.loadPolicy(policy));
+ // Load policy
+ prov.loadPolicy(policy);
// policy file should have been created
File policyFile = new File(TEMP_DIR, "my-name_1.2.3.xml");