Update baseUrl of pms_v2.0
[portal/nonrtric-controlpanel.git] / webapp-backend / src / test / java / org / oransc / portal / nonrtric / controlpanel / controller / AbstractControllerTest.java
index 08c1c74..504223b 100644 (file)
@@ -27,23 +27,19 @@ import java.util.Map;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
-import org.oransc.portal.nonrtric.controlpanel.config.WebSecurityMockConfiguration;
+import org.oransc.portal.nonrtric.controlpanel.util.AsyncRestClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.boot.test.web.client.TestRestTemplate;
 import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.web.util.UriComponentsBuilder;
 
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
 // Need the fake answers from the backend
-@ActiveProfiles("test")
-public class AbstractControllerTest {
+class AbstractControllerTest {
 
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
@@ -52,22 +48,19 @@ public class AbstractControllerTest {
     @LocalServerPort
     private int localServerPort;
 
-    @Autowired
-    protected TestRestTemplate restTemplate;
+    protected final AsyncRestClient webClient = new AsyncRestClient("");
 
     /**
      * Flexible URI builder.
      *
-     * @param queryParams
-     *        Map of string-string query parameters
-     * @param path
-     *        Array of path components. If a component has an
-     *        embedded slash, the string is split and each
-     *        subcomponent is added individually.
+     * @param queryParams Map of string-string query parameters
+     * @param path Array of path components. If a component has an embedded
+     *        slash, the string is split and each subcomponent is added
+     *        individually.
      * @return URI
      */
     protected URI buildUri(final Map<String, String> queryParams, final String... path) {
-        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + localServerPort + "/");
+        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("https://localhost:" + localServerPort + "/");
         for (int p = 0; p < path.length; ++p) {
             if (path[p] == null || path[p].isEmpty()) {
                 throw new IllegalArgumentException("Unexpected null or empty at path index " + Integer.toString(p));
@@ -94,20 +87,10 @@ public class AbstractControllerTest {
     // Because I put the annotations on this parent class,
     // must define at least one test here.
     @Test
-    public void contextLoads() {
+    void contextLoads() {
         // Silence Sonar warning about missing assertion.
         Assertions.assertTrue(logger.isWarnEnabled());
         logger.info("Context loads on mock profile");
     }
 
-    public TestRestTemplate testRestTemplateAdminRole() {
-        return restTemplate.withBasicAuth(WebSecurityMockConfiguration.TEST_CRED_ADMIN,
-            WebSecurityMockConfiguration.TEST_CRED_ADMIN);
-    }
-
-    public TestRestTemplate testRestTemplateStandardRole() {
-        return restTemplate.withBasicAuth(WebSecurityMockConfiguration.TEST_CRED_STANDARD,
-            WebSecurityMockConfiguration.TEST_CRED_STANDARD);
-    }
-
 }