Require RIC instance key in controller methods
[portal/ric-dashboard.git] / webapp-backend / src / test / java / org / oransc / ric / portal / dashboard / config / E2ManagerMockConfiguration.java
index 75ab01a..3f33f40 100644 (file)
@@ -2,7 +2,7 @@
  * ========================LICENSE_START=================================
  * O-RAN-SC
  * %%
- * Copyright (C) 2019 AT&T Intellectual Property and Nokia
+ * Copyright (C) 2019 AT&T Intellectual Property
  * %%
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,8 +49,8 @@ import org.springframework.http.HttpStatus;
 /**
  * Creates a mock implementation of the E2 Manager client API.
  */
-@Profile("test")
 @Configuration
+@Profile("test")
 public class E2ManagerMockConfiguration {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -59,8 +59,8 @@ public class E2ManagerMockConfiguration {
        @Value("${mock.config.delay:0}")
        private int delayMs;
 
-       public static final String RAN_NAME_1 = "Connected RAN";
-       public static final String RAN_NAME_2 = "Unknown RAN";
+       public static final String RAN_NAME_1 = "Connected-RAN";
+       public static final String RAN_NAME_2 = "Unknown-RAN";
 
        private final List<NodebIdentity> nodebIdList;
        private final Map<String, GetNodebResponse> nodebResponseMap;
@@ -91,9 +91,7 @@ public class E2ManagerMockConfiguration {
                return mockClient;
        }
 
-       @Bean
-       // Use the same name as regular configuration
-       public HealthCheckApi e2MgrHealthCheckApi() {
+       private HealthCheckApi healthCheckApi() {
                ApiClient apiClient = apiClient();
                HealthCheckApi mockApi = mock(HealthCheckApi.class);
                when(mockApi.getApiClient()).thenReturn(apiClient);
@@ -101,9 +99,7 @@ public class E2ManagerMockConfiguration {
                return mockApi;
        }
 
-       @Bean
-       // Use the same name as regular configuration
-       public NodebApi e2MgrNodebApi() {
+       private NodebApi nodebApi() {
                ApiClient apiClient = apiClient();
                NodebApi mockApi = mock(NodebApi.class);
                when(mockApi.getApiClient()).thenReturn(apiClient);
@@ -164,4 +160,15 @@ public class E2ManagerMockConfiguration {
                return mockApi;
        }
 
+       @Bean
+       // Must use the same name as the non-mock configuration
+       public E2ManagerApiBuilder e2ManagerApiBuilder() {
+               final E2ManagerApiBuilder mockBuilder = mock(E2ManagerApiBuilder.class);
+               final HealthCheckApi mockHealthCheckApi = healthCheckApi();
+               when(mockBuilder.getHealthCheckApi(any(String.class))).thenReturn(mockHealthCheckApi);
+               final NodebApi mockNodebApi = nodebApi();
+               when(mockBuilder.getNodebApi(any(String.class))).thenReturn(mockNodebApi);
+               return mockBuilder;
+       }
+
 }