2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property and Nokia
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
20 package org.oransc.ric.portal.dashboard.controller;
22 import java.lang.invoke.MethodHandles;
24 import java.util.List;
26 import org.junit.jupiter.api.Assertions;
27 import org.junit.jupiter.api.Test;
28 import org.oransc.ric.e2mgr.client.model.GetNodebResponse;
29 import org.oransc.ric.e2mgr.client.model.NodebIdentity;
30 import org.oransc.ric.e2mgr.client.model.ResetRequest;
31 import org.oransc.ric.e2mgr.client.model.SetupRequest;
32 import org.oransc.ric.portal.dashboard.model.RanDetailsTransport;
33 import org.oransc.ric.portal.dashboard.model.SuccessTransport;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36 import org.springframework.core.ParameterizedTypeReference;
37 import org.springframework.http.HttpEntity;
38 import org.springframework.http.HttpMethod;
39 import org.springframework.http.ResponseEntity;
41 public class E2ManagerControllerTest extends AbstractControllerTest {
43 private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
46 public void versionTest() {
47 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, E2ManagerController.VERSION_METHOD);
48 logger.info("Invoking {}", uri);
49 SuccessTransport st = restTemplate.getForObject(uri, SuccessTransport.class);
50 Assertions.assertFalse(st.getData().toString().isEmpty());
54 public void healthTest() {
55 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, E2ManagerController.HEALTH_METHOD);
56 logger.info("Invoking {}", uri);
57 ResponseEntity<Void> voidResponse = restTemplate.getForEntity(uri, Void.class);
58 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
62 public void ranDetailsTest() {
63 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, E2ManagerController.RAN_METHOD);
64 logger.info("Invoking {}", uri);
65 ResponseEntity<List<RanDetailsTransport>> response = testRestTemplateStandardRole().exchange(uri,
66 HttpMethod.GET, null, new ParameterizedTypeReference<List<RanDetailsTransport>>() {
68 Assertions.assertFalse(response.getBody().isEmpty());
72 public void nodebListTest() {
73 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, E2ManagerController.NODEB_LIST_METHOD);
74 logger.info("Invoking {}", uri);
75 ResponseEntity<List<NodebIdentity>> response = testRestTemplateStandardRole().exchange(uri, HttpMethod.GET,
76 null, new ParameterizedTypeReference<List<NodebIdentity>>() {
78 Assertions.assertFalse(response.getBody().isEmpty());
82 public void nodebStatusTest() {
83 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, E2ManagerController.NODEB_METHOD, "nodeb");
84 logger.info("Invoking {}", uri);
85 GetNodebResponse response = testRestTemplateStandardRole().getForObject(uri, GetNodebResponse.class);
86 Assertions.assertNotNull(response.getRanName());
90 public void endcSetupTest() {
91 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, E2ManagerController.ENDC_SETUP_METHOD);
92 logger.info("Invoking {}", uri);
93 SetupRequest setup = new SetupRequest();
94 HttpEntity<SetupRequest> entity = new HttpEntity<>(setup);
95 ResponseEntity<Void> voidResponse = testRestTemplateAdminRole().exchange(uri, HttpMethod.POST, entity,
97 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
101 public void x2SetupTest() {
102 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, E2ManagerController.X2_SETUP_METHOD);
103 logger.info("Invoking {}", uri);
104 SetupRequest setup = new SetupRequest();
105 HttpEntity<SetupRequest> entity = new HttpEntity<>(setup);
106 ResponseEntity<Void> voidResponse = testRestTemplateAdminRole().exchange(uri, HttpMethod.POST, entity,
108 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
111 // Aka big--button test
113 public void nodebPutTest() {
114 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, E2ManagerController.NODEB_METHOD);
115 logger.info("Invoking {}", uri);
116 ResponseEntity<Void> voidResponse = testRestTemplateAdminRole().exchange(uri, HttpMethod.PUT, null, Void.class);
117 logger.debug("nodebPutTest: response {}", voidResponse);
118 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
122 public void resetTest() {
123 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, E2ManagerController.RESET_METHOD, "ranName");
124 logger.info("Invoking {}", uri);
125 ResetRequest reset = new ResetRequest();
126 HttpEntity<ResetRequest> entity = new HttpEntity<>(reset);
127 ResponseEntity<Void> voidResponse = testRestTemplateAdminRole().exchange(uri, HttpMethod.PUT, entity,
129 logger.debug("resetTest: response {}", voidResponse);
130 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());