2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
4 * Copyright (C) 2020 Nokia. 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
10 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
19 package org.onap.dcae.runtime.core;
22 import java.io.FileWriter;
23 import java.io.IOException;
24 import java.io.Writer;
25 import org.junit.Rule;
26 import org.junit.Test;
27 import org.junit.rules.TemporaryFolder;
28 import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnap;
30 public class TestFlowGraphParser extends BpGenTestBase {
33 public TemporaryFolder folder = new TemporaryFolder();
36 public void testFlowGraphParser() throws IOException {
38 File importsfile = folder.newFile("imports.yaml");
39 try (Writer w = new FileWriter(importsfile)) {
42 " - 'http://www.getcloudify.org/spec/cloudify/3.4/types.yaml'\n" +
43 " - '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 BlueprintCreatorOnap bcod = new BlueprintCreatorOnap(componentSpecService, blueprintCreatorService,
51 blueprintService, fixesService);
52 bcod.setTopicUrl("u.r.l");
53 bcod.setImportFilePath(importsfile.getAbsolutePath());
54 FlowGraphParser flowGraphParser = new FlowGraphParser(bcod);
55 flowGraphParser.parse(mainFlowGraph);
56 String compspec = Helper.loadFileContent("src/test/data/compspecs/componentSpec_hello_world.json");
57 mainFlowGraph.addNode(new Node("comp5678", "hello-world-2", compspec));
58 mainFlowGraph.addNode(new Node("comp1234", "hello-world-1", compspec));
59 mainFlowGraph.addEdge(
60 flowGraphParser.getNodeFromId("comp1234"),
61 flowGraphParser.getNodeFromId("comp5678"),
63 new EdgeLocation("comp1234", "DCAE-HELLO-WORLD-PUB-MR"),
64 new EdgeLocation("comp5678", "DCAE-HELLO-WORLD-SUB-MR"),
65 new EdgeMetadata("sample_topic_1", "json", "MR")));
66 flowGraphParser.createAndProcessBlueprints();
67 } catch (RuntimeException rte) {
68 rte.printStackTrace();
70 } catch (Exception e) {
72 throw new RuntimeException(e);