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