Improve tests/issues found in Sonar report - A1 Oslo

Issue-ID: CCSDK-4037
Change-Id: Ic8e13141f2e0dcb32c51134f96ce883bc05701ee
Signed-off-by: Raviteja Karumuri <raviteja.karumuri@est.tech>
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java
index 6f45864..714fd2e 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java
@@ -36,8 +36,10 @@
 @SpringBootApplication
 public class Application {
 
-    @Autowired
-    private RefreshConfigTask configRefresh;
+    private final RefreshConfigTask configRefresh;
+    Application(RefreshConfigTask configRefresh) {
+        this.configRefresh = configRefresh;
+    }
 
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerTestV3.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerV3Test.java
similarity index 97%
rename from a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerTestV3.java
rename to a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerV3Test.java
index c634ecc..40990f6 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerTestV3.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerV3Test.java
@@ -45,7 +45,6 @@
 import static org.awaitility.Awaitility.await;
 import static org.hamcrest.CoreMatchers.equalTo;
 
-@TestMethodOrder(MethodOrderer.MethodName.class)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @TestPropertySource(properties = { //
         "server.ssl.key-store=./config/keystore.jks", //
@@ -53,7 +52,7 @@
         "app.vardata-directory=./target", //
         "app.config-file-schema-path=/application_configuration_schema.json" //
 })
-class ConfigurationControllerTestV3 {
+class ConfigurationControllerV3Test {
     @Autowired
     ApplicationContext context;
 
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerTestV3.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3Test.java
similarity index 97%
rename from a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerTestV3.java
rename to a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3Test.java
index a8c5fba..e81a936 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerTestV3.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3Test.java
@@ -65,7 +65,7 @@
         "app.filepath=", //
         "app.s3.bucket=" // If this is set, S3 will be used to store data.
 })
-public class PolicyControllerTestV3 {
+class PolicyControllerV3Test {
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
     @Autowired
@@ -146,7 +146,7 @@
         Mono<ResponseEntity<String>> responseMono = testHelper.restClientV3().postForEntity(url, policyBody);
         testHelper.testSuccessResponse(responseMono, HttpStatus.CREATED, responseBody ->
                 responseBody.contains("{\"scope\":{\"ueId\":\"ue5100\",\"qosId\":\"qos5100\"},\"qosObjectives\":{\"priorityLevel\":5100.0}}"));
-        testHelper.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1policymanagement/v1/policies/"));
+        testHelper.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/"));
     }
 
     @Test
@@ -158,11 +158,11 @@
         testHelper.addPolicyType(policyTypeName, nonRtRicId);
         String policyBody = testHelper.postPolicyBody(nonRtRicId, policyTypeName, "1");
         Mono<ResponseEntity<String>> responseMono = testHelper.restClientV3().postForEntity(url, policyBody);
-        testHelper.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1policymanagement/v1/policies/1"));
+        testHelper.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/1"));
     }
 
     @Test
-    @DisplayName("test Create Policy with exisitng policy id")
+    @DisplayName("test Create Policy with existing policy id")
     void testPostPolicyWithExistingPolicyID() throws Exception {
         String nonRtRicId = "ric.1";
         String policyTypeName = "type1_1.2.3";
@@ -234,7 +234,7 @@
         String policyTypeName = "type1_1.2.3";
         String nonRtRicId = "ricOne";
         testHelper.addPolicyType(policyTypeName, nonRtRicId);
-        Mono<ResponseEntity<String>> responseMono = testHelper.restClientV3().getForEntity("/policytypes" + "?nearRtRicId=\"noRic\"");
+        Mono<ResponseEntity<String>> responseMono = testHelper.restClientV3().getForEntity("/policy-types" + "?nearRtRicId=\"noRic\"");
         testHelper.testErrorCode(responseMono, HttpStatus.NOT_FOUND, "Near-RT RIC not Found using ID:");
     }
 
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerTestV3.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3Test.java
similarity index 95%
rename from a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerTestV3.java
rename to a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3Test.java
index 576ae7f..5f97df0 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerTestV3.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3Test.java
@@ -52,10 +52,9 @@
         "app.webclient.trust-store=./config/truststore.jks", //
         "app.webclient.trust-store-used=true", //
         "app.vardata-directory=/tmp/pmstestv3", //a
-        "app.filepath=", //
         "app.s3.bucket=" // If this is set, S3 will be used to store data.
 })
-public class RicRepositoryControllerTestV3 {
+class RicRepositoryControllerV3Test {
 
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
@@ -89,6 +88,7 @@
     @BeforeEach
     void init() {
         testHelper.port = port;
+        rics.clear();
         this.applicationConfig.setAuthProviderUrl(testHelper.baseUrl() + OpenPolicyAgentSimulatorController.ACCESS_CONTROL_URL);
     }
 
@@ -116,8 +116,9 @@
         testHelper.addPolicyType("2", "ricAddedTwo");
         Mono<ResponseEntity<String>> responseEntityMono = testHelper.restClientV3().getForEntity("/rics");
         testHelper.testSuccessResponse(responseEntityMono, HttpStatus.OK, responseBody -> responseBody
-                .contains("{\"rics\":[{\"ricId\":\"ricAddedTwo\",\"managedElementIds\":[],\"state\":\"AVAILABLE\"," +
+                .contains("{\"ricId\":\"ricAddedTwo\",\"managedElementIds\":[],\"state\":\"AVAILABLE\"," +
                         "\"policyTypeIds\":[\"2\"]},{\"ricId\":\"ricAddedOne\",\"managedElementIds\":[]," +
-                        "\"state\":\"AVAILABLE\",\"policyTypeIds\":[\"1\"]}]}"));
+                        "\"state\":\"AVAILABLE\",\"policyTypeIds\":[\"1\"]"));
     }
 }
+
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerTestV3.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerV3Test.java
similarity index 98%
rename from a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerTestV3.java
rename to a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerV3Test.java
index 9eeaa3a..bfc0b68 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerTestV3.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerV3Test.java
@@ -58,7 +58,7 @@
         "app.filepath=", //
         "app.s3.bucket=" // If this is set, S3 will be used to store data.
 })
-public class ServiceControllerTestV3 {
+class ServiceControllerV3Test {
 
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());