7ce5976ed05eff2210877ce6257b45e67fa790d8
[portal/ric-dashboard.git] / webapp-backend / src / test / java / org / oransc / ric / portal / dashboard / test / controller / AnrXappControllerTest.java
1 /*-
2  * ========================LICENSE_START=================================
3  * O-RAN-SC
4  * %%
5  * Copyright (C) 2019 AT&T Intellectual Property and Nokia
6  * %%
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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===================================
19  */
20 package org.oransc.ric.portal.dashboard.test.controller;
21
22 import java.lang.invoke.MethodHandles;
23 import java.net.URI;
24
25 import org.junit.jupiter.api.Assertions;
26 import org.junit.jupiter.api.Test;
27 import org.oransc.ric.anrxapp.client.model.GgNodeBTable;
28 import org.oransc.ric.anrxapp.client.model.NeighborCellRelationMod;
29 import org.oransc.ric.anrxapp.client.model.NeighborCellRelationTable;
30 import org.oransc.ric.portal.dashboard.controller.AnrXappController;
31 import org.oransc.ric.portal.dashboard.model.SuccessTransport;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34 import org.springframework.http.HttpEntity;
35 import org.springframework.http.HttpMethod;
36 import org.springframework.http.ResponseEntity;
37
38 public class AnrXappControllerTest extends AbstractControllerTest {
39
40         private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
41
42         @Test
43         public void versionTest() {
44                 URI uri = buildUri(null, AnrXappController.CONTROLLER_PATH, AnrXappController.VERSION_METHOD);
45                 logger.info("Invoking {}", uri);
46                 SuccessTransport st = restTemplate.getForObject(uri, SuccessTransport.class);
47                 Assertions.assertFalse(st.getData().toString().isEmpty());
48         }
49
50         @Test
51         public void healthAliveTest() {
52                 URI uri = buildUri(null, AnrXappController.CONTROLLER_PATH, AnrXappController.HEALTH_ALIVE_METHOD);
53                 logger.info("Invoking {}", uri);
54                 ResponseEntity<Void> voidResponse = restTemplate.getForEntity(uri, Void.class);
55                 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
56         }
57
58         @Test
59         public void healthReadyTest() {
60                 URI uri = buildUri(null, AnrXappController.CONTROLLER_PATH, AnrXappController.HEALTH_READY_METHOD);
61                 logger.info("Invoking {}", uri);
62                 ResponseEntity<Void> voidResponse = restTemplate.getForEntity(uri, Void.class);
63                 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
64         }
65
66         @Test
67         public void gnodebsTest() {
68                 URI uri = buildUri(null, AnrXappController.CONTROLLER_PATH, AnrXappController.GNODEBS_METHOD);
69                 logger.info("Invoking {}", uri);
70                 GgNodeBTable list = restTemplate.getForObject(uri, GgNodeBTable.class);
71                 Assertions.assertFalse(list.getGNodeBIds().isEmpty());
72         }
73
74         @Test
75         public void ncrtGetTest() {
76                 URI uri = buildUri(null, AnrXappController.CONTROLLER_PATH, AnrXappController.NCRT_METHOD);
77                 logger.info("Invoking {}", uri);
78                 NeighborCellRelationTable table = restTemplate.getForObject(uri, NeighborCellRelationTable.class);
79                 Assertions.assertFalse(table.getNcrtRelations().isEmpty());
80         }
81
82         @Test
83         public void ncrtPutTest() {
84                 URI uri = buildUri(null, AnrXappController.CONTROLLER_PATH, AnrXappController.NCRT_METHOD,
85                                 AnrXappController.PP_SERVING, "serving", AnrXappController.PP_NEIGHBOR, "neighbor");
86                 logger.info("Invoking {}", uri);
87                 HttpEntity<NeighborCellRelationMod> entity = new HttpEntity<>(new NeighborCellRelationMod());
88                 ResponseEntity<Void> voidResponse = restTemplate.exchange(uri, HttpMethod.PUT, entity, Void.class);
89                 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
90         }
91
92         @Test
93         public void ncrtDeleteTest() {
94                 URI uri = buildUri(null, AnrXappController.CONTROLLER_PATH, AnrXappController.NCRT_METHOD,
95                                 AnrXappController.PP_SERVING, "serving", AnrXappController.PP_NEIGHBOR, "neighbor");
96                 logger.info("Invoking {}", uri);
97                 ResponseEntity<Void> voidResponse = restTemplate.exchange(uri, HttpMethod.DELETE, null, Void.class);
98                 Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful());
99         }
100
101 }