fix - when retrieve topology we are using threadPool and the MDC values are not updated
[vid.git] / vid-app-common / src / test / java / org / onap / vid / controller / LocalWebConfig.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2018 - 2019 Nokia. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.vid.controller;
23
24 import com.fasterxml.jackson.databind.ObjectMapper;
25 import java.io.File;
26 import java.util.concurrent.ExecutorService;
27 import javax.servlet.ServletContext;
28 import org.onap.vid.aai.AaiClient;
29 import org.onap.vid.aai.AaiClientInterface;
30 import org.onap.vid.aai.AaiResponseTranslator;
31 import org.onap.vid.aai.model.PortDetailsTranslator;
32 import org.onap.vid.aai.util.AAIRestInterface;
33 import org.onap.vid.aai.util.CacheProvider;
34 import org.onap.vid.aai.util.HttpsAuthClient;
35 import org.onap.vid.aai.util.NonCachingCacheProvider;
36 import org.onap.vid.aai.util.SSLContextProvider;
37 import org.onap.vid.aai.util.ServletRequestHelper;
38 import org.onap.vid.aai.util.SystemPropertyHelper;
39 import org.onap.vid.asdc.AsdcClient;
40 import org.onap.vid.asdc.parser.ToscaParserImpl2;
41 import org.onap.vid.asdc.parser.VidNotionsBuilder;
42 import org.onap.vid.services.AAIServiceTree;
43 import org.onap.vid.services.AaiService;
44 import org.onap.vid.services.AaiServiceImpl;
45 import org.onap.vid.services.VidService;
46 import org.onap.vid.services.VidServiceImpl;
47 import org.onap.vid.utils.Logging;
48 import org.springframework.beans.factory.annotation.Qualifier;
49 import org.springframework.context.annotation.Bean;
50 import org.springframework.context.annotation.Configuration;
51 import org.togglz.core.manager.FeatureManager;
52
53 @Configuration
54 public class LocalWebConfig {
55
56     /**
57      * Gets the object mapper.
58      *
59      * @return the object mapper
60      */
61     @Bean
62     public ObjectMapper getObjectMapper() {
63         return new ObjectMapper();
64     }
65
66
67     @Bean
68     public VidService vidService(AsdcClient asdcClient, ToscaParserImpl2 toscaParserImpl2,FeatureManager featureManager) {
69         return new VidServiceImpl(asdcClient,toscaParserImpl2, featureManager);
70     }
71
72     @Bean
73     public AaiService getAaiService(AaiClientInterface aaiClient, AaiResponseTranslator aaiResponseTranslator,
74         AAIServiceTree aaiServiceTree, Logging logging, ExecutorService executorService) {
75         return new AaiServiceImpl(aaiClient, aaiResponseTranslator, aaiServiceTree, executorService, logging);
76     }
77
78     @Bean
79     public SSLContextProvider sslContextProvider() {
80         return new SSLContextProvider();
81     }
82
83     @Bean
84     public SystemPropertyHelper systemPropertyHelper() {
85         return new SystemPropertyHelper();
86     }
87
88     @Bean
89     public ServletRequestHelper servletRequestHelper() {
90         return new ServletRequestHelper();
91     }
92
93     @Bean
94     public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager) {
95         final String certFilePath = new File(servletContext.getRealPath("/WEB-INF/cert/")).getAbsolutePath();
96         return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider, featureManager);
97     }
98
99     @Bean
100     public CacheProvider cacheProvider() {
101         return new NonCachingCacheProvider();
102     }
103
104     @Bean(name = "aaiRestInterface")
105     public AAIRestInterface aaiRestInterface(HttpsAuthClient httpsAuthClientFactory,
106         ServletRequestHelper servletRequestHelper,
107         SystemPropertyHelper systemPropertyHelper,
108         Logging loggingService) {
109         return new AAIRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper, loggingService);
110     }
111
112     @Bean
113     public AaiClientInterface getAaiClientInterface(@Qualifier("aaiRestInterface") AAIRestInterface aaiRestInterface, PortDetailsTranslator portDetailsTranslator, CacheProvider cacheProvider) {
114         return new AaiClient(aaiRestInterface, portDetailsTranslator, cacheProvider);
115     }
116
117     @Bean
118     public VidNotionsBuilder vidNotionsBuilder(FeatureManager featureManager) {
119         return new VidNotionsBuilder(featureManager);
120     }
121
122     @Bean
123     public ToscaParserImpl2 getToscaParser(VidNotionsBuilder vidNotionsBuilder) {
124         return new ToscaParserImpl2(vidNotionsBuilder);
125     }
126
127     @Bean
128     public AaiResponseTranslator aaiResponseTranslator() {
129         return new AaiResponseTranslator();
130     }
131
132     @Bean
133     public PortDetailsTranslator portDetailsTranslator(){
134         return new PortDetailsTranslator();
135     }
136
137 }