* ========================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.
* 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());
@Value("${mock.config.delay:0}")
private int delayMs;
- private final AllDeployableXapps availXapps;
+ private final AllDeployableXapps deployableApps;
private final AllDeployedXapps deployedXapps;
private final AllXappConfig allXappConfigs;
private final SubscriptionResponse subRes;
public AppManagerMockConfiguration() {
logger.info("Configuring mock xApp Manager");
- final String[] appNames = { "AdmissionControl", "Automatic Neighbor Relation", "Dual Connectivity" };
+ final String[] appNames = { "AdmissionControl", "UE Event Collector" };
final String configJson = " { \"config\" : \"example\" }";
final String descriptorJson = " { \"descriptor\" : \"example\" }";
allXappConfigs = new AllXappConfig();
- availXapps = new AllDeployableXapps();
+ deployableApps = new AllDeployableXapps();
deployedXapps = new AllDeployedXapps();
for (String n : appNames) {
ConfigMetadata metadata = new ConfigMetadata().configName("config-" + n).name(n).namespace("namespace");
XAppConfig config = new XAppConfig().config(configJson).descriptor(descriptorJson).metadata(metadata);
allXappConfigs.add(config);
- availXapps.add(n);
+ deployableApps.add(n);
Xapp xapp = new Xapp().name(n).version("version").status(StatusEnum.UNKNOWN);
xapp.addInstancesItem(new XappInstance().name("abcd-1234").ip("127.0.0.1").port(200)
.status(XappInstance.StatusEnum.RUNNING));
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);
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);
}).when(mockApi).deployXapp(any(XAppInfo.class));
doAnswer(inv -> {
if (delayMs > 0) {
- logger.debug("listAllXapps sleeping {}", delayMs);
+ logger.debug("listAllDeployableXapps sleeping {}", delayMs);
Thread.sleep(delayMs);
}
- return availXapps;
- }).when(mockApi).listAllXapps();
+ return deployableApps;
+ }).when(mockApi).listAllDeployableXapps();
doAnswer(inv -> {
if (delayMs > 0) {
logger.debug("getAllXapps sleeping {}", delayMs);
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;
+ }
+
}