commit f335b855fbca2499a2638b1c8cdabe82823664ed
Author: Vít Mazín <vit.mazin@seznam.cz>
Date:   Mon Apr 1 17:33:52 2019 +0200

    DOT Loader tests

diff --git a/sources/classes/test/imiger-dot-converter/complete1.dot b/sources/classes/test/imiger-dot-converter/complete1.dot
new file mode 100644
index 0000000..3422119
--- /dev/null
+++ b/sources/classes/test/imiger-dot-converter/complete1.dot
@@ -0,0 +1,31 @@
+digraph "example.y"
+{
+  node [fontname = courier, shape = box, colorscheme = paired6]
+  edge [fontname = courier]
+
+  0 [label="State 0\n\l  0 $accept: . exp $end\l"]
+  0 -> 1 [style=solid label="\"0\""]
+  0 -> 2 [style=dashed label="exp"]
+  0 -> 3 [style=dashed label="a"]
+  0 -> 4 [style=dashed label="b"]
+  1 [label="State 1\n\l  3 a: \"0\" .\l  4 b: \"0\" .\l"]
+  1 -> "1R3" [style=solid]
+ "1R3" [label="R3", fillcolor=3, shape=diamond, styale=filled]
+  1 -> "1R4" [label="[\".\"]", style=solid]
+ "1R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
+  2 [label="State 2\n\l  0 $accept: exp . $end\l"]
+  2 -> 5 [style=solid label="$end"]
+  3 [label="State 3\n\l  1 exp: a . \";\"\l"]
+  3 -> 6 [style=solid label="\";\""]
+  4 [label="State 4\n\l  2 exp: b . \".\"\l"]
+  4 -> 7 [style=solid label="\".\""]
+  5 [label="State 5\n\l  0 $accept: exp $end .\l"]
+  5 -> "5R0" [style=solid]
+ "5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
+  6 [label="State 6\n\l  1 exp: a \";\" .\l"]
+  6 -> "6R1" [style=solid]
+ "6R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
+  7 [label="State 7\n\l  2 exp: b \".\" .\l"]
+  7 -> "7R2" [style=solid]
+ "7R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
+}
\ No newline at end of file
diff --git a/sources/classes/test/imiger-dot-converter/incomplete1.dot b/sources/classes/test/imiger-dot-converter/incomplete1.dot
new file mode 100644
index 0000000..229ebe4
--- /dev/null
+++ b/sources/classes/test/imiger-dot-converter/incomplete1.dot
@@ -0,0 +1,31 @@
+digraph "example.y"
+{
+  node [fontname = courier, shape = box, colorscheme = paired6]
+  edge [fontname = courier]
+
+  0 [label="State 0\n\l  0 $accept: . exp $end\l"]
+   -> 1 [style=solid label="\"0\""]
+  0 -> 2 [style=dashed label="exp"]
+  0 -> 3 [style=dashed label="a"]
+  0 -> 4 [style=dashed label="b"]
+  1 [label="State 1\n\l  3 a: \"0\" .\l  4 b: \"0\" .\l"]
+  1 -> "1R3" [style=solid]
+ "1R3" [label="R3", fillcolor=3, shape=diamond, styale=filled]
+  1 -> "1R4" [label="[\".\"]", style=solid]
+ "1R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
+  2 [label="State 2\n\l  0 $accept: exp . $end\l"]
+  2 -> 5 [style=solid label="$end"]
+  3 [label="State 3\n\l  1 exp: a . \";\"\l"]
+  3 -> 6 [style=solid label="\";\""]
+  4 [label="State 4\n\l  2 exp: b . \".\"\l"]
+  4 -> 7 [style=solid label="\".\""]
+  5 [label="State 5\n\l  0 $accept: exp $end .\l"]
+  5 -> "5R0" [style=solid]
+ "5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
+  6 [label="State 6\n\l  1 exp: a \";\" .\l"]
+  6 -> "6R1" [style=solid]
+ "6R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
+  7 [label="State 7\n\l  2 exp: b \".\" .\l"]
+  7 -> "7R2" [style=solid]
+ "7R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
+}
\ No newline at end of file
diff --git a/sources/imiger-dot-converter/pom.xml b/sources/imiger-dot-converter/pom.xml
index 6428d1a..1e3793a 100644
--- a/sources/imiger-dot-converter/pom.xml
+++ b/sources/imiger-dot-converter/pom.xml
@@ -69,6 +69,11 @@
             <artifactId>commons-io</artifactId>
             <version>2.6</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.3.2</version>
+        </dependency>
 
         <!-- Libs for Logging -->
         <dependency>
@@ -84,9 +89,9 @@
 
         <!-- Libs for Unit testing -->
         <dependency>
-            <groupId>org.junit.jupiter</groupId>
-            <artifactId>junit-jupiter-api</artifactId>
-            <version>5.3.2</version>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/PaypalDOTLoader.java b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/PaypalDOTLoader.java
index 71a0fa0..ddc1af4 100644
--- a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/PaypalDOTLoader.java
+++ b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/PaypalDOTLoader.java
@@ -43,8 +43,11 @@ public class PaypalDOTLoader extends BaseDOTLoader<VertexDTO, EdgeDTO> {
         attributeTypes = new HashSet<>();
         remappedVertices = new HashMap<>();
         attributeNames = new HashSet<>();
-        processVertices();
-        processEdges();
+
+        if(parser != null) {
+            processVertices();
+            processEdges();
+        }
     }
 
     /**
@@ -71,7 +74,7 @@ public class PaypalDOTLoader extends BaseDOTLoader<VertexDTO, EdgeDTO> {
      */
     @Override
     public Set<AttributeType> getAttributeTypes() {
-        if(attributeTypes.size() == 0) {
+        if(attributeTypes.size() == 0 && attributeNames.size() > 0) {
             for(String attr : attributeNames) {
                 attributeTypes.add(new AttributeType(attr, AttributeDataType.STRING, ""));
             }
diff --git a/sources/imiger-dot-converter/src/test/java/cz/zcu/kiv/imiger/plugin/dot/backend/PaypalDOTLoaderTest.java b/sources/imiger-dot-converter/src/test/java/cz/zcu/kiv/imiger/plugin/dot/backend/PaypalDOTLoaderTest.java
new file mode 100644
index 0000000..e6a091a
--- /dev/null
+++ b/sources/imiger-dot-converter/src/test/java/cz/zcu/kiv/imiger/plugin/dot/backend/PaypalDOTLoaderTest.java
@@ -0,0 +1,64 @@
+package cz.zcu.kiv.imiger.plugin.dot.backend;
+
+import cz.zcu.kiv.imiger.plugin.dot.dto.EdgeDTO;
+import cz.zcu.kiv.imiger.plugin.dot.dto.VertexDTO;
+import cz.zcu.kiv.imiger.plugin.dot.loader.BaseDOTLoader;
+import cz.zcu.kiv.imiger.plugin.dot.loader.PaypalDOTLoader;
+import cz.zcu.kiv.imiger.vo.AttributeType;
+import org.junit.Before;
+import org.junit.Test;
+import org.apache.commons.io.*;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.*;
+
+public class PaypalDOTLoaderTest {
+
+    BaseDOTLoader<VertexDTO, EdgeDTO> loader;
+
+    @Before
+    public void setup() {
+        loader = null;
+    }
+
+    private String getFileAsString(String fileName) {
+        try {
+            return IOUtils.toString(getClass().getClassLoader().getResourceAsStream(fileName), "UTF-8");
+        } catch (IOException e) {
+            return null;
+        }
+    }
+
+    @Test
+    public void testOkGraph() {
+        String input = getFileAsString("complete1.dot");
+
+        loader = new PaypalDOTLoader(input);
+
+        List<VertexDTO> vertices = loader.getVertices();
+        List<EdgeDTO> edges = loader.getEdges();
+        Set<AttributeType> attrs = loader.getAttributeTypes();
+
+        assertEquals(13, vertices.size());
+        assertEquals(12, edges.size());
+        assertEquals(5, attrs.size());
+    }
+
+    @Test
+    public void testIncompleteGraph() {
+        String input = getFileAsString("incomplete1.dot");
+
+        loader = new PaypalDOTLoader(input);
+
+        List<VertexDTO> vertices = loader.getVertices();
+        List<EdgeDTO> edges = loader.getEdges();
+        Set<AttributeType> attrs = loader.getAttributeTypes();
+
+        assertEquals(0, vertices.size());
+        assertEquals(0, edges.size());
+        assertEquals(0, attrs.size());
+    }
+}
diff --git a/sources/imiger-dot-converter/src/test/resources/complete1.dot b/sources/imiger-dot-converter/src/test/resources/complete1.dot
new file mode 100644
index 0000000..3422119
--- /dev/null
+++ b/sources/imiger-dot-converter/src/test/resources/complete1.dot
@@ -0,0 +1,31 @@
+digraph "example.y"
+{
+  node [fontname = courier, shape = box, colorscheme = paired6]
+  edge [fontname = courier]
+
+  0 [label="State 0\n\l  0 $accept: . exp $end\l"]
+  0 -> 1 [style=solid label="\"0\""]
+  0 -> 2 [style=dashed label="exp"]
+  0 -> 3 [style=dashed label="a"]
+  0 -> 4 [style=dashed label="b"]
+  1 [label="State 1\n\l  3 a: \"0\" .\l  4 b: \"0\" .\l"]
+  1 -> "1R3" [style=solid]
+ "1R3" [label="R3", fillcolor=3, shape=diamond, styale=filled]
+  1 -> "1R4" [label="[\".\"]", style=solid]
+ "1R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
+  2 [label="State 2\n\l  0 $accept: exp . $end\l"]
+  2 -> 5 [style=solid label="$end"]
+  3 [label="State 3\n\l  1 exp: a . \";\"\l"]
+  3 -> 6 [style=solid label="\";\""]
+  4 [label="State 4\n\l  2 exp: b . \".\"\l"]
+  4 -> 7 [style=solid label="\".\""]
+  5 [label="State 5\n\l  0 $accept: exp $end .\l"]
+  5 -> "5R0" [style=solid]
+ "5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
+  6 [label="State 6\n\l  1 exp: a \";\" .\l"]
+  6 -> "6R1" [style=solid]
+ "6R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
+  7 [label="State 7\n\l  2 exp: b \".\" .\l"]
+  7 -> "7R2" [style=solid]
+ "7R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
+}
\ No newline at end of file
diff --git a/sources/imiger-dot-converter/src/test/resources/incomplete1.dot b/sources/imiger-dot-converter/src/test/resources/incomplete1.dot
new file mode 100644
index 0000000..229ebe4
--- /dev/null
+++ b/sources/imiger-dot-converter/src/test/resources/incomplete1.dot
@@ -0,0 +1,31 @@
+digraph "example.y"
+{
+  node [fontname = courier, shape = box, colorscheme = paired6]
+  edge [fontname = courier]
+
+  0 [label="State 0\n\l  0 $accept: . exp $end\l"]
+   -> 1 [style=solid label="\"0\""]
+  0 -> 2 [style=dashed label="exp"]
+  0 -> 3 [style=dashed label="a"]
+  0 -> 4 [style=dashed label="b"]
+  1 [label="State 1\n\l  3 a: \"0\" .\l  4 b: \"0\" .\l"]
+  1 -> "1R3" [style=solid]
+ "1R3" [label="R3", fillcolor=3, shape=diamond, styale=filled]
+  1 -> "1R4" [label="[\".\"]", style=solid]
+ "1R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
+  2 [label="State 2\n\l  0 $accept: exp . $end\l"]
+  2 -> 5 [style=solid label="$end"]
+  3 [label="State 3\n\l  1 exp: a . \";\"\l"]
+  3 -> 6 [style=solid label="\";\""]
+  4 [label="State 4\n\l  2 exp: b . \".\"\l"]
+  4 -> 7 [style=solid label="\".\""]
+  5 [label="State 5\n\l  0 $accept: exp $end .\l"]
+  5 -> "5R0" [style=solid]
+ "5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
+  6 [label="State 6\n\l  1 exp: a \";\" .\l"]
+  6 -> "6R1" [style=solid]
+ "6R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
+  7 [label="State 7\n\l  2 exp: b \".\" .\l"]
+  7 -> "7R2" [style=solid]
+ "7R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
+}
\ No newline at end of file
