2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019-2020 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
9 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
18 package org.onap.dcae.runtime.core;
21 import java.io.FileWriter;
22 import java.io.IOException;
23 import java.io.Writer;
25 import org.junit.Rule;
26 import org.junit.rules.TemporaryFolder;
27 import org.junit.Test;
28 import static org.junit.Assert.assertEquals;
29 import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnapDublin;
31 public class TestFlowGraphParser {
34 public TemporaryFolder folder = new TemporaryFolder();
37 public void testFlowGraphParser() throws IOException {
39 File importsfile = folder.newFile("imports.yaml");
40 try (Writer w = new FileWriter(importsfile)) {
43 " - 'http://www.getcloudify.org/spec/cloudify/3.4/types.yaml'\n" +
44 " - 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.5/k8splugin_types.yaml'\n" +
45 " - 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml'\n"
48 FlowGraph<Node, Edge> mainFlowGraph = new FlowGraph<>("1234", "nifi-main", true, "mock graph");
49 mainFlowGraph.addNode(new Node("dummy_id", "dummy_name", "dummy_compspec"));
50 BlueprintCreatorOnapDublin bcod = new BlueprintCreatorOnapDublin();
51 bcod.setTopicUrl("u.r.l");
52 bcod.setImportFilePath(importsfile.getAbsolutePath());
53 FlowGraphParser flowGraphParser = new FlowGraphParser(bcod);
54 flowGraphParser.parse(mainFlowGraph);
55 String compspec = Helper.loadFileContent("src/test/data/compspecs/componentSpec_hello_world.json");
56 mainFlowGraph.addNode(new Node("comp5678", "hello-world-2", compspec));
57 mainFlowGraph.addNode(new Node("comp1234", "hello-world-1", compspec));
58 mainFlowGraph.addEdge(
59 flowGraphParser.getNodeFromId("comp1234"),
60 flowGraphParser.getNodeFromId("comp5678"),
62 new EdgeLocation("comp1234", "DCAE-HELLO-WORLD-PUB-MR"),
63 new EdgeLocation("comp5678", "DCAE-HELLO-WORLD-SUB-MR"),
64 new EdgeMetadata("sample_topic_1", "json", "MR")));
65 flowGraphParser.createAndProcessBlueprints();
66 } catch (RuntimeException rte) {
67 rte.printStackTrace();
69 } catch (Exception e) {
71 throw new RuntimeException(e);