1 package com.oransc.rappmanager.sme.service;
3 import com.fasterxml.jackson.databind.DeserializationFeature;
4 import com.fasterxml.jackson.databind.ObjectMapper;
5 import com.oransc.rappmanager.sme.configuration.SmeConfiguration;
6 import com.oransc.rappmanager.sme.provider.rest.DefaultApiClient;
7 import lombok.RequiredArgsConstructor;
8 import org.springframework.beans.factory.annotation.Qualifier;
9 import org.springframework.boot.test.context.TestConfiguration;
10 import org.springframework.boot.web.client.RestTemplateBuilder;
11 import org.springframework.cache.CacheManager;
12 import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
13 import org.springframework.context.annotation.Bean;
14 import org.springframework.web.client.RestTemplate;
17 @RequiredArgsConstructor
18 public class BeanTestConfiguration {
20 private final SmeConfiguration smeConfiguration;
23 public ObjectMapper objectMapper() {
24 ObjectMapper objectMapper = new ObjectMapper();
25 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
30 public RestTemplateBuilder restTemplateBuilder() {
31 return new RestTemplateBuilder();
35 public CacheManager cacheManager() {
36 return new ConcurrentMapCacheManager(); // or any other CacheManager implementation you want to use in the test
40 public RestTemplate restTemplate(RestTemplateBuilder builder) {
41 return builder.build();
44 @Bean("smeProviderApiClient")
45 public com.oransc.rappmanager.sme.provider.ApiClient smeProviderApiClient(RestTemplate restTemplate) {
46 return new com.oransc.rappmanager.sme.provider.ApiClient(restTemplate);
49 @Bean("smePublishServiceApiClient")
50 public com.oransc.rappmanager.sme.publishservice.ApiClient smePublishServiceApiClient(RestTemplate restTemplate) {
51 return new com.oransc.rappmanager.sme.publishservice.ApiClient(restTemplate);
54 @Bean("smeInvokerApiClient")
55 public com.oransc.rappmanager.sme.invoker.ApiClient smeInvokerApiClient(RestTemplate restTemplate) {
56 return new com.oransc.rappmanager.sme.invoker.ApiClient(restTemplate);
60 public DefaultApiClient defaultProviderApiClient(
61 @Qualifier("smeProviderApiClient") com.oransc.rappmanager.sme.provider.ApiClient apiClient) {
62 apiClient.setBasePath(smeConfiguration.getBaseUrl() + smeConfiguration.getProviderBasePath());
63 return new DefaultApiClient(apiClient);
67 public com.oransc.rappmanager.sme.publishservice.rest.DefaultApiClient defaultPublishServiceApiClient(
68 @Qualifier("smePublishServiceApiClient") com.oransc.rappmanager.sme.publishservice.ApiClient apiClient) {
69 apiClient.setBasePath(smeConfiguration.getBaseUrl() + smeConfiguration.getPublishApiBasePath());
70 return new com.oransc.rappmanager.sme.publishservice.rest.DefaultApiClient(apiClient);
74 public com.oransc.rappmanager.sme.invoker.rest.DefaultApiClient defaultInvokerApiClient(
75 @Qualifier("smeInvokerApiClient") com.oransc.rappmanager.sme.invoker.ApiClient apiClient) {
76 apiClient.setBasePath(smeConfiguration.getBaseUrl() + smeConfiguration.getInvokerBasePath());
77 return new com.oransc.rappmanager.sme.invoker.rest.DefaultApiClient(apiClient);