* ========================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.
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
-import org.springframework.util.Assert;
import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.DefaultUriBuilderFactory;
/**
* Creates instances of the ANR xApp client APIs.
*/
@Configuration
-@Profile("!mock")
+@Profile("!test")
public class AnrXappConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
// Populated by the autowired constructor
- private final String anrXappBasepath;
+ private final String anrXappUrl;
@Autowired
- public AnrXappConfiguration(@Value("${anrxapp.basepath}") final String anrXappBasepath) {
- Assert.notNull(anrXappBasepath, "base path must not be null");
- logger.info("Configuring ANR client at base path {}", anrXappBasepath);
- this.anrXappBasepath = anrXappBasepath;
+ public AnrXappConfiguration(@Value("${anrxapp.url.prefix}") final String urlPrefix,
+ @Value("${anrxapp.url.suffix}") final String urlSuffix) {
+ logger.debug("ctor prefix '{}' suffix '{}'", urlPrefix, urlSuffix);
+ anrXappUrl = new DefaultUriBuilderFactory(urlPrefix.trim()).builder().path(urlSuffix.trim()).build().normalize()
+ .toString();
+ logger.info("Configuring ANR client at URL {}", anrXappUrl);
}
private ApiClient apiClient() {
ApiClient apiClient = new ApiClient(new RestTemplate());
- apiClient.setBasePath(anrXappBasepath);
+ apiClient.setBasePath(anrXappUrl);
return apiClient;
}
@Bean
+ // The bean (method) name must be globally unique
public HealthApi anrHealthApi() {
return new HealthApi(apiClient());
}
@Bean
+ // The bean (method) name must be globally unique
public NcrtApi anrNcrtApi() {
return new NcrtApi(apiClient());
}