org.onap migration
[vid.git] / vid-app-common / src / test / java / org / onap / vid / controllers / LocalWebConfig.java
1 package org.onap.vid.controllers;
2
3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import org.apache.commons.io.IOUtils;
5 import org.json.JSONObject;
6 import org.json.JSONTokener;
7 import org.onap.vid.aai.AaiClient;
8 import org.onap.vid.aai.AaiClientInterface;
9 import org.onap.vid.asdc.AsdcClient;
10 import org.onap.vid.asdc.local.LocalAsdcClient;
11 import org.onap.vid.asdc.parser.ToscaParserImpl2;
12 import org.onap.vid.controllers.VidController;
13 import org.onap.vid.services.AaiService;
14 import org.onap.vid.services.AaiServiceImpl;
15 import org.onap.vid.services.VidService;
16 import org.onap.vid.services.VidServiceImpl;
17 import org.springframework.context.annotation.Bean;
18 import org.springframework.context.annotation.Configuration;
19
20 import java.io.IOException;
21 import java.io.InputStream;
22
23 @Configuration
24 public class LocalWebConfig {
25
26     /**
27      * Gets the object mapper.
28      *
29      * @return the object mapper
30      */
31     @Bean
32     public ObjectMapper getObjectMapper() {
33         return new ObjectMapper();
34     }
35
36
37     @Bean
38     public VidService vidService(AsdcClient asdcClient) {
39         return new VidServiceImpl(asdcClient);
40     }
41
42     @Bean
43     public AaiService getAaiService() {
44         return new AaiServiceImpl();
45     }
46
47     @Bean
48     public AaiClientInterface getAaiClientInterface() {
49         return new AaiClient();
50     }
51
52     @Bean
53     public AsdcClient asdcClient() throws IOException {
54
55
56         final InputStream asdcServicesFile = VidController.class.getClassLoader().getResourceAsStream("sdcservices.json");
57
58         final JSONTokener jsonTokener = new JSONTokener(IOUtils.toString(asdcServicesFile));
59         final JSONObject sdcServicesCatalog = new JSONObject(jsonTokener);
60
61         return new LocalAsdcClient.Builder().catalog(sdcServicesCatalog).build();
62
63     }
64
65     @Bean
66     public ToscaParserImpl2 getToscaParser() {
67         return new ToscaParserImpl2();
68     }
69
70 }