summaryrefslogtreecommitdiffstats
path: root/applications/common/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'applications/common/src/test')
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/TestUtilsCommon.java6
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java19
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java4
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java2
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java4
5 files changed, 17 insertions, 18 deletions
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/TestUtilsCommon.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/TestUtilsCommon.java
index ab5dde27..026bea9e 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/TestUtilsCommon.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/TestUtilsCommon.java
@@ -112,9 +112,11 @@ public class TestUtilsCommon {
* @param policyIds Collection of IdReference objects
* @return Response object
*/
- public static Response createXacmlResponse(StatusCode code, Decision decision, Collection<Obligation> obligations,
+ public static Response createXacmlResponse(StatusCode code, String message, Decision decision,
+ Collection<Obligation> obligations,
Collection<IdReference> policyIds) {
- StdStatus status = new StdStatus(code);
+
+ StdStatus status = new StdStatus(code, message);
StdMutableResult result = new StdMutableResult(decision, status);
result.addObligations(obligations);
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java
index 8039a9cf..8e692583 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java
@@ -120,7 +120,7 @@ public class StdBaseTranslatorTest {
}
@Test
- public void test() throws ParseException {
+ public void testTranslatorNormalFlow() throws Exception {
StdBaseTranslator translator = new MyStdBaseTranslator();
assertNotNull(translator);
assertThatThrownBy(() -> translator.convertPolicy(null)).isInstanceOf(ToscaPolicyConversionException.class);
@@ -176,7 +176,7 @@ public class StdBaseTranslatorTest {
ids.put("onap.policies.Test", "1.0.0");
Collection<IdReference> policyIds = TestUtilsCommon.createPolicyIdList(ids);
- Response xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_OK,
+ Response xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_OK, null,
Decision.PERMIT, Arrays.asList(obligation), policyIds);
DecisionResponse decision = translator.convertResponse(xacmlResponse);
@@ -210,7 +210,7 @@ public class StdBaseTranslatorTest {
ids.put("onap.policies.Test", "1.0.0");
Collection<IdReference> policyIds = TestUtilsCommon.createPolicyIdList(ids);
- Response xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_OK,
+ Response xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_OK, null,
Decision.PERMIT, Arrays.asList(obligation), policyIds);
DecisionResponse decision = translator.convertResponse(xacmlResponse);
@@ -220,28 +220,25 @@ public class StdBaseTranslatorTest {
assertThat(decision.getPolicies()).isNotNull();
assertThat(decision.getPolicies().size()).isEqualTo(0);
- //
- // This will need more work when I fix
- // the convertResponse
- //
-
Obligation badObligation = TestUtilsCommon.createXacmlObligation(
ToscaDictionary.ID_OBLIGATION_REST_BODY.stringValue(),
Arrays.asList(assignmentBadPolicy, assignmentUnknown));
- xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE,
+ xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE, null,
Decision.PERMIT, Arrays.asList(badObligation), policyIds);
decision = translator.convertResponse(xacmlResponse);
assertNotNull(decision);
- xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_OK,
- Decision.DENY, Arrays.asList(badObligation), policyIds);
+ xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ "Bad obligation", Decision.DENY, Arrays.asList(badObligation), policyIds);
decision = translator.convertResponse(xacmlResponse);
assertNotNull(decision);
+ assertThat(decision.getStatus()).isEqualTo("error");
+ assertThat(decision.getMessage()).isEqualTo("Bad obligation");
}
private class MyStdBaseTranslator extends StdBaseTranslator {
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java
index 6ff7a7f1..42c13d9e 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java
@@ -108,7 +108,7 @@ public class StdCombinedPolicyResultsTranslatorTest {
ids.put("onap.policies.Test", "1.0.0");
Collection<IdReference> policyIds = TestUtilsCommon.createPolicyIdList(ids);
- Response xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_OK,
+ Response xacmlResponse = TestUtilsCommon.createXacmlResponse(StdStatusCode.STATUS_CODE_OK, null,
Decision.PERMIT, Arrays.asList(obligation), policyIds);
DecisionResponse decision = translator.convertResponse(xacmlResponse);
@@ -148,7 +148,7 @@ public class StdCombinedPolicyResultsTranslatorTest {
}
@Test
- public void testDecision() {
+ public void testDecision() throws ToscaPolicyConversionException {
StdCombinedPolicyResultsTranslator translator = new StdCombinedPolicyResultsTranslator();
DecisionRequest decision = new DecisionRequest();
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java
index aeb4cf88..e191a08a 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java
@@ -237,7 +237,7 @@ public class StdMatchableTranslatorTest {
Collection<IdReference> policyIds = TestUtilsCommon.createPolicyIdList(ids);
com.att.research.xacml.api.Response xacmlResponse = TestUtilsCommon.createXacmlResponse(
- StdStatusCode.STATUS_CODE_OK, Decision.PERMIT,
+ StdStatusCode.STATUS_CODE_OK, null, Decision.PERMIT,
Arrays.asList(obligation1, obligation2, obligation3), policyIds);
//
// Test the response
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 e7ea049a..c95d3ca5 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -255,7 +255,7 @@ public class StdXacmlApplicationServiceProviderTest {
}
@Test
- public void testMakeDecision() {
+ public void testMakeDecision() throws ToscaPolicyConversionException {
prov.createEngine(null);
DecisionRequest decreq = mock(DecisionRequest.class);