1 package com.oransc.rappmanager.acm.service;
3 import com.fasterxml.jackson.databind.DeserializationFeature;
4 import com.fasterxml.jackson.databind.ObjectMapper;
5 import com.oransc.rappmanager.acm.ApiClient;
6 import com.oransc.rappmanager.acm.configuration.ACMConfiguration;
7 import com.oransc.rappmanager.acm.rest.AutomationCompositionDefinitionApiClient;
8 import com.oransc.rappmanager.acm.rest.AutomationCompositionInstanceApiClient;
9 import com.oransc.rappmanager.acm.rest.ParticipantMonitoringApiClient;
10 import lombok.RequiredArgsConstructor;
11 import org.springframework.beans.factory.annotation.Qualifier;
12 import org.springframework.boot.test.context.TestConfiguration;
13 import org.springframework.boot.web.client.RestTemplateBuilder;
14 import org.springframework.cache.CacheManager;
15 import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
16 import org.springframework.context.annotation.Bean;
17 import org.springframework.web.client.RestTemplate;
20 @RequiredArgsConstructor
21 public class BeanTestConfiguration {
23 private final ACMConfiguration acmConfiguration;
26 public ObjectMapper objectMapper() {
27 ObjectMapper objectMapper = new ObjectMapper();
28 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
33 public RestTemplateBuilder restTemplateBuilder() {
34 return new RestTemplateBuilder();
38 public CacheManager cacheManager() {
39 return new ConcurrentMapCacheManager(); // or any other CacheManager implementation you want to use in the test
43 public RestTemplate restTemplate(RestTemplateBuilder builder) {
44 return builder.build();
48 public ApiClient acmApiClient(RestTemplate restTemplate) {
49 ApiClient apiClient = new ApiClient(restTemplate);
50 apiClient.setUsername(acmConfiguration.getUsername());
51 apiClient.setPassword(acmConfiguration.getPassword());
52 return apiClient.setBasePath(acmConfiguration.getBaseUrl());
56 public ParticipantMonitoringApiClient participantMonitoringApiClient(
57 @Qualifier("acmApiClient") ApiClient apiClient) {
58 return new ParticipantMonitoringApiClient(apiClient);
62 public AutomationCompositionDefinitionApiClient automationCompositionDefinitionApiClient(
63 @Qualifier("acmApiClient") ApiClient apiClient) {
64 return new AutomationCompositionDefinitionApiClient(apiClient);
68 public AutomationCompositionInstanceApiClient automationCompositionInstanceApiClient(
69 @Qualifier("acmApiClient") ApiClient apiClient) {
70 return new AutomationCompositionInstanceApiClient(apiClient);