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.e2mgr.client.api.HealthCheckApi;
30 import org.oransc.ric.e2mgr.client.api.NodebApi;
31 import org.oransc.ric.e2mgr.client.invoker.ApiClient;
32 import org.oransc.ric.e2mgr.client.model.SetupRequest;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
35 import org.springframework.context.annotation.Bean;
36 import org.springframework.context.annotation.Configuration;
37 import org.springframework.context.annotation.Profile;
38 import org.springframework.http.HttpStatus;
41 * Creates a mock implementation of the E2 manager client API. This version
42 * answers only status codes, no data, so the mock implementations are trivial.
46 public class E2ManagerMockConfiguration {
48 private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
50 public E2ManagerMockConfiguration() {
51 logger.info("Configuring mock E2 Manager");
54 private ApiClient apiClient() {
55 ApiClient mockClient = mock(ApiClient.class);
56 when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK);
61 public HealthCheckApi e2HealthCheckApi() {
62 ApiClient apiClient = apiClient();
63 HealthCheckApi mockApi = mock(HealthCheckApi.class);
64 when(mockApi.getApiClient()).thenReturn(apiClient);
68 }).when(mockApi).healthGet();
74 public NodebApi e2NodebApi() {
75 ApiClient apiClient = apiClient();
76 NodebApi mockApi = mock(NodebApi.class);
77 when(mockApi.getApiClient()).thenReturn(apiClient);
81 }).when(mockApi).endcSetup(any(SetupRequest.class));
85 }).when(mockApi).x2Setup(any(SetupRequest.class));