Merge "Restore test assertions. Update default plugin imports. Fix sonar issues in...
[dcaegen2/platform.git] / mod / bpgenerator / src / main / java / org / onap / blueprintgenerator / models / blueprint / Imports.java
1 /**============LICENSE_START======================================================= 
2  org.onap.dcae 
3  ================================================================================ 
4  Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. 
5  ================================================================================ 
6  Licensed under the Apache License, Version 2.0 (the "License"); 
7  you may not use this file except in compliance with the License. 
8  You may obtain a copy of the License at 
9  
10       http://www.apache.org/licenses/LICENSE-2.0 
11  
12  Unless required by applicable law or agreed to in writing, software 
13  distributed under the License is distributed on an "AS IS" BASIS, 
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
15  See the License for the specific language governing permissions and 
16  limitations under the License. 
17  ============LICENSE_END========================================================= 
18  
19 */
20
21 package org.onap.blueprintgenerator.models.blueprint;
22
23
24 import com.fasterxml.jackson.annotation.JsonInclude;
25 import com.fasterxml.jackson.annotation.JsonInclude.Include;
26 import com.fasterxml.jackson.databind.ObjectMapper;
27 import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
28 import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
29 import java.io.File;
30 import java.io.IOException;
31 import java.util.ArrayList;
32 import lombok.Getter;
33 import lombok.Setter;
34
35
36
37 @Getter @Setter
38 @JsonInclude(value=Include.NON_NULL)
39 public class Imports {
40         /** The imports. */
41         private ArrayList<String> imports;
42
43         public static ArrayList<String> createOnapImports() {
44                 ArrayList<String> imps = new ArrayList<>();
45                 imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
46                 imps.add("plugin:k8splugin?version=3.4.2");
47                 imps.add("plugin:dcaepolicyplugin?version=2.4.0");
48                 return imps;
49         }
50         public static ArrayList<String> createDmaapImports(){
51                 ArrayList<String> imps = new ArrayList<>();
52                 imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
53                 imps.add("plugin:k8splugin?version=3.4.2");
54                 imps.add("plugin:dmaap?version=1.5.0");
55                 return imps;
56         }
57         public static ArrayList<String> createImportsFromFile(String path) {
58                 Imports imports;
59                 ObjectMapper importMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
60                 File importPath = new File(path);
61                 try {
62                         imports = importMapper.readValue(importPath, Imports.class);
63                 } catch (IOException e) {
64                         throw new RuntimeException(e);
65                 }
66                 return imports.getImports();
67         }
68 }