From ef1c07eb976ff4d8145f40ce4db092591bb78047 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 10 Mar 2020 12:41:47 -0400 Subject: Bump monitoring app code coverage Cleaned up some code to remove unnecessary branches. Add more test cases specifically for query parameters. Coverage should be above 90% for this repo. Issue-ID: POLICY-2242 Change-Id: I20a75aacd75f9b8c87abb47e88b81ab8f2d30626 Signed-off-by: Pamela Dragosh --- .../monitoring/MonitoringPdpApplication.java | 40 +++++++++------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'applications/monitoring/src/main/java') diff --git a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java index 27bb24e5..436028fd 100644 --- a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java +++ b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * 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. @@ -51,17 +51,14 @@ import org.slf4j.LoggerFactory; public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider { private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringPdpApplication.class); - private static final String ONAP_MONITORING_BASE_POLICY_TYPE = "onap.Monitoring"; - private static final String ONAP_MONITORING_CDAP = "onap.policies.monitoring.cdap.tca.hi.lo.app"; - private static final String ONAP_MONITORING_APPSERVER = + public static final String ONAP_MONITORING_BASE_POLICY_TYPE = "onap.Monitoring"; + public static final String ONAP_MONITORING_CDAP = "onap.policies.monitoring.cdap.tca.hi.lo.app"; + public static final String ONAP_MONITORING_APPSERVER = "onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server"; - private static final String ONAP_MONITORING_SONHANDLER = "onap.policies.monitoring.docker.sonhandler.app"; - private static final String ONAP_MONITORING_DERIVED_POLICY_TYPE = "onap.policies.monitoring."; - // Note: this requirement is temporary; it will no longer be necessary once the PDPs and PAP - // are updated to use the PDP Group name instead of the supported types. - private static final String ONAP_MONITORING_ALL_DERIVED_POLICY_TYPE = ONAP_MONITORING_DERIVED_POLICY_TYPE + "*"; + public static final String ONAP_MONITORING_SONHANDLER = "onap.policies.monitoring.docker.sonhandler.app"; + public static final String ONAP_MONITORING_DERIVED_POLICY_TYPE = "onap.policies.monitoring."; - private static final String VERSION_100 = "1.0.0"; + public static final String VERSION_100 = "1.0.0"; private StdCombinedPolicyResultsTranslator translator = new StdCombinedPolicyResultsTranslator(); private List supportedPolicyTypes = new ArrayList<>(); @@ -77,9 +74,6 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(ONAP_MONITORING_CDAP, VERSION_100)); supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(ONAP_MONITORING_APPSERVER, VERSION_100)); supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(ONAP_MONITORING_SONHANDLER, VERSION_100)); - - // temporary requirement - supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(ONAP_MONITORING_ALL_DERIVED_POLICY_TYPE, VERSION_100)); } @Override @@ -129,18 +123,18 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider // // Abbreviate results if needed // - if (checkAbbreviateResults(requestQueryParams) && decisionResponse.getPolicies() != null - && !decisionResponse.getPolicies().isEmpty()) { + if (checkAbbreviateResults(requestQueryParams) && decisionResponse.getPolicies() != null) { LOGGER.info("Abbreviating decision results {}", decisionResponse); for (Entry entry : decisionResponse.getPolicies().entrySet()) { - if (entry.getValue() instanceof Map) { - @SuppressWarnings("unchecked") - Map policy = (Map) entry.getValue(); - policy.remove("type_version"); - policy.remove("properties"); - policy.remove("name"); - policy.remove("version"); - } + // + // DecisionResponse policies will always be a map + // + @SuppressWarnings("unchecked") + Map policy = (Map) entry.getValue(); + policy.remove("type_version"); + policy.remove("properties"); + policy.remove("name"); + policy.remove("version"); } } return Pair.of(decisionResponse, xacmlResponse); -- cgit 1.2.3-korg