2 * ========================LICENSE_START=================================
\r
5 * Copyright (C) 2023-2024 OpenInfra Foundation Europe.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ========================LICENSE_END===================================
\r
21 package org.oransc.nonrtric.sample.rest;
\r
23 import static org.junit.jupiter.api.Assertions.assertEquals;
\r
25 import org.junit.jupiter.api.Test;
\r
26 import org.mockito.InjectMocks;
\r
27 import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
\r
28 import org.springframework.mock.web.MockHttpServletRequest;
\r
30 @WebMvcTest(HelloWorldController.class)
\r
31 public class HelloWorldControllerTest {
\r
34 private HelloWorldController helloWorldController;
\r
37 public void testHelloWorldEndpoint() {
\r
38 MockHttpServletRequest request = new MockHttpServletRequest();
\r
39 request.setRequestURI("/helloworld/v1");
\r
41 String result = helloWorldController.helloWorld(request);
\r
43 assertEquals("Hello from /helloworld/v1", result);
\r
47 public void testHelloWorldSubpathEndpoint() {
\r
48 MockHttpServletRequest request = new MockHttpServletRequest();
\r
49 request.setRequestURI("/helloworld/v1/subpath1");
\r
51 String result = helloWorldController.helloWorldSubpath1(request);
\r
53 assertEquals("Hello from /helloworld/v1/subpath1", result);
\r
57 public void testHelloWorld2Endpoint() {
\r
58 MockHttpServletRequest request = new MockHttpServletRequest();
\r
59 request.setRequestURI("/helloworld2/v1");
\r
61 String result = helloWorldController.helloWorld2(request);
\r
63 assertEquals("Hello from /helloworld2/v1", result);
\r
67 public void testHelloWorldEndpointV2() {
\r
68 MockHttpServletRequest request = new MockHttpServletRequest();
\r
69 request.setRequestURI("/helloworld/v2");
\r
71 String result = helloWorldController.helloWorldV2(request);
\r
73 assertEquals("Hello from /helloworld/v2", result);
\r
77 public void testHelloWorldSubpathEndpointV2() {
\r
78 MockHttpServletRequest request = new MockHttpServletRequest();
\r
79 request.setRequestURI("/helloworld/v2/subpath1");
\r
81 String result = helloWorldController.helloWorldSubpath1V2(request);
\r
83 assertEquals("Hello from /helloworld/v2/subpath1", result);
\r