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
9 * http://www.apache.org/licenses/LICENSE-2.0
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========================================================================
19 package com.oransc.rappmanager.dme.service;
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;
35 @RequiredArgsConstructor
36 public class BeanTestConfiguration {
38 private final DmeConfiguration dmeConfiguration;
41 public ObjectMapper objectMapper() {
42 ObjectMapper objectMapper = new ObjectMapper();
43 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
48 public RestTemplateBuilder restTemplateBuilder() {
49 return new RestTemplateBuilder();
53 public CacheManager cacheManager() {
54 return new ConcurrentMapCacheManager(); // or any other CacheManager implementation you want to use in the test
58 public RestTemplate restTemplate(RestTemplateBuilder builder) {
59 return builder.build();
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());
69 public DataProducerRegistrationApiClient dataProducerRegistrationApiClient(
70 com.oransc.rappmanager.dme.ApiClient apiClient) {
71 return new DataProducerRegistrationApiClient(apiClient);
75 public DataConsumerApiClient dataConsumerApiClient(com.oransc.rappmanager.dme.ApiClient apiClient) {
76 return new DataConsumerApiClient(apiClient);