X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dashboard%2Fwebapp-backend%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fcontroller%2FAbstractControllerTest.java;h=09d3a869d30efd61bdffa5395f75da308e75256b;hb=a5470fae8111ad883b674450324566031d454251;hp=d4163f0dfb0fa5107ea32ae621d2e9ee289fb562;hpb=a2bc79c5f0027e953815d6e98814a748b36827aa;p=nonrtric.git diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AbstractControllerTest.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AbstractControllerTest.java index d4163f0d..09d3a869 100644 --- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AbstractControllerTest.java +++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AbstractControllerTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,69 +44,69 @@ import org.springframework.web.util.UriComponentsBuilder; @ActiveProfiles("test") public class AbstractControllerTest { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - // Created by Spring black magic - // https://spring.io/guides/gs/testing-web/ - @LocalServerPort - private int localServerPort; + // Created by Spring black magic + // https://spring.io/guides/gs/testing-web/ + @LocalServerPort + private int localServerPort; - @Autowired - protected TestRestTemplate restTemplate; + @Autowired + protected TestRestTemplate restTemplate; - /** - * 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. - * @return URI - */ - protected URI buildUri(final Map queryParams, final String... path) { - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://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)); - } else if (path[p].contains("/")) { - String[] subpaths = path[p].split("/"); - for (String s : subpaths) - if (!s.isEmpty()) - builder.pathSegment(s); - } else { - builder.pathSegment(path[p]); - } - } - if (queryParams != null && queryParams.size() > 0) { - for (Map.Entry entry : queryParams.entrySet()) { - if (entry.getKey() == null || entry.getValue() == null) - throw new IllegalArgumentException("Unexpected null key or value"); - else - builder.queryParam(entry.getKey(), entry.getValue()); - } - } - return builder.build().encode().toUri(); - } + /** + * 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. + * @return URI + */ + protected URI buildUri(final Map queryParams, final String... path) { + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://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)); + } else if (path[p].contains("/")) { + String[] subpaths = path[p].split("/"); + for (String s : subpaths) + if (!s.isEmpty()) + builder.pathSegment(s); + } else { + builder.pathSegment(path[p]); + } + } + if (queryParams != null && queryParams.size() > 0) { + for (Map.Entry entry : queryParams.entrySet()) { + if (entry.getKey() == null || entry.getValue() == null) + throw new IllegalArgumentException("Unexpected null key or value"); + else + builder.queryParam(entry.getKey(), entry.getValue()); + } + } + return builder.build().encode().toUri(); + } - // Because I put the annotations on this parent class, - // must define at least one test here. - @Test - public void contextLoads() { - // Silence Sonar warning about missing assertion. - Assertions.assertTrue(logger.isWarnEnabled()); - logger.info("Context loads on mock profile"); - } + // Because I put the annotations on this parent class, + // must define at least one test here. + @Test + public 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 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); - } + public TestRestTemplate testRestTemplateStandardRole() { + return restTemplate.withBasicAuth(WebSecurityMockConfiguration.TEST_CRED_STANDARD, + WebSecurityMockConfiguration.TEST_CRED_STANDARD); + } }