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.config;
22 import static org.mockito.ArgumentMatchers.any;
23 import static org.mockito.Mockito.doAnswer;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.when;
27 import java.lang.invoke.MethodHandles;
29 import org.oransc.ric.anrxapp.client.api.HealthApi;
30 import org.oransc.ric.anrxapp.client.api.NcrtApi;
31 import org.oransc.ric.anrxapp.client.invoker.ApiClient;
32 import org.oransc.ric.anrxapp.client.model.NeighborCellRelation;
33 import org.oransc.ric.anrxapp.client.model.NeighborCellRelationDelTable;
34 import org.oransc.ric.anrxapp.client.model.NeighborCellRelationModTable;
35 import org.oransc.ric.anrxapp.client.model.NeighborCellRelationTable;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38 import org.springframework.context.annotation.Bean;
39 import org.springframework.context.annotation.Configuration;
40 import org.springframework.context.annotation.Profile;
41 import org.springframework.http.HttpStatus;
44 * Creates a mock implementation of the ANR xApp client APIs.
48 public class AnrXappMockConfiguration {
50 private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
52 public AnrXappMockConfiguration() {
53 logger.info("Configuring mock ANR xApp client");
56 private ApiClient apiClient() {
57 ApiClient mockClient = mock(ApiClient.class);
58 when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK);
63 public HealthApi anrHealthMockApi() {
64 ApiClient mockClient = mock(ApiClient.class);
65 when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK);
66 HealthApi mockApi = mock(HealthApi.class);
67 when(mockApi.getApiClient()).thenReturn(mockClient);
70 }).when(mockApi).getHealthAlive();
73 }).when(mockApi).getHealthReady();
78 public NcrtApi ncrtPapi() {
79 ApiClient apiClient = apiClient();
80 NcrtApi mockApi = mock(NcrtApi.class);
81 when(mockApi.getApiClient()).thenReturn(apiClient);
83 NeighborCellRelation a = new NeighborCellRelation().cellIdentifierNrcgi("A12345").neighborCellNrpci("A123456")
84 .neighborCellNrcgi("A12347").flagNoHo(true).flagNoXn(true).flagNoRemove(true);
85 NeighborCellRelation e = new NeighborCellRelation().cellIdentifierNrcgi("E12345").neighborCellNrpci("E123456")
86 .neighborCellNrcgi("E12347").flagNoHo(true).flagNoXn(true).flagNoRemove(true);
87 NeighborCellRelationTable ncrt = new NeighborCellRelationTable().addNcrtRelationsItem(a)
88 .addNcrtRelationsItem(e);
90 when(mockApi.getNcrtInfo(any(String.class), any(String.class), any(Integer.class))).thenReturn(ncrt);
91 when(mockApi.getCellNcrtInfo(any(String.class), any(String.class), any(Integer.class), any(String.class),
92 any(String.class))).thenReturn(ncrt);
96 }).when(mockApi).deleteNcrt(any(String.class), any(NeighborCellRelationDelTable.class));
100 }).when(mockApi).modifyNcrt(any(String.class), any(NeighborCellRelationModTable.class));