integrate helm-chart-generator to runtime api
[dcaegen2/platform.git] / mod / runtimeapi / runtime-core / src / test / java / org / onap / dcae / runtime / core / Helper.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=========================================================
17  */
18 package org.onap.dcae.runtime.core;
19
20 import java.io.IOException;
21 import java.nio.file.Files;
22 import java.nio.file.Paths;
23 import java.util.HashMap;
24 import java.util.Map;
25
26 public class Helper {
27     public static String loadFileContent(String filePath) {
28         String fileContent = "";
29         try {
30             fileContent = new String(Files.readAllBytes(Paths.get(filePath)),"UTF-8");
31         } catch (IOException e) {
32             e.printStackTrace();
33         }
34         return fileContent;
35     }
36
37     public static Map<String, String> loadTestBlueprints() {
38         Map<String,String> expectedBlueprints = new HashMap<String, String>();
39         expectedBlueprints.put("hello-world-2_blueprint",
40                 loadFileContent("src/test/data/blueprints/helloworld_test_2.yaml"));
41         expectedBlueprints.put("hello-world-1_blueprint",
42                 loadFileContent("src/test/data/blueprints/helloworld_test_1.yaml"));
43         return expectedBlueprints;
44     }
45
46     public static Edge getTestEdge(){
47         EdgeLocation src = new EdgeLocation("comp1234","DCAE-HELLO-WORLD-PUB-MR");
48         EdgeLocation tgt = new EdgeLocation("comp5678", "DCAE-HELLO-WORLD-SUB-MR");
49         EdgeMetadata metadata = new EdgeMetadata("sample_topic_1", "json", "MR");
50         Edge edge = new Edge(src, tgt, metadata);
51         return edge;
52     }
53
54     public static FlowGraph<Node, Edge> prepareFlowGraph() {
55         FlowGraph<Node, Edge> flowGraph = new FlowGraph("random_id","anyName",true,"someDescription");
56
57         Node node_1 = new Node("comp1234", "hello-world-1",
58                 Helper.loadFileContent("src/test/data/compspecs/componentSpec_hello_world.json"));
59         Node node_2 = new Node("comp5678", "hello-world-2",
60                 Helper.loadFileContent("src/test/data/compspecs/componentSpec_hello_world.json"));
61         flowGraph.addNode(node_1);
62         flowGraph.addNode(node_2);
63         flowGraph.addEdge(node_1,node_2,Helper.getTestEdge());
64
65         return flowGraph;
66     }
67 }