Revize f335b855
Přidáno uživatelem Vít Mazín před téměř 6 roky(ů)
sources/classes/test/imiger-dot-converter/complete1.dot | ||
---|---|---|
1 |
digraph "example.y" |
|
2 |
{ |
|
3 |
node [fontname = courier, shape = box, colorscheme = paired6] |
|
4 |
edge [fontname = courier] |
|
5 |
|
|
6 |
0 [label="State 0\n\l 0 $accept: . exp $end\l"] |
|
7 |
0 -> 1 [style=solid label="\"0\""] |
|
8 |
0 -> 2 [style=dashed label="exp"] |
|
9 |
0 -> 3 [style=dashed label="a"] |
|
10 |
0 -> 4 [style=dashed label="b"] |
|
11 |
1 [label="State 1\n\l 3 a: \"0\" .\l 4 b: \"0\" .\l"] |
|
12 |
1 -> "1R3" [style=solid] |
|
13 |
"1R3" [label="R3", fillcolor=3, shape=diamond, styale=filled] |
|
14 |
1 -> "1R4" [label="[\".\"]", style=solid] |
|
15 |
"1R4" [label="R4", fillcolor=3, shape=diamond, style=filled] |
|
16 |
2 [label="State 2\n\l 0 $accept: exp . $end\l"] |
|
17 |
2 -> 5 [style=solid label="$end"] |
|
18 |
3 [label="State 3\n\l 1 exp: a . \";\"\l"] |
|
19 |
3 -> 6 [style=solid label="\";\""] |
|
20 |
4 [label="State 4\n\l 2 exp: b . \".\"\l"] |
|
21 |
4 -> 7 [style=solid label="\".\""] |
|
22 |
5 [label="State 5\n\l 0 $accept: exp $end .\l"] |
|
23 |
5 -> "5R0" [style=solid] |
|
24 |
"5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] |
|
25 |
6 [label="State 6\n\l 1 exp: a \";\" .\l"] |
|
26 |
6 -> "6R1" [style=solid] |
|
27 |
"6R1" [label="R1", fillcolor=3, shape=diamond, style=filled] |
|
28 |
7 [label="State 7\n\l 2 exp: b \".\" .\l"] |
|
29 |
7 -> "7R2" [style=solid] |
|
30 |
"7R2" [label="R2", fillcolor=3, shape=diamond, style=filled] |
|
31 |
} |
sources/classes/test/imiger-dot-converter/incomplete1.dot | ||
---|---|---|
1 |
digraph "example.y" |
|
2 |
{ |
|
3 |
node [fontname = courier, shape = box, colorscheme = paired6] |
|
4 |
edge [fontname = courier] |
|
5 |
|
|
6 |
0 [label="State 0\n\l 0 $accept: . exp $end\l"] |
|
7 |
-> 1 [style=solid label="\"0\""] |
|
8 |
0 -> 2 [style=dashed label="exp"] |
|
9 |
0 -> 3 [style=dashed label="a"] |
|
10 |
0 -> 4 [style=dashed label="b"] |
|
11 |
1 [label="State 1\n\l 3 a: \"0\" .\l 4 b: \"0\" .\l"] |
|
12 |
1 -> "1R3" [style=solid] |
|
13 |
"1R3" [label="R3", fillcolor=3, shape=diamond, styale=filled] |
|
14 |
1 -> "1R4" [label="[\".\"]", style=solid] |
|
15 |
"1R4" [label="R4", fillcolor=3, shape=diamond, style=filled] |
|
16 |
2 [label="State 2\n\l 0 $accept: exp . $end\l"] |
|
17 |
2 -> 5 [style=solid label="$end"] |
|
18 |
3 [label="State 3\n\l 1 exp: a . \";\"\l"] |
|
19 |
3 -> 6 [style=solid label="\";\""] |
|
20 |
4 [label="State 4\n\l 2 exp: b . \".\"\l"] |
|
21 |
4 -> 7 [style=solid label="\".\""] |
|
22 |
5 [label="State 5\n\l 0 $accept: exp $end .\l"] |
|
23 |
5 -> "5R0" [style=solid] |
|
24 |
"5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] |
|
25 |
6 [label="State 6\n\l 1 exp: a \";\" .\l"] |
|
26 |
6 -> "6R1" [style=solid] |
|
27 |
"6R1" [label="R1", fillcolor=3, shape=diamond, style=filled] |
|
28 |
7 [label="State 7\n\l 2 exp: b \".\" .\l"] |
|
29 |
7 -> "7R2" [style=solid] |
|
30 |
"7R2" [label="R2", fillcolor=3, shape=diamond, style=filled] |
|
31 |
} |
sources/imiger-dot-converter/pom.xml | ||
---|---|---|
69 | 69 |
<artifactId>commons-io</artifactId> |
70 | 70 |
<version>2.6</version> |
71 | 71 |
</dependency> |
72 |
<dependency> |
|
73 |
<groupId>org.apache.commons</groupId> |
|
74 |
<artifactId>commons-io</artifactId> |
|
75 |
<version>1.3.2</version> |
|
76 |
</dependency> |
|
72 | 77 |
|
73 | 78 |
<!-- Libs for Logging --> |
74 | 79 |
<dependency> |
... | ... | |
84 | 89 |
|
85 | 90 |
<!-- Libs for Unit testing --> |
86 | 91 |
<dependency> |
87 |
<groupId>org.junit.jupiter</groupId>
|
|
88 |
<artifactId>junit-jupiter-api</artifactId>
|
|
89 |
<version>5.3.2</version>
|
|
92 |
<groupId>junit</groupId>
|
|
93 |
<artifactId>junit</artifactId> |
|
94 |
<version>4.12</version>
|
|
90 | 95 |
<scope>test</scope> |
91 | 96 |
</dependency> |
92 | 97 |
</dependencies> |
sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/PaypalDOTLoader.java | ||
---|---|---|
43 | 43 |
attributeTypes = new HashSet<>(); |
44 | 44 |
remappedVertices = new HashMap<>(); |
45 | 45 |
attributeNames = new HashSet<>(); |
46 |
processVertices(); |
|
47 |
processEdges(); |
|
46 |
|
|
47 |
if(parser != null) { |
|
48 |
processVertices(); |
|
49 |
processEdges(); |
|
50 |
} |
|
48 | 51 |
} |
49 | 52 |
|
50 | 53 |
/** |
... | ... | |
71 | 74 |
*/ |
72 | 75 |
@Override |
73 | 76 |
public Set<AttributeType> getAttributeTypes() { |
74 |
if(attributeTypes.size() == 0) { |
|
77 |
if(attributeTypes.size() == 0 && attributeNames.size() > 0) {
|
|
75 | 78 |
for(String attr : attributeNames) { |
76 | 79 |
attributeTypes.add(new AttributeType(attr, AttributeDataType.STRING, "")); |
77 | 80 |
} |
sources/imiger-dot-converter/src/test/java/cz/zcu/kiv/imiger/plugin/dot/backend/PaypalDOTLoaderTest.java | ||
---|---|---|
1 |
package cz.zcu.kiv.imiger.plugin.dot.backend; |
|
2 |
|
|
3 |
import cz.zcu.kiv.imiger.plugin.dot.dto.EdgeDTO; |
|
4 |
import cz.zcu.kiv.imiger.plugin.dot.dto.VertexDTO; |
|
5 |
import cz.zcu.kiv.imiger.plugin.dot.loader.BaseDOTLoader; |
|
6 |
import cz.zcu.kiv.imiger.plugin.dot.loader.PaypalDOTLoader; |
|
7 |
import cz.zcu.kiv.imiger.vo.AttributeType; |
|
8 |
import org.junit.Before; |
|
9 |
import org.junit.Test; |
|
10 |
import org.apache.commons.io.*; |
|
11 |
|
|
12 |
import java.io.IOException; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Set; |
|
15 |
|
|
16 |
import static org.junit.Assert.*; |
|
17 |
|
|
18 |
public class PaypalDOTLoaderTest { |
|
19 |
|
|
20 |
BaseDOTLoader<VertexDTO, EdgeDTO> loader; |
|
21 |
|
|
22 |
@Before |
|
23 |
public void setup() { |
|
24 |
loader = null; |
|
25 |
} |
|
26 |
|
|
27 |
private String getFileAsString(String fileName) { |
|
28 |
try { |
|
29 |
return IOUtils.toString(getClass().getClassLoader().getResourceAsStream(fileName), "UTF-8"); |
|
30 |
} catch (IOException e) { |
|
31 |
return null; |
|
32 |
} |
|
33 |
} |
|
34 |
|
|
35 |
@Test |
|
36 |
public void testOkGraph() { |
|
37 |
String input = getFileAsString("complete1.dot"); |
|
38 |
|
|
39 |
loader = new PaypalDOTLoader(input); |
|
40 |
|
|
41 |
List<VertexDTO> vertices = loader.getVertices(); |
|
42 |
List<EdgeDTO> edges = loader.getEdges(); |
|
43 |
Set<AttributeType> attrs = loader.getAttributeTypes(); |
|
44 |
|
|
45 |
assertEquals(13, vertices.size()); |
|
46 |
assertEquals(12, edges.size()); |
|
47 |
assertEquals(5, attrs.size()); |
|
48 |
} |
|
49 |
|
|
50 |
@Test |
|
51 |
public void testIncompleteGraph() { |
|
52 |
String input = getFileAsString("incomplete1.dot"); |
|
53 |
|
|
54 |
loader = new PaypalDOTLoader(input); |
|
55 |
|
|
56 |
List<VertexDTO> vertices = loader.getVertices(); |
|
57 |
List<EdgeDTO> edges = loader.getEdges(); |
|
58 |
Set<AttributeType> attrs = loader.getAttributeTypes(); |
|
59 |
|
|
60 |
assertEquals(0, vertices.size()); |
|
61 |
assertEquals(0, edges.size()); |
|
62 |
assertEquals(0, attrs.size()); |
|
63 |
} |
|
64 |
} |
sources/imiger-dot-converter/src/test/resources/complete1.dot | ||
---|---|---|
1 |
digraph "example.y" |
|
2 |
{ |
|
3 |
node [fontname = courier, shape = box, colorscheme = paired6] |
|
4 |
edge [fontname = courier] |
|
5 |
|
|
6 |
0 [label="State 0\n\l 0 $accept: . exp $end\l"] |
|
7 |
0 -> 1 [style=solid label="\"0\""] |
|
8 |
0 -> 2 [style=dashed label="exp"] |
|
9 |
0 -> 3 [style=dashed label="a"] |
|
10 |
0 -> 4 [style=dashed label="b"] |
|
11 |
1 [label="State 1\n\l 3 a: \"0\" .\l 4 b: \"0\" .\l"] |
|
12 |
1 -> "1R3" [style=solid] |
|
13 |
"1R3" [label="R3", fillcolor=3, shape=diamond, styale=filled] |
|
14 |
1 -> "1R4" [label="[\".\"]", style=solid] |
|
15 |
"1R4" [label="R4", fillcolor=3, shape=diamond, style=filled] |
|
16 |
2 [label="State 2\n\l 0 $accept: exp . $end\l"] |
|
17 |
2 -> 5 [style=solid label="$end"] |
|
18 |
3 [label="State 3\n\l 1 exp: a . \";\"\l"] |
|
19 |
3 -> 6 [style=solid label="\";\""] |
|
20 |
4 [label="State 4\n\l 2 exp: b . \".\"\l"] |
|
21 |
4 -> 7 [style=solid label="\".\""] |
|
22 |
5 [label="State 5\n\l 0 $accept: exp $end .\l"] |
|
23 |
5 -> "5R0" [style=solid] |
|
24 |
"5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] |
|
25 |
6 [label="State 6\n\l 1 exp: a \";\" .\l"] |
|
26 |
6 -> "6R1" [style=solid] |
|
27 |
"6R1" [label="R1", fillcolor=3, shape=diamond, style=filled] |
|
28 |
7 [label="State 7\n\l 2 exp: b \".\" .\l"] |
|
29 |
7 -> "7R2" [style=solid] |
|
30 |
"7R2" [label="R2", fillcolor=3, shape=diamond, style=filled] |
|
31 |
} |
sources/imiger-dot-converter/src/test/resources/incomplete1.dot | ||
---|---|---|
1 |
digraph "example.y" |
|
2 |
{ |
|
3 |
node [fontname = courier, shape = box, colorscheme = paired6] |
|
4 |
edge [fontname = courier] |
|
5 |
|
|
6 |
0 [label="State 0\n\l 0 $accept: . exp $end\l"] |
|
7 |
-> 1 [style=solid label="\"0\""] |
|
8 |
0 -> 2 [style=dashed label="exp"] |
|
9 |
0 -> 3 [style=dashed label="a"] |
|
10 |
0 -> 4 [style=dashed label="b"] |
|
11 |
1 [label="State 1\n\l 3 a: \"0\" .\l 4 b: \"0\" .\l"] |
|
12 |
1 -> "1R3" [style=solid] |
|
13 |
"1R3" [label="R3", fillcolor=3, shape=diamond, styale=filled] |
|
14 |
1 -> "1R4" [label="[\".\"]", style=solid] |
|
15 |
"1R4" [label="R4", fillcolor=3, shape=diamond, style=filled] |
|
16 |
2 [label="State 2\n\l 0 $accept: exp . $end\l"] |
|
17 |
2 -> 5 [style=solid label="$end"] |
|
18 |
3 [label="State 3\n\l 1 exp: a . \";\"\l"] |
|
19 |
3 -> 6 [style=solid label="\";\""] |
|
20 |
4 [label="State 4\n\l 2 exp: b . \".\"\l"] |
|
21 |
4 -> 7 [style=solid label="\".\""] |
|
22 |
5 [label="State 5\n\l 0 $accept: exp $end .\l"] |
|
23 |
5 -> "5R0" [style=solid] |
|
24 |
"5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] |
|
25 |
6 [label="State 6\n\l 1 exp: a \";\" .\l"] |
|
26 |
6 -> "6R1" [style=solid] |
|
27 |
"6R1" [label="R1", fillcolor=3, shape=diamond, style=filled] |
|
28 |
7 [label="State 7\n\l 2 exp: b \".\" .\l"] |
|
29 |
7 -> "7R2" [style=solid] |
|
30 |
"7R2" [label="R2", fillcolor=3, shape=diamond, style=filled] |
|
31 |
} |
Také k dispozici: Unified diff
DOT Loader tests