1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.xml.mapper; |
17 |
|
|
18 |
|
import org.qedeq.kernel.bo.module.KernelQedeqBo; |
19 |
|
import org.qedeq.kernel.bo.test.QedeqBoTestCase; |
20 |
|
import org.qedeq.kernel.se.common.DefaultModuleAddress; |
21 |
|
import org.qedeq.kernel.se.common.ModuleAddress; |
22 |
|
import org.qedeq.kernel.se.common.ModuleContext; |
23 |
|
import org.qedeq.kernel.se.common.ModuleDataException; |
24 |
|
|
25 |
|
|
26 |
|
@link |
27 |
|
|
28 |
|
@author |
29 |
|
|
|
|
| 97.7% |
Uncovered Elements: 1 (44) |
Complexity: 12 |
Complexity Density: 0.36 |
|
30 |
|
public class Context2SimpleXPathTest extends QedeqBoTestCase { |
31 |
|
|
32 |
|
private KernelQedeqBo qedeq; |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
34 |
9
|
protected void setUp() throws Exception {... |
35 |
9
|
super.setUp(); |
36 |
9
|
final ModuleAddress address = new DefaultModuleAddress(getFile("mapper/Context2SimpleXPath001.xml")); |
37 |
9
|
getServices().loadModule(address); |
38 |
9
|
qedeq = getInternalServices().getKernelQedeqBo(address); |
39 |
9
|
assertEquals(0, qedeq.getErrors().size()); |
40 |
|
} |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
9
|
protected void tearDown() throws Exception {... |
43 |
9
|
super.tearDown(); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
46 |
1
|
public void testGetXPath01() throws ModuleDataException {... |
47 |
1
|
final ModuleContext find = new ModuleContext(qedeq.getModuleAddress()); |
48 |
1
|
assertEquals("/QEDEQ", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString()); |
49 |
|
} |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
51 |
1
|
public void testGetXPath02() throws ModuleDataException {... |
52 |
1
|
final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0)"); |
53 |
1
|
assertEquals("/QEDEQ/CHAPTER", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString()); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
56 |
1
|
public void testGetXPath03() throws ModuleDataException {... |
57 |
1
|
final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getHeader()"); |
58 |
1
|
assertEquals("/QEDEQ/HEADER", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString()); |
59 |
|
} |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
61 |
1
|
public void testGetXPath04() throws ModuleDataException {... |
62 |
1
|
assertNotNull(qedeq.getQedeq().getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode()); |
63 |
1
|
final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode()"); |
64 |
1
|
assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString()); |
65 |
|
} |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
67 |
1
|
public void testGetXPath05() throws ModuleDataException {... |
68 |
1
|
assertNotNull(qedeq.getQedeq().getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2)); |
69 |
1
|
final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2)"); |
70 |
1
|
assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString()); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
73 |
1
|
public void testGetXPath06() throws ModuleDataException {... |
74 |
1
|
assertNotNull(qedeq.getQedeq().getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode().getNodeType().getPredicateDefinition().getFormula().getElement().getList()); |
75 |
1
|
final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode().getNodeType().getPredicateDefinition().getFormula().getElement().getList()"); |
76 |
1
|
assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]/DEFINITION_PREDICATE/FORMULA/EQUI", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString()); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
79 |
1
|
public void testGetXPath07() throws ModuleDataException {... |
80 |
1
|
final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode().getNodeType().getPredicateDefinition().getFormula().getElement().getList().getElement(0).getList()"); |
81 |
1
|
assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]/DEFINITION_PREDICATE/FORMULA/EQUI/PREDCON", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString()); |
82 |
|
} |
83 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1
PASS
|
|
84 |
1
|
public void testGetXPath08() {... |
85 |
1
|
final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(99).getNode().getNodeType()"); |
86 |
1
|
try { |
87 |
1
|
Context2SimpleXPath.getXPath(find, qedeq.getQedeq()); |
88 |
0
|
fail("ModuleDataException expected"); |
89 |
|
} catch (ModuleDataException e) { |
90 |
|
|
91 |
|
} |
92 |
|
} |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
94 |
1
|
public void testGetXPath09() throws ModuleDataException {... |
95 |
1
|
final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode().getNodeType().getUnknown()"); |
96 |
1
|
final boolean locationFailures = "true".equalsIgnoreCase( |
97 |
|
System.getProperty("qedeq.test.xmlLocationFailures", "false")); |
98 |
1
|
System.setProperty("qedeq.test.xmlLocationFailures", "false"); |
99 |
1
|
try { |
100 |
1
|
assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]", |
101 |
|
Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString()); |
102 |
|
} finally { |
103 |
1
|
System.setProperty("qedeq.test.xmlLocationFailures", Boolean.toString(locationFailures)); |
104 |
|
} |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
} |