2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property
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.MethodOrderer;
28 import org.junit.jupiter.api.Order;
29 import org.junit.jupiter.api.Test;
30 import org.junit.jupiter.api.TestMethodOrder;
31 import org.oransc.ric.portal.dashboard.DashboardConstants;
32 import org.oransc.ric.portal.dashboard.config.E2ManagerMockConfiguration;
33 import org.oransc.ric.portal.dashboard.config.RICInstanceMockConfiguration;
34 import org.oransc.ric.portal.dashboard.model.RanDetailsTransport;
35 import org.oransc.ric.portal.dashboard.model.SuccessTransport;
36 import org.oransc.ricplt.e2mgr.client.model.GetNodebResponse;
37 import org.oransc.ricplt.e2mgr.client.model.NodebIdentity;
38 import org.oransc.ricplt.e2mgr.client.model.UpdateGnbRequest;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
41 import org.springframework.core.ParameterizedTypeReference;
42 import org.springframework.http.HttpEntity;
43 import org.springframework.http.HttpMethod;
44 import org.springframework.http.ResponseEntity;
46 @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
47 public class E2ManagerControllerTest extends AbstractControllerTest {
49 private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
52 public void updateGnb() {
53 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY,
54 RICInstanceMockConfiguration.INSTANCE_KEY_1, E2ManagerController.NODEB_PREFIX, "nobeb");
55 logger.info("Invoking {}", uri);
56 UpdateGnbRequest update = new UpdateGnbRequest();
57 HttpEntity<UpdateGnbRequest> entity = new HttpEntity<>(update);
58 ResponseEntity<Void> voidResponse = testRestTemplateAdminRole().exchange(uri, HttpMethod.PUT, entity,
60 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
65 public void versionTest() {
66 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, DashboardConstants.VERSION_METHOD);
67 logger.info("Invoking {}", uri);
68 SuccessTransport st = restTemplate.getForObject(uri, SuccessTransport.class);
69 Assertions.assertFalse(st.getData().toString().isEmpty());
74 public void healthTest() {
75 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY,
76 RICInstanceMockConfiguration.INSTANCE_KEY_1, E2ManagerController.HEALTH_METHOD);
77 logger.info("Invoking {}", uri);
78 ResponseEntity<Void> voidResponse = restTemplate.getForEntity(uri, Void.class);
79 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
84 public void ranDetailsTest() {
85 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY,
86 RICInstanceMockConfiguration.INSTANCE_KEY_1, E2ManagerController.RAN_METHOD);
87 logger.info("Invoking {}", uri);
88 ResponseEntity<List<RanDetailsTransport>> response = testRestTemplateStandardRole().exchange(uri,
89 HttpMethod.GET, null, new ParameterizedTypeReference<List<RanDetailsTransport>>() {
91 Assertions.assertFalse(response.getBody().isEmpty());
96 public void nodebListTest() {
97 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY,
98 RICInstanceMockConfiguration.INSTANCE_KEY_1, E2ManagerController.NODEB_LIST_METHOD);
99 logger.info("Invoking {}", uri);
100 ResponseEntity<List<NodebIdentity>> response = testRestTemplateStandardRole().exchange(uri, HttpMethod.GET,
101 null, new ParameterizedTypeReference<List<NodebIdentity>>() {
103 Assertions.assertFalse(response.getBody().isEmpty());
108 public void nodebStatusTest() {
109 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY,
110 RICInstanceMockConfiguration.INSTANCE_KEY_1, E2ManagerController.NODEB_PREFIX,
111 E2ManagerMockConfiguration.RAN_NAME_1);
112 logger.info("Invoking {}", uri);
113 GetNodebResponse response = testRestTemplateStandardRole().getForObject(uri, GetNodebResponse.class);
114 Assertions.assertNotNull(response.getRanName());
117 // Aka big--button test, run this last
120 public void nodebShutdownPutTest() {
121 URI uri = buildUri(null, E2ManagerController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY,
122 RICInstanceMockConfiguration.INSTANCE_KEY_1, E2ManagerController.NODEB_SHUTDOWN_METHOD);
123 logger.info("Invoking {}", uri);
124 ResponseEntity<Void> voidResponse = testRestTemplateAdminRole().exchange(uri, HttpMethod.PUT, null, Void.class);
125 logger.debug("nodebPutTest: response {}", voidResponse);
126 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());