Fixes for missed sonar critical issues
[policy/engine.git] / ONAP-PDP-REST / src / test / java / org / onap / policy / pdp / rest / api / test / PolicyEngineServicesTest.java
index 2a76f58..ac8b269 100644 (file)
@@ -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,6 +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.  
@@ -236,7 +242,7 @@ public class PolicyEngineServicesTest {
                DecisionRequestParameters pep = new DecisionRequestParameters();
                Map<String,String> eventAttributes = new HashMap<>();
                eventAttributes.put("TEST", "test");
-               pep.setONAPComponentName("te123");
+               pep.setOnapName("te123");
                pep.setDecisionAttributes(eventAttributes);
                //Failure Tests. 
                mockMvc.perform(post("/getDecision")).andExpect(status().isBadRequest());
@@ -245,10 +251,10 @@ public class PolicyEngineServicesTest {
                mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
                                .headers(headers).header(UUIDHEADER, "123")).andExpect(status().isOk());
                pep.setDecisionAttributes(null);
-               pep.setONAPComponentName(null);
+               pep.setOnapName(null);
                mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
                                .headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
-               pep.setONAPComponentName("testing");
+               pep.setOnapName("testing");
                mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
                                .headers(headers)).andExpect(status().isBadRequest());
                pep.setDecisionAttributes(eventAttributes);