Implant vid-app-common org.onap.vid.job (main and test)
[vid.git] / vid-app-common / src / test / java / org / onap / vid / controller / LocalWebConfig.java
index 9b6a3e7..701f1c6 100644 (file)
@@ -1,24 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 - 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
 package org.onap.vid.controller;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.IOUtils;
-import org.json.JSONObject;
-import org.json.JSONTokener;
 import org.onap.vid.aai.AaiClient;
 import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.AaiOverTLSClientInterface;
+import org.onap.vid.aai.AaiResponseTranslator;
+import org.onap.vid.aai.model.PortDetailsTranslator;
+import org.onap.vid.aai.util.*;
 import org.onap.vid.asdc.AsdcClient;
-import org.onap.vid.asdc.local.LocalAsdcClient;
 import org.onap.vid.asdc.parser.ToscaParserImpl2;
-import org.onap.vid.controller.VidController;
+import org.onap.vid.asdc.parser.VidNotionsBuilder;
+import org.onap.vid.services.AAIServiceTree;
+import org.onap.vid.services.AAITreeNodeBuilder;
 import org.onap.vid.services.AaiService;
 import org.onap.vid.services.AaiServiceImpl;
 import org.onap.vid.services.VidService;
 import org.onap.vid.services.VidServiceImpl;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.togglz.core.manager.FeatureManager;
 
-import java.io.IOException;
-import java.io.InputStream;
+import javax.servlet.ServletContext;
+import java.io.File;
+import java.util.concurrent.ExecutorService;
 
 @Configuration
 public class LocalWebConfig {
@@ -35,36 +61,70 @@ public class LocalWebConfig {
 
 
     @Bean
-    public VidService vidService(AsdcClient asdcClient) {
-        return new VidServiceImpl(asdcClient);
+    public VidService vidService(AsdcClient asdcClient, ToscaParserImpl2 toscaParserImpl2,FeatureManager featureManager) {
+        return new VidServiceImpl(asdcClient,toscaParserImpl2, featureManager);
     }
 
     @Bean
-    public AaiService getAaiService() {
-        return new AaiServiceImpl();
+    public AaiService getAaiService(AaiClientInterface aaiClient, AaiOverTLSClientInterface aaiOverTLSClient,
+        AaiResponseTranslator aaiResponseTranslator, AAITreeNodeBuilder aaiTreeNode, AAIServiceTree aaiServiceTree, ExecutorService executorService) {
+        return new AaiServiceImpl(aaiClient, aaiOverTLSClient, aaiResponseTranslator, aaiTreeNode, aaiServiceTree, executorService);
     }
 
     @Bean
-    public AaiClientInterface getAaiClientInterface() {
-        return new AaiClient();
+    public SSLContextProvider sslContextProvider() {
+        return new SSLContextProvider();
     }
 
     @Bean
-    public AsdcClient asdcClient() throws IOException {
+    public SystemPropertyHelper systemPropertyHelper() {
+        return new SystemPropertyHelper();
+    }
 
+    @Bean
+    public ServletRequestHelper servletRequestHelper() {
+        return new ServletRequestHelper();
+    }
 
-        final InputStream asdcServicesFile = VidController.class.getClassLoader().getResourceAsStream("sdcservices.json");
+    @Bean
+    public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager) {
+        final String certFilePath = new File(servletContext.getRealPath("/WEB-INF/cert/")).getAbsolutePath();
+        return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider, featureManager);
+    }
 
-        final JSONTokener jsonTokener = new JSONTokener(IOUtils.toString(asdcServicesFile));
-        final JSONObject sdcServicesCatalog = new JSONObject(jsonTokener);
+    @Bean
+    public CacheProvider cacheProvider() {
+        return new NonCachingCacheProvider();
+    }
 
-        return new LocalAsdcClient.Builder().catalog(sdcServicesCatalog).build();
+    @Bean(name = "aaiRestInterface")
+    public AAIRestInterface aaiRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
+        return new AAIRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
+    }
 
+    @Bean
+    public AaiClientInterface getAaiClientInterface(@Qualifier("aaiRestInterface") AAIRestInterface aaiRestInterface, PortDetailsTranslator portDetailsTranslator, CacheProvider cacheProvider) {
+        return new AaiClient(aaiRestInterface, portDetailsTranslator, cacheProvider);
+    }
+
+    @Bean
+    public VidNotionsBuilder vidNotionsBuilder(FeatureManager featureManager) {
+        return new VidNotionsBuilder(featureManager);
+    }
+
+    @Bean
+    public ToscaParserImpl2 getToscaParser(VidNotionsBuilder vidNotionsBuilder) {
+        return new ToscaParserImpl2(vidNotionsBuilder);
+    }
+
+    @Bean
+    public AaiResponseTranslator aaiResponseTranslator() {
+        return new AaiResponseTranslator();
     }
 
     @Bean
-    public ToscaParserImpl2 getToscaParser() {
-        return new ToscaParserImpl2();
+    public PortDetailsTranslator portDetailsTranslator(){
+        return new PortDetailsTranslator();
     }
 
 }