Update flow and architecture images
[nonrtric/plt/rappmanager.git] / rapp-manager-sme / src / test / java / com / oransc / rappmanager / sme / service / BeanTestConfiguration.java
1 package com.oransc.rappmanager.sme.service;
2
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;
15
16 @TestConfiguration
17 @RequiredArgsConstructor
18 public class BeanTestConfiguration {
19
20     private final SmeConfiguration smeConfiguration;
21
22     @Bean
23     public ObjectMapper objectMapper() {
24         ObjectMapper objectMapper = new ObjectMapper();
25         objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
26         return objectMapper;
27     }
28
29     @Bean
30     public RestTemplateBuilder restTemplateBuilder() {
31         return new RestTemplateBuilder();
32     }
33
34     @Bean
35     public CacheManager cacheManager() {
36         return new ConcurrentMapCacheManager(); // or any other CacheManager implementation you want to use in the test
37     }
38
39     @Bean
40     public RestTemplate restTemplate(RestTemplateBuilder builder) {
41         return builder.build();
42     }
43
44     @Bean("smeProviderApiClient")
45     public com.oransc.rappmanager.sme.provider.ApiClient smeProviderApiClient(RestTemplate restTemplate) {
46         return new com.oransc.rappmanager.sme.provider.ApiClient(restTemplate);
47     }
48
49     @Bean("smePublishServiceApiClient")
50     public com.oransc.rappmanager.sme.publishservice.ApiClient smePublishServiceApiClient(RestTemplate restTemplate) {
51         return new com.oransc.rappmanager.sme.publishservice.ApiClient(restTemplate);
52     }
53
54     @Bean("smeInvokerApiClient")
55     public com.oransc.rappmanager.sme.invoker.ApiClient smeInvokerApiClient(RestTemplate restTemplate) {
56         return new com.oransc.rappmanager.sme.invoker.ApiClient(restTemplate);
57     }
58
59     @Bean
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);
64     }
65
66     @Bean
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);
71     }
72
73     @Bean
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);
78     }
79 }