add xapp deploy dialog, call backend api
[portal/ric-dashboard.git] / webapp-backend / src / main / java / org / oranosc / ric / portal / dash / config / E2ManagerMockConfiguration.java
1 /*-
2  * ========================LICENSE_START=================================
3  * ORAN-OSC
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.oranosc.ric.portal.dash.config;
21
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;
26
27 import org.oranosc.ric.e2mgr.client.api.DefaultApi;
28 import org.oranosc.ric.e2mgr.client.invoker.ApiClient;
29 import org.oranosc.ric.e2mgr.client.model.RanSetupRequest;
30 import org.springframework.context.annotation.Bean;
31 import org.springframework.context.annotation.Configuration;
32 import org.springframework.context.annotation.Primary;
33 import org.springframework.context.annotation.Profile;
34 import org.springframework.http.HttpStatus;
35
36 /**
37  * Creates an implementation of the E2 manager client that answers requests with
38  * mock data.
39  */
40 @Profile("mock")
41 @Configuration
42 public class E2ManagerMockConfiguration {
43
44         @Bean
45         @Primary
46         public DefaultApi e2ManagerMockClient() {
47                 ApiClient mockClient = mock(ApiClient.class);
48                 when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK);
49
50                 DefaultApi mockApi = mock(DefaultApi.class);
51                 when(mockApi.getApiClient()).thenReturn(mockClient);
52
53                 doAnswer(i -> {
54                         return null;
55                 }).when(mockApi).getHealth();
56
57                 doAnswer(i -> {
58                         return null;
59                 }).when(mockApi).setupRan(any(RanSetupRequest.class));
60
61                 return mockApi;
62         }
63
64 }