7e50c8959dea113637f1b7ca1517506f3519bc3b
[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 org.onap.vid.aai.AaiClient;
26 import org.onap.vid.aai.AaiClientInterface;
27 import org.onap.vid.aai.AaiOverTLSClientInterface;
28 import org.onap.vid.aai.AaiResponseTranslator;
29 import org.onap.vid.aai.model.PortDetailsTranslator;
30 import org.onap.vid.aai.util.*;
31 import org.onap.vid.asdc.AsdcClient;
32 import org.onap.vid.asdc.parser.ToscaParserImpl2;
33 import org.onap.vid.asdc.parser.VidNotionsBuilder;
34 import org.onap.vid.services.AAIServiceTree;
35 import org.onap.vid.services.AAITreeNodeBuilder;
36 import org.onap.vid.services.AaiService;
37 import org.onap.vid.services.AaiServiceImpl;
38 import org.onap.vid.services.VidService;
39 import org.onap.vid.services.VidServiceImpl;
40 import org.springframework.beans.factory.annotation.Qualifier;
41 import org.springframework.context.annotation.Bean;
42 import org.springframework.context.annotation.Configuration;
43 import org.togglz.core.manager.FeatureManager;
44
45 import javax.servlet.ServletContext;
46 import java.io.File;
47
48 @Configuration
49 public class LocalWebConfig {
50
51     /**
52      * Gets the object mapper.
53      *
54      * @return the object mapper
55      */
56     @Bean
57     public ObjectMapper getObjectMapper() {
58         return new ObjectMapper();
59     }
60
61
62     @Bean
63     public VidService vidService(AsdcClient asdcClient, ToscaParserImpl2 toscaParserImpl2,FeatureManager featureManager) {
64         return new VidServiceImpl(asdcClient,toscaParserImpl2, featureManager);
65     }
66
67     @Bean
68     public AaiService getAaiService(AaiClientInterface aaiClient, AaiOverTLSClientInterface aaiOverTLSClient,
69         AaiResponseTranslator aaiResponseTranslator, AAITreeNodeBuilder aaiTreeNode, AAIServiceTree aaiServiceTree) {
70         return new AaiServiceImpl(aaiClient, aaiOverTLSClient, aaiResponseTranslator, aaiTreeNode, aaiServiceTree);
71     }
72
73     @Bean
74     public SSLContextProvider sslContextProvider() {
75         return new SSLContextProvider();
76     }
77
78     @Bean
79     public SystemPropertyHelper systemPropertyHelper() {
80         return new SystemPropertyHelper();
81     }
82
83     @Bean
84     public ServletRequestHelper servletRequestHelper() {
85         return new ServletRequestHelper();
86     }
87
88     @Bean
89     public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager) {
90         final String certFilePath = new File(servletContext.getRealPath("/WEB-INF/cert/")).getAbsolutePath();
91         return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider, featureManager);
92     }
93
94     @Bean
95     public CacheProvider cacheProvider() {
96         return new NonCachingCacheProvider();
97     }
98
99     @Bean(name = "aaiRestInterface")
100     public AAIRestInterface aaiRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
101         return new AAIRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
102     }
103
104     @Bean
105     public AaiClientInterface getAaiClientInterface(@Qualifier("aaiRestInterface") AAIRestInterface aaiRestInterface, PortDetailsTranslator portDetailsTranslator, CacheProvider cacheProvider) {
106         return new AaiClient(aaiRestInterface, portDetailsTranslator, cacheProvider);
107     }
108
109     @Bean
110     public VidNotionsBuilder vidNotionsBuilder(FeatureManager featureManager) {
111         return new VidNotionsBuilder(featureManager);
112     }
113
114     @Bean
115     public ToscaParserImpl2 getToscaParser(VidNotionsBuilder vidNotionsBuilder) {
116         return new ToscaParserImpl2(vidNotionsBuilder);
117     }
118
119     @Bean
120     public AaiResponseTranslator aaiResponseTranslator() {
121         return new AaiResponseTranslator();
122     }
123
124     @Bean
125     public PortDetailsTranslator portDetailsTranslator(){
126         return new PortDetailsTranslator();
127     }
128
129 }