Remove Sonar issues
[nonrtric.git] / policy-agent / src / test / java / org / oransc / policyagent / ApplicationTest.java
index a8cab60..0fb80f3 100644 (file)
@@ -81,6 +81,7 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.web.reactive.function.client.WebClientResponseException;
 
@@ -90,6 +91,10 @@ import reactor.util.annotation.Nullable;
 
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@TestPropertySource(
+    properties = { //
+        "server.ssl.key-store=./config/keystore.jks", //
+        "app.webclient.trust-store=./config/truststore.jks"})
 class ApplicationTest {
     private static final Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
 
@@ -332,7 +337,7 @@ class ApplicationTest {
 
         url = "/policies";
         String rsp = restClient().get(url).block();
-        assertThat(rsp.contains(policyInstanceId)).as("Response contains policy instance ID.").isTrue();
+        assertThat(rsp).as("Response contains policy instance ID.").contains(policyInstanceId);
 
         url = "/policy?id=" + policyInstanceId;
         rsp = restClient().get(url).block();
@@ -343,6 +348,7 @@ class ApplicationTest {
         testErrorCode(restClient().put(url, policyBody), HttpStatus.NOT_FOUND);
 
         url = putPolicyUrl(serviceName, ricName, policyTypeName + "XX", policyInstanceId);
+        addPolicyType(policyTypeName + "XX", "otherRic");
         testErrorCode(restClient().put(url, policyBody), HttpStatus.NOT_FOUND);
 
         url = putPolicyUrl(serviceName, ricName, policyTypeName, policyInstanceId);
@@ -403,7 +409,7 @@ class ApplicationTest {
         assertThat(info.size()).isEqualTo(1);
         PolicyInfo policyInfo = info.get(0);
         assertThat(policyInfo.id).isEqualTo("id1");
-        assertThat(policyInfo.type).isEqualTo("");
+        assertThat(policyInfo.type).isEmpty();
     }
 
     @Test
@@ -597,7 +603,7 @@ class ApplicationTest {
         // GET (all)
         url = "/services";
         rsp = restClient().get(url).block();
-        assertThat(rsp.contains(serviceName)).as("Response contains service name").isTrue();
+        assertThat(rsp).as("Response contains service name").contains(serviceName);
         logger.info(rsp);
 
         // Keep alive