Roll versions after J-Relase master -> 0.2.0
[nonrtric/plt/rappmanager.git] / rapp-manager-dme / src / test / java / com / oransc / rappmanager / dme / service / BeanTestConfiguration.java
1 /*-
2  * ============LICENSE_START======================================================================
3  * Copyright (C) 2023 Nordix Foundation. All rights reserved.
4  * ===============================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END========================================================================
17  */
18
19 package com.oransc.rappmanager.dme.service;
20
21 import com.fasterxml.jackson.databind.DeserializationFeature;
22 import com.fasterxml.jackson.databind.ObjectMapper;
23 import com.oransc.rappmanager.dme.configuration.DmeConfiguration;
24 import com.oransc.rappmanager.dme.rest.DataConsumerApiClient;
25 import com.oransc.rappmanager.dme.rest.DataProducerRegistrationApiClient;
26 import lombok.RequiredArgsConstructor;
27 import org.springframework.boot.test.context.TestConfiguration;
28 import org.springframework.boot.web.client.RestTemplateBuilder;
29 import org.springframework.cache.CacheManager;
30 import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
31 import org.springframework.context.annotation.Bean;
32 import org.springframework.web.client.RestTemplate;
33
34 @TestConfiguration
35 @RequiredArgsConstructor
36 public class BeanTestConfiguration {
37
38     private final DmeConfiguration dmeConfiguration;
39
40     @Bean
41     public ObjectMapper objectMapper() {
42         ObjectMapper objectMapper = new ObjectMapper();
43         objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
44         return objectMapper;
45     }
46
47     @Bean
48     public RestTemplateBuilder restTemplateBuilder() {
49         return new RestTemplateBuilder();
50     }
51
52     @Bean
53     public CacheManager cacheManager() {
54         return new ConcurrentMapCacheManager(); // or any other CacheManager implementation you want to use in the test
55     }
56
57     @Bean
58     public RestTemplate restTemplate(RestTemplateBuilder builder) {
59         return builder.build();
60     }
61
62     @Bean
63     public com.oransc.rappmanager.dme.ApiClient dmeApiClient(RestTemplate restTemplate) {
64         com.oransc.rappmanager.dme.ApiClient apiClient = new com.oransc.rappmanager.dme.ApiClient(restTemplate);
65         return apiClient.setBasePath(dmeConfiguration.getBaseUrl());
66     }
67
68     @Bean
69     public DataProducerRegistrationApiClient dataProducerRegistrationApiClient(
70             com.oransc.rappmanager.dme.ApiClient apiClient) {
71         return new DataProducerRegistrationApiClient(apiClient);
72     }
73
74     @Bean
75     public DataConsumerApiClient dataConsumerApiClient(com.oransc.rappmanager.dme.ApiClient apiClient) {
76         return new DataConsumerApiClient(apiClient);
77     }
78 }