Require RIC instance key in controller methods
[portal/ric-dashboard.git] / webapp-backend / src / test / java / org / oransc / ric / portal / dashboard / config / AppManagerMockConfiguration.java
index f08df05..6b0517e 100644 (file)
@@ -52,8 +52,8 @@ import org.springframework.http.HttpStatus;
  * Creates an implementation of the xApp manager client that answers requests
  * with mock data.
  */
-@Profile("test")
 @Configuration
+@Profile("test")
 public class AppManagerMockConfiguration {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -69,7 +69,7 @@ public class AppManagerMockConfiguration {
 
        public AppManagerMockConfiguration() {
                logger.info("Configuring mock xApp Manager");
-               final String[] appNames = { "AdmissionControl", "Automatic Neighbor Relation", "UE Event Collector" };
+               final String[] appNames = { "AdmissionControl", "UE Event Collector" };
                final String configJson = " { \"config\" : \"example\" }";
                final String descriptorJson = " { \"descriptor\" : \"example\" }";
                allXappConfigs = new AllXappConfig();
@@ -88,9 +88,7 @@ public class AppManagerMockConfiguration {
                subRes = new SubscriptionResponse().eventType(SubscriptionResponse.EventTypeEnum.ALL).id("subid").version(1);
        }
 
-       @Bean
-       // Use the same name as regular configuration
-       public HealthApi xappMgrHealthApi() {
+       private HealthApi healthApi() {
                ApiClient mockClient = mock(ApiClient.class);
                when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK);
                HealthApi mockApi = mock(HealthApi.class);
@@ -100,9 +98,7 @@ public class AppManagerMockConfiguration {
                return mockApi;
        }
 
-       @Bean
-       // Use the same name as regular configuration
-       public XappApi xappMgrXappApi() {
+       private XappApi xappApi() {
                ApiClient mockClient = mock(ApiClient.class);
                when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK);
                XappApi mockApi = mock(XappApi.class);
@@ -187,4 +183,15 @@ public class AppManagerMockConfiguration {
                return mockApi;
        }
 
+       @Bean
+       // Must use the same name as the non-mock configuration
+       public AppManagerApiBuilder appManagerApiBuilder() {
+               final AppManagerApiBuilder mockBuilder = mock(AppManagerApiBuilder.class);
+               final HealthApi mockHealthApi = healthApi();
+               when(mockBuilder.getHealthApi(any(String.class))).thenReturn(mockHealthApi);
+               final XappApi mockXappApi = xappApi();
+               when(mockBuilder.getXappApi(any(String.class))).thenReturn(mockXappApi);
+               return mockBuilder;
+       }
+
 }