diff options
author | Pamela Dragosh <pd1248@att.com> | 2021-07-19 14:37:41 -0400 |
---|---|---|
committer | Pamela Dragosh <pd1248@att.com> | 2021-07-20 10:30:04 -0400 |
commit | 24446884306a87a1d22fb8d0b28efbf41201a87c (patch) | |
tree | 263eebaae79945d34aab98e149e10cdbb3bb1c8f /applications/monitoring/src/test | |
parent | e3d0ebb1599c36f23ec82ca2f428af6db8fa4373 (diff) |
Include returned attributes in Decision
Adds new method to return attributes in a decision, which
can be configurable.
By default it is turned off which ensures that the current
functionality is maintained for our client applications.
Enhanced the JUnits for the applications to ensure that no
extra information is passed, thus maintaining backward
compatibility.
Issue-ID: POLICY-2865
Change-Id: Ia533e5462c0cb475cb1f72f34e95f128d6c52678
Signed-off-by: Pamela Dragosh <pd1248@att.com>
Diffstat (limited to 'applications/monitoring/src/test')
-rw-r--r-- | applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java index a1f18927..40414f56 100644 --- a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java +++ b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java @@ -184,6 +184,12 @@ public class MonitoringPdpApplicationTest { assertThat(decision.getKey()).isNotNull(); assertThat(decision.getKey().getPolicies()).isEmpty(); + // + // Monitoring applications should not have this information returned + // + assertThat(decision.getKey().getAdvice()).isNull(); + assertThat(decision.getKey().getObligations()).isNull(); + assertThat(decision.getKey().getAttributes()).isNull(); } @SuppressWarnings("unchecked") @@ -204,10 +210,18 @@ public class MonitoringPdpApplicationTest { // Pair<DecisionResponse, Response> decision = service.makeDecision(requestSinglePolicy, null); LOGGER.info("Decision {}", decision); - + // + // Should have one policy returned + // assertThat(decision.getKey()).isNotNull(); assertThat(decision.getKey().getPolicies()).hasSize(1); // + // Monitoring applications should not have this information returned + // + assertThat(decision.getKey().getAdvice()).isNull(); + assertThat(decision.getKey().getObligations()).isNull(); + assertThat(decision.getKey().getAttributes()).isNull(); + // // Dump it out as Json // LOGGER.info(gson.encode(decision.getKey())); @@ -216,9 +230,20 @@ public class MonitoringPdpApplicationTest { // decision = service.makeDecision(requestPolicyType, null); LOGGER.info("Decision {}", decision); - + // + // Should have one policy returned + // assertThat(decision.getKey()).isNotNull(); assertThat(decision.getKey().getPolicies()).hasSize(1); + // + // Monitoring applications should not have this information returned + // + assertThat(decision.getKey().getAdvice()).isNull(); + assertThat(decision.getKey().getObligations()).isNull(); + assertThat(decision.getKey().getAttributes()).isNull(); + // + // Validate the full policy is returned + // Map<String, Object> jsonPolicy = (Map<String, Object>) decision.getKey().getPolicies().get("onap.scaleout.tca"); assertThat(jsonPolicy).isNotNull(); assertThat(jsonPolicy.get("properties")).isNotNull(); @@ -233,9 +258,20 @@ public class MonitoringPdpApplicationTest { requestQueryParams.put("abbrev", new String[] {"true"}); decision = service.makeDecision(requestPolicyType, requestQueryParams); LOGGER.info("Decision {}", decision); - + // + // Should have one policy returned + // assertThat(decision.getKey()).isNotNull(); assertThat(decision.getKey().getPolicies()).hasSize(1); + // + // Monitoring applications should not have this information returned + // + assertThat(decision.getKey().getAdvice()).isNull(); + assertThat(decision.getKey().getObligations()).isNull(); + assertThat(decision.getKey().getAttributes()).isNull(); + // + // Validate an abbreviated policy is returned + // jsonPolicy = (Map<String, Object>) decision.getKey().getPolicies().get("onap.scaleout.tca"); assertThat(jsonPolicy).isNotNull().doesNotContainKey("properties"); // @@ -245,9 +281,20 @@ public class MonitoringPdpApplicationTest { requestQueryParams.put("abbrev", new String[] {"false"}); decision = service.makeDecision(requestPolicyType, requestQueryParams); LOGGER.info("Decision {}", decision); - + // + // Should have one policy returned + // assertThat(decision.getKey()).isNotNull(); assertThat(decision.getKey().getPolicies()).hasSize(1); + // + // Monitoring applications should not have this information returned + // + assertThat(decision.getKey().getAdvice()).isNull(); + assertThat(decision.getKey().getObligations()).isNull(); + assertThat(decision.getKey().getAttributes()).isNull(); + // + // And should have full policy returned + // jsonPolicy = (Map<String, Object>) decision.getKey().getPolicies().get("onap.scaleout.tca"); assertThat(jsonPolicy).isNotNull(); assertThat(jsonPolicy.get("properties")).isNotNull(); |