From ed2bcd773ec3dbe07311bad597ec664c4e38c009 Mon Sep 17 00:00:00 2001 From: "Tej, Tarun" Date: Thu, 24 Aug 2017 12:13:12 -0400 Subject: Fixes for missed sonar critical issues Few fixes to the missed sonar critical issues and import warning fixes which are part of sonar critical fixes. Issue-Id: POLICY-113 Change-Id: If5010e984020b673e058cc1d01a8964a2354796d Signed-off-by: Tarun Tej Velaga --- .../org/onap/policy/pdp/rest/api/services/NotificationService.java | 7 +++++++ .../onap/policy/pdp/rest/notifications/NotificationController.java | 2 +- .../onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'ONAP-PDP-REST/src') diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java index c1b9f63e1..6ca52ca40 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java @@ -118,6 +118,13 @@ public class NotificationService { callThread(); } } + + public static void reloadProps(){ + dmaapServers = null; + aafLogin = null; + aafPassword = null; + backUpthread = null; + } private void run(String notificationTopic, NotificationServiceType serviceType) throws PolicyException{ // Check Validation diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java index 577d5b347..8121bdc8f 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java @@ -175,7 +175,7 @@ public class NotificationController { } } - private void setNotificationFlag(boolean value) { + private static void setNotificationFlag(boolean value) { notificationFlag = value; } diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java index fe4ce0599..ac8b269eb 100644 --- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java +++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java @@ -55,6 +55,7 @@ import org.onap.policy.pdp.rest.api.models.ConfigFirewallPolicyAPIRequest; import org.onap.policy.pdp.rest.api.models.ConfigNameRequest; import org.onap.policy.pdp.rest.api.models.ConfigPolicyAPIRequest; import org.onap.policy.pdp.rest.api.services.CreateUpdatePolicyServiceImpl; +import org.onap.policy.pdp.rest.api.services.NotificationService; import org.onap.policy.pdp.rest.config.PDPRestConfig; import org.onap.policy.utils.PolicyUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -195,9 +196,11 @@ public class PolicyEngineServicesTest { @Test public void getNotificationTopicValidPassTest() throws Exception{ + // Values can be polluted due to failure tests and need to be reloaded. XACMLProperties.reloadProperties(); System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/notification.xacml.pdp.properties"); XACMLProperties.getProperties(); + NotificationService.reloadProps(); // Add a Topic. mockMvc.perform(post("/getNotification").headers(headers).header(UUIDHEADER, "123").content("test")).andExpect(status().isOk()); // Try to add same topic should fail. -- cgit 1.2.3-korg