summaryrefslogtreecommitdiffstats
path: root/mod/runtimeapi/runtime-core
diff options
context:
space:
mode:
authorAndrew Gauld <agauld@att.com>2020-01-24 19:14:27 +0000
committerAndrew Gauld <agauld@att.com>2020-01-24 19:22:15 +0000
commit25cd97d9626dcc1cd3dd82b3ad5c934cdb137342 (patch)
tree8d62d75cfd381e8bd7b307bca2e2305f922198ec /mod/runtimeapi/runtime-core
parent6f2d7c7bd510345436f54fd1554280cc731a1dc4 (diff)
Improve mod/runtimeapi code coverage
Change-Id: Ic8b23955deed9411ac2c216571ec2548a9fc5e42 Issue-ID: DCAEGEN2-1860 Signed-off-by: Andrew Gauld <agauld@att.com>
Diffstat (limited to 'mod/runtimeapi/runtime-core')
-rw-r--r--mod/runtimeapi/runtime-core/pom.xml24
-rw-r--r--mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestBeans.java51
-rw-r--r--mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestFlowGraphParser.java69
3 files changed, 121 insertions, 23 deletions
diff --git a/mod/runtimeapi/runtime-core/pom.xml b/mod/runtimeapi/runtime-core/pom.xml
index fcfe314..dd5d10b 100644
--- a/mod/runtimeapi/runtime-core/pom.xml
+++ b/mod/runtimeapi/runtime-core/pom.xml
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+============LICENSE_START=======================================================
+Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
+================================================================================
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+============LICENSE_END=========================================================
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -28,10 +45,15 @@
<artifactId>blueprint-generator</artifactId>
<version>1.0.0</version>
</dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20190722</version>
+ </dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
- <version>1.21</version>
+ <version>1.23</version>
</dependency>
</dependencies>
</project>
diff --git a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestBeans.java b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestBeans.java
new file mode 100644
index 0000000..1d2e8fb
--- /dev/null
+++ b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestBeans.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcae.runtime.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestBeans {
+ @Test
+ public void testBeans() {
+ BlueprintData bpd = new BlueprintData("version", "content");
+ bpd.setVersion(bpd.getVersion());
+ bpd.setBlueprint_content(bpd.getBlueprint_content());
+ Edge edg = new Edge(null, null, null);
+ edg.setSrc(edg.getSrc());
+ edg.setTgt(edg.getTgt());
+ edg.setMetadata(edg.getMetadata());
+ EdgeLocation el = new EdgeLocation("node", "port");
+ el.setNode(el.getNode());
+ el.setPort(el.getPort());
+ EdgeMetadata em = new EdgeMetadata("name", "data_type", "dmaap_type");
+ em.setName(em.getName());
+ em.setDataType(em.getDataType());
+ em.setDmaapType(em.getDmaapType());
+ Node nod = new Node("componentId", "componentName", "componentSpec");
+ nod.setComponentId(nod.getComponentId());
+ nod.setComponentName(nod.getComponentName());
+ nod.setComponentSpec(nod.getComponentSpec());
+ nod.setBlueprintData(nod.getBlueprintData());
+ assertTrue(nod.equals(nod));
+ assertEquals(nod.toString(), "componentId");
+ }
+}
diff --git a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestFlowGraphParser.java b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestFlowGraphParser.java
index bacfcb1..8412133 100644
--- a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestFlowGraphParser.java
+++ b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestFlowGraphParser.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,33 +17,58 @@
*/
package org.onap.dcae.runtime.core;
-import org.junit.Before;
-import org.junit.Ignore;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnapDublin;
public class TestFlowGraphParser {
- private FlowGraph<Node, Edge> flowGraph;
- private FlowGraphParser flowGraphParser;
-
- @Before
- public void setUp() throws Exception{
- flowGraph = Helper.prepareFlowGraph();
- flowGraphParser = new FlowGraphParser(new BlueprintCreatorOnapDublin());
- flowGraphParser.parse(flowGraph);
- }
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder();
@Test
- @Ignore
- public void testBlueprintsCreate() throws Exception{
- /*
- TODO: FIX
- Map<String,String> expectedBlueprints = Helper.loadTestBlueprints();
- Map<String,String> resultBlueprints = flowGraphParser.createAndProcessBlueprints();
-
- assertEquals(expectedBlueprints,resultBlueprints);
- */
+ public void testFlowGraphParser() throws IOException {
+ try {
+ File importsfile = folder.newFile("imports.yaml");
+ try (Writer w = new FileWriter(importsfile)) {
+ w.write(
+ "imports:\n" +
+ " - 'http://www.getcloudify.org/spec/cloudify/3.4/types.yaml'\n" +
+ " - 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.5/k8splugin_types.yaml'\n" +
+ " - 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml'\n"
+ );
+ }
+ FlowGraph<Node, Edge> mainFlowGraph = new FlowGraph<>("1234", "nifi-main", true, "mock graph");
+ mainFlowGraph.addNode(new Node("dummy_id", "dummy_name", "dummy_compspec"));
+ BlueprintCreatorOnapDublin bcod = new BlueprintCreatorOnapDublin();
+ bcod.setTopicUrl("u.r.l");
+ bcod.setImportFilePath(importsfile.getAbsolutePath());
+ FlowGraphParser flowGraphParser = new FlowGraphParser(bcod);
+ flowGraphParser.parse(mainFlowGraph);
+ String compspec = Helper.loadFileContent("src/test/data/compspecs/componentSpec_hello_world.json");
+ mainFlowGraph.addNode(new Node("comp5678", "hello-world-2", compspec));
+ mainFlowGraph.addNode(new Node("comp1234", "hello-world-1", compspec));
+ mainFlowGraph.addEdge(
+ flowGraphParser.getNodeFromId("comp1234"),
+ flowGraphParser.getNodeFromId("comp5678"),
+ new Edge(
+ new EdgeLocation("comp1234", "DCAE-HELLO-WORLD-PUB-MR"),
+ new EdgeLocation("comp5678", "DCAE-HELLO-WORLD-SUB-MR"),
+ new EdgeMetadata("sample_topic_1", "json", "MR")));
+ flowGraphParser.createAndProcessBlueprints();
+ } catch (RuntimeException rte) {
+ rte.printStackTrace();
+ throw rte;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
}
-
}