commit 7740b8c50f8cb60babe975b0504eec5971ec1455
Author: Martin Matas <nouzovekonto@gmail.com>
Date:   Wed Apr 3 21:29:29 2019 +0200

    Integrity test for DOT module with necessary test files

diff --git a/sources/imiger-dot-converter/src/test/java/cz/zcu/kiv/imiger/plugin/dot/DOTIntegrityTest.java b/sources/imiger-dot-converter/src/test/java/cz/zcu/kiv/imiger/plugin/dot/DOTIntegrityTest.java
new file mode 100644
index 0000000..5a5c828
--- /dev/null
+++ b/sources/imiger-dot-converter/src/test/java/cz/zcu/kiv/imiger/plugin/dot/DOTIntegrityTest.java
@@ -0,0 +1,91 @@
+package cz.zcu.kiv.imiger.plugin.dot;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Integrity test fot DOT module. Verifies that for given DOT file module produces correct JSON output.
+ *
+ * Date: 03.04.2019
+ *
+ * @author Martin Matas
+ */
+public class DOTIntegrityTest {
+
+    /**
+     * Loaded test DOT file. Loaded string contains simple graph definition (two vertices connected with edge,
+     * each of them has defined attribute).
+     */
+    private final String integrityTestDOTFile = loadTestDOTFile();
+
+    /**
+     * Loaded JSON file. Represents correct test result.
+     */
+    private final String integrityTestExpectedResult = loadTestResult();
+
+    /**
+     * Test verifies that for given DOT file module produces correct JSON output.
+     */
+    @Test
+    public void getRawJson() {
+        assertThat(integrityTestDOTFile, is(not(nullValue())));
+        assertThat(integrityTestExpectedResult, is(not(nullValue())));
+
+        DOT dotModule = new DOT();
+        String result = dotModule.getRawJson(integrityTestDOTFile);
+
+        assertThat(result, is(equalTo(integrityTestExpectedResult)));
+    }
+
+    /**
+     * Method loads DOT file from resources and returns it as a string.
+     *
+     * @return - string that contains loaded DOT file
+     */
+    private String loadTestDOTFile() {
+        return readFile(Objects.requireNonNull(getClass().getClassLoader().getResource("integrityTestSource.dot")));
+    }
+
+    /**
+     * Method loads JSON file from resources and returns it as a string.
+     *
+     * @return - string that contains loaded JSON file
+     */
+    private String loadTestResult() {
+        return readFile(Objects.requireNonNull(getClass().getClassLoader().getResource("integrityTestResult.json")));
+    }
+
+    /**
+     * Method loads file based on given URL and returns it as a string.
+     *
+     * @param url - URL of file
+     * @return - file content as a string
+     */
+    private String readFile(URL url) {
+        String data = null;
+
+        try {
+            Path path = Paths.get(url.toURI());
+            Stream<String> lines = Files.lines(path);
+            data = lines.collect(Collectors.joining("\n"));
+            lines.close();
+        } catch (IOException | URISyntaxException e) {
+            System.err.println("Loading test resource failed.");
+        }
+
+        return data;
+    }
+
+}
\ No newline at end of file
diff --git a/sources/imiger-dot-converter/src/test/resources/integrityTestResult.json b/sources/imiger-dot-converter/src/test/resources/integrityTestResult.json
new file mode 100644
index 0000000..68dc5e4
--- /dev/null
+++ b/sources/imiger-dot-converter/src/test/resources/integrityTestResult.json
@@ -0,0 +1 @@
+{"vertices":[{"attributes":[["test","test value"]],"id":0,"name":"A","archetype":0,"text":""},{"attributes":[["test","test value"]],"id":1,"name":"B","archetype":0,"text":""}],"edges":[{"subedgeInfo":[{"archetype":0,"id":0,"attributes":[["test","test value"]]}],"id":0,"from":0,"to":1,"text":"A-B"}],"vertexArchetypes":[{"name":"Vertex","text":"","icon":""}],"edgeArchetypes":[{"name":"Edge","text":""}],"attributeTypes":[{"name":"test","dataType":"STRING","text":""}],"possibleEnumValues":{},"groups":[],"sideBar":[],"highlightedVertex":"","highlightedEdge":""}
\ No newline at end of file
diff --git a/sources/imiger-dot-converter/src/test/resources/integrityTestSource.dot b/sources/imiger-dot-converter/src/test/resources/integrityTestSource.dot
new file mode 100644
index 0000000..a7c0f6d
--- /dev/null
+++ b/sources/imiger-dot-converter/src/test/resources/integrityTestSource.dot
@@ -0,0 +1,5 @@
+digraph "test" {
+	"A" [test="test value"];
+	"B" [test="test value"];
+	"A" -> "B" [test="test value"];
+}
\ No newline at end of file
