Add status check between ACM depriming and deletion
[nonrtric/plt/rappmanager.git] / rapp-manager-acm / src / test / java / com / oransc / rappmanager / acm / service / BeanTestConfiguration.java
1 package com.oransc.rappmanager.acm.service;
2
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.configuration.JacksonMessageConverterConfiguration;
8 import com.oransc.rappmanager.acm.rest.AutomationCompositionDefinitionApiClient;
9 import com.oransc.rappmanager.acm.rest.AutomationCompositionInstanceApiClient;
10 import com.oransc.rappmanager.acm.rest.ParticipantMonitoringApiClient;
11 import lombok.RequiredArgsConstructor;
12 import org.springframework.beans.factory.annotation.Qualifier;
13 import org.springframework.boot.test.context.TestConfiguration;
14 import org.springframework.boot.web.client.RestTemplateBuilder;
15 import org.springframework.cache.CacheManager;
16 import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
17 import org.springframework.context.annotation.Bean;
18 import org.springframework.web.client.RestTemplate;
19
20 @TestConfiguration
21 @RequiredArgsConstructor
22 public class BeanTestConfiguration {
23
24     private final ACMConfiguration acmConfiguration;
25
26     @Bean
27     public ObjectMapper objectMapper() {
28         ObjectMapper objectMapper = new ObjectMapper();
29         objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
30         return objectMapper;
31     }
32
33     @Bean
34     public RestTemplateBuilder restTemplateBuilder() {
35         return new RestTemplateBuilder();
36     }
37
38     @Bean
39     public CacheManager cacheManager() {
40         return new ConcurrentMapCacheManager(); // or any other CacheManager implementation you want to use in the test
41     }
42
43     @Bean
44     public RestTemplate restTemplate(RestTemplateBuilder builder, ObjectMapper objectMapper) {
45         RestTemplate restTemplate = builder.build();
46         restTemplate.getMessageConverters().add(new JacksonMessageConverterConfiguration(objectMapper));
47         return restTemplate;
48     }
49
50     @Bean("acmApiClient")
51     public ApiClient acmApiClient(RestTemplate restTemplate) {
52         ApiClient apiClient = new ApiClient(restTemplate);
53         apiClient.setUsername(acmConfiguration.getUsername());
54         apiClient.setPassword(acmConfiguration.getPassword());
55         return apiClient.setBasePath(acmConfiguration.getBaseUrl());
56     }
57
58     @Bean
59     public ParticipantMonitoringApiClient participantMonitoringApiClient(
60             @Qualifier("acmApiClient") ApiClient apiClient) {
61         return new ParticipantMonitoringApiClient(apiClient);
62     }
63
64     @Bean
65     public AutomationCompositionDefinitionApiClient automationCompositionDefinitionApiClient(
66             @Qualifier("acmApiClient") ApiClient apiClient) {
67         return new AutomationCompositionDefinitionApiClient(apiClient);
68     }
69
70     @Bean
71     public AutomationCompositionInstanceApiClient automationCompositionInstanceApiClient(
72             @Qualifier("acmApiClient") ApiClient apiClient) {
73         return new AutomationCompositionInstanceApiClient(apiClient);
74     }
75
76
77 }