Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 6a0e825

Browse files
committed
Adjust whitespaces in test code
1 parent 9a425e4 commit 6a0e825

3 files changed

Lines changed: 259 additions & 260 deletions

File tree

src/test/java/com/formulasearchengine/mathmlquerygenerator/NtcirPatternTest.java

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,53 @@
77

88
public class NtcirPatternTest {
99

10-
private NtcirPattern topic;
11-
12-
@Before
13-
public void setUp() throws Exception {
14-
topic = (new NtcirTopicReaderTest()).getFirstTopic();
15-
}
16-
17-
@Test
18-
public void testGetNum() throws Exception {
19-
assertEquals( "NTCIR11-Math-1", topic.getNum() );
20-
}
21-
22-
23-
@Test
24-
public void testGetFormulaID() throws Exception {
25-
assertEquals( "f1.0", topic.getFormulaID() );
26-
}
27-
28-
@Test
29-
public void testGetxQueryExpression() throws Exception {
30-
assertEquals( "declare default element namespace \"http://www.w3.org/1998/Math/MathML\";\n" +
31-
"for $m in db2-fn:xmlcolumn(\"math.math_mathml\") return\n" +
32-
"for $x in $m//*:apply\n" +
33-
"[*[1]/name() = 'gt' and *[2]/name() = 'apply' and *[2][*[1]/name() = 'times' and *[2]/name() = 'ci' and *[2][./text() = 'W'] and *[3]/name() = 'interval' and *[3][*[1]/name() = 'cn' and *[1][./text() = '2'] and *[2]/name() = 'ci' and *[2][./text() = 'k']]] and *[3]/name() = 'apply' and *[3][*[1]/name() = 'divide' and *[2]/name() = 'apply' and *[2][*[1]/name() = 'csymbol' and *[1][./text() = 'superscript'] and *[2]/name() = 'cn' and *[2][./text() = '2'] and *[3]/name() = 'ci' and *[3][./text() = 'k']] and *[3]/name() = 'apply' and *[3][*[1]/name() = 'csymbol' and *[1][./text() = 'superscript'] and *[2]/name() = 'ci' and *[2][./text() = 'k'] and *[3]/name() = 'ci' and *[3][./text() = 'ε']]]]\n" +
34-
"where\n" +
35-
"fn:count($x/*[2]/*[2]/*) = 0\n" +
36-
" and fn:count($x/*[2]/*[3]/*[1]/*) = 0\n" +
37-
" and fn:count($x/*[2]/*[3]/*[2]/*) = 0\n" +
38-
" and fn:count($x/*[2]/*[3]/*) = 2\n" +
39-
" and fn:count($x/*[2]/*) = 3\n" +
40-
" and fn:count($x/*[3]/*[2]/*[1]/*) = 0\n" +
41-
" and fn:count($x/*[3]/*[2]/*[2]/*) = 0\n" +
42-
" and fn:count($x/*[3]/*[2]/*[3]/*) = 0\n" +
43-
" and fn:count($x/*[3]/*[2]/*) = 3\n" +
44-
" and fn:count($x/*[3]/*[3]/*[1]/*) = 0\n" +
45-
" and fn:count($x/*[3]/*[3]/*[2]/*) = 0\n" +
46-
" and fn:count($x/*[3]/*[3]/*[3]/*) = 0\n" +
47-
" and fn:count($x/*[3]/*[3]/*) = 3\n" +
48-
" and fn:count($x/*[3]/*) = 3\n" +
49-
" and fn:count($x/*) = 3\n" +
50-
"\n" +
51-
"return\n" +
52-
"data($m/*[1]/@alttext)", topic.getxQueryExpression() );
53-
}
54-
55-
@Test
56-
public void testGetMathMLNode() throws Exception {
57-
assertEquals( "http://www.w3.org/1998/Math/MathML", topic.getMathMLNode().getNamespaceURI() );
58-
}
10+
private NtcirPattern topic;
11+
12+
@Before
13+
public void setUp() throws Exception {
14+
topic = (new NtcirTopicReaderTest()).getFirstTopic();
15+
}
16+
17+
@Test
18+
public void testGetNum() throws Exception {
19+
assertEquals("NTCIR11-Math-1", topic.getNum());
20+
}
21+
22+
23+
@Test
24+
public void testGetFormulaID() throws Exception {
25+
assertEquals("f1.0", topic.getFormulaID());
26+
}
27+
28+
@Test
29+
public void testGetxQueryExpression() throws Exception {
30+
assertEquals("declare default element namespace \"http://www.w3.org/1998/Math/MathML\";\n" +
31+
"for $m in db2-fn:xmlcolumn(\"math.math_mathml\") return\n" +
32+
"for $x in $m//*:apply\n" +
33+
"[*[1]/name() = 'gt' and *[2]/name() = 'apply' and *[2][*[1]/name() = 'times' and *[2]/name() = 'ci' and *[2][./text() = 'W'] and *[3]/name() = 'interval' and *[3][*[1]/name() = 'cn' and *[1][./text() = '2'] and *[2]/name() = 'ci' and *[2][./text() = 'k']]] and *[3]/name() = 'apply' and *[3][*[1]/name() = 'divide' and *[2]/name() = 'apply' and *[2][*[1]/name() = 'csymbol' and *[1][./text() = 'superscript'] and *[2]/name() = 'cn' and *[2][./text() = '2'] and *[3]/name() = 'ci' and *[3][./text() = 'k']] and *[3]/name() = 'apply' and *[3][*[1]/name() = 'csymbol' and *[1][./text() = 'superscript'] and *[2]/name() = 'ci' and *[2][./text() = 'k'] and *[3]/name() = 'ci' and *[3][./text() = 'ε']]]]\n" +
34+
"where\n" +
35+
"fn:count($x/*[2]/*[2]/*) = 0\n" +
36+
" and fn:count($x/*[2]/*[3]/*[1]/*) = 0\n" +
37+
" and fn:count($x/*[2]/*[3]/*[2]/*) = 0\n" +
38+
" and fn:count($x/*[2]/*[3]/*) = 2\n" +
39+
" and fn:count($x/*[2]/*) = 3\n" +
40+
" and fn:count($x/*[3]/*[2]/*[1]/*) = 0\n" +
41+
" and fn:count($x/*[3]/*[2]/*[2]/*) = 0\n" +
42+
" and fn:count($x/*[3]/*[2]/*[3]/*) = 0\n" +
43+
" and fn:count($x/*[3]/*[2]/*) = 3\n" +
44+
" and fn:count($x/*[3]/*[3]/*[1]/*) = 0\n" +
45+
" and fn:count($x/*[3]/*[3]/*[2]/*) = 0\n" +
46+
" and fn:count($x/*[3]/*[3]/*[3]/*) = 0\n" +
47+
" and fn:count($x/*[3]/*[3]/*) = 3\n" +
48+
" and fn:count($x/*[3]/*) = 3\n" +
49+
" and fn:count($x/*) = 3\n" +
50+
"\n" +
51+
"return\n" +
52+
"data($m/*[1]/@alttext)", topic.getxQueryExpression());
53+
}
54+
55+
@Test
56+
public void testGetMathMLNode() throws Exception {
57+
assertEquals("http://www.w3.org/1998/Math/MathML", topic.getMathMLNode().getNamespaceURI());
58+
}
5959
}

src/test/java/com/formulasearchengine/mathmlquerygenerator/NtcirTopicReaderTest.java

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,96 +18,96 @@
1818
import static org.junit.Assert.assertEquals;
1919

2020
public class NtcirTopicReaderTest {
21-
public static final String BASEX_NAMESPACE = "declare default element namespace \"http://www.w3.org/1998/Math/MathML\";";
22-
public static final String BASEX_PATHTOROOT = "//*:expr";
23-
public static final String BASEX_RETURNFORMAT = "<a href=\"http://demo.formulasearchengine.com/index.php?curid={$m/@url}\">result</a>";
24-
public static final String WIKIPEDIA_RESOURCE = "jp/ac/nii/Ntcir11MathWikipediaTopicsParticipants.xml";
25-
public static final String ARXIV_RESOURCE = "jp/ac/nii/NTCIR-11-Math-test.xml";
21+
public static final String BASEX_NAMESPACE = "declare default element namespace \"http://www.w3.org/1998/Math/MathML\";";
22+
public static final String BASEX_PATHTOROOT = "//*:expr";
23+
public static final String BASEX_RETURNFORMAT = "<a href=\"http://demo.formulasearchengine.com/index.php?curid={$m/@url}\">result</a>";
24+
public static final String WIKIPEDIA_RESOURCE = "jp/ac/nii/Ntcir11MathWikipediaTopicsParticipants.xml";
25+
public static final String ARXIV_RESOURCE = "jp/ac/nii/NTCIR-11-Math-test.xml";
2626

2727

28-
@Test
29-
public void testExtractPatterns() throws Exception {
30-
assertEquals( "Count in Wikipedia testfile incorrect", 100, countFormulaeInTopics( WIKIPEDIA_RESOURCE ) );
31-
assertEquals( "Count in arXiv testfile incorrect", 55, countFormulaeInTopics( ARXIV_RESOURCE ) );
32-
}
28+
@Test
29+
public void testExtractPatterns() throws Exception {
30+
assertEquals("Count in Wikipedia testfile incorrect", 100, countFormulaeInTopics(WIKIPEDIA_RESOURCE));
31+
assertEquals("Count in arXiv testfile incorrect", 55, countFormulaeInTopics(ARXIV_RESOURCE));
32+
}
3333

34-
private int countFormulaeInTopics( String resourceName ) throws URISyntaxException, IOException, SAXException, ParserConfigurationException, XPathExpressionException {
35-
final List<NtcirPattern> ntcirPatterns = getTopicReader( resourceName ).extractPatterns();
36-
return ntcirPatterns.size();
37-
}
34+
private int countFormulaeInTopics(String resourceName) throws URISyntaxException, IOException, SAXException, ParserConfigurationException, XPathExpressionException {
35+
final List<NtcirPattern> ntcirPatterns = getTopicReader(resourceName).extractPatterns();
36+
return ntcirPatterns.size();
37+
}
3838

39-
private NtcirTopicReader getTopicReader( String resourceName ) throws ParserConfigurationException, IOException, SAXException, URISyntaxException, XPathExpressionException, NullPointerException {
40-
final URL resource = getClass().getClassLoader().getResource(resourceName);
41-
return new NtcirTopicReader( new File( resource.toURI() ) ).setAddQvarMap(false);
42-
}
39+
private NtcirTopicReader getTopicReader(String resourceName) throws ParserConfigurationException, IOException, SAXException, URISyntaxException, XPathExpressionException, NullPointerException {
40+
final URL resource = getClass().getClassLoader().getResource(resourceName);
41+
return new NtcirTopicReader(new File(resource.toURI())).setAddQvarMap(false);
42+
}
4343

44-
public NtcirPattern getFirstTopic() throws URISyntaxException, ParserConfigurationException, SAXException, XPathExpressionException, IOException {
45-
final NtcirTopicReader tr = getTopicReader(WIKIPEDIA_RESOURCE);
46-
return tr.extractPatterns().get(0);
47-
}
44+
public NtcirPattern getFirstTopic() throws URISyntaxException, ParserConfigurationException, SAXException, XPathExpressionException, IOException {
45+
final NtcirTopicReader tr = getTopicReader(WIKIPEDIA_RESOURCE);
46+
return tr.extractPatterns().get(0);
47+
}
4848

49-
@Test
50-
public void checkBaseX() throws Exception {
51-
final String referenceString = getFileContents("jp/ac/nii/basexReferenceQueries.txt");
52-
final NtcirTopicReader tr = getTopicReader( WIKIPEDIA_RESOURCE );
53-
tr.setNamespace(BASEX_NAMESPACE);
54-
tr.setPathToRoot(BASEX_PATHTOROOT);
55-
tr.setReturnFormat(BASEX_RETURNFORMAT);
56-
final StringBuilder sb = new StringBuilder();
57-
for ( final NtcirPattern ntcirPattern : tr.extractPatterns() ) {
58-
sb.append( ntcirPattern.getxQueryExpression() ).append("\n");
59-
}
60-
assertEquals( referenceString, sb.toString() );
49+
@Test
50+
public void checkBaseX() throws Exception {
51+
final String referenceString = getFileContents("jp/ac/nii/basexReferenceQueries.txt");
52+
final NtcirTopicReader tr = getTopicReader(WIKIPEDIA_RESOURCE);
53+
tr.setNamespace(BASEX_NAMESPACE);
54+
tr.setPathToRoot(BASEX_PATHTOROOT);
55+
tr.setReturnFormat(BASEX_RETURNFORMAT);
56+
final StringBuilder sb = new StringBuilder();
57+
for (final NtcirPattern ntcirPattern : tr.extractPatterns()) {
58+
sb.append(ntcirPattern.getxQueryExpression()).append("\n");
59+
}
60+
assertEquals(referenceString, sb.toString());
6161

62-
}
62+
}
6363

64-
@Test
65-
public void checkRecursiveBaseX() throws Exception {
64+
@Test
65+
public void checkRecursiveBaseX() throws Exception {
6666
final String referenceString = getFileContents("jp/ac/nii/basexRecursiveReferenceQueries.txt");
67-
final NtcirTopicReader tr = getTopicReader( WIKIPEDIA_RESOURCE );
68-
tr.setNamespace(BASEX_NAMESPACE);
69-
tr.setPathToRoot(BASEX_PATHTOROOT);
70-
tr.setReturnFormat(BASEX_RETURNFORMAT);
71-
tr.setFindRootApply(true);
72-
final StringBuilder sb = new StringBuilder();
73-
for ( final NtcirPattern ntcirPattern : tr.extractPatterns() ) {
74-
sb.append(ntcirPattern.getxQueryExpression()).append("\n");
75-
}
76-
System.out.println(sb.toString());
77-
assertEquals( referenceString, sb.toString() );
78-
}
67+
final NtcirTopicReader tr = getTopicReader(WIKIPEDIA_RESOURCE);
68+
tr.setNamespace(BASEX_NAMESPACE);
69+
tr.setPathToRoot(BASEX_PATHTOROOT);
70+
tr.setReturnFormat(BASEX_RETURNFORMAT);
71+
tr.setFindRootApply(true);
72+
final StringBuilder sb = new StringBuilder();
73+
for (final NtcirPattern ntcirPattern : tr.extractPatterns()) {
74+
sb.append(ntcirPattern.getxQueryExpression()).append("\n");
75+
}
76+
System.out.println(sb.toString());
77+
assertEquals(referenceString, sb.toString());
78+
}
7979

80-
@Test
81-
public void extractPattern() throws Exception {
82-
final NtcirTopicReader tr = getTopicReader( WIKIPEDIA_RESOURCE );
83-
tr.setNamespace(BASEX_NAMESPACE);
84-
tr.setPathToRoot(BASEX_PATHTOROOT);
85-
tr.setReturnFormat(BASEX_RETURNFORMAT);
86-
for ( final NtcirPattern ntcirPattern : tr.extractPatterns() ) {
87-
if ( ntcirPattern.getNum().endsWith( "29" ) ) {
88-
System.out.println( ntcirPattern.getxQueryExpression() );
89-
}
90-
}
91-
}
80+
@Test
81+
public void extractPattern() throws Exception {
82+
final NtcirTopicReader tr = getTopicReader(WIKIPEDIA_RESOURCE);
83+
tr.setNamespace(BASEX_NAMESPACE);
84+
tr.setPathToRoot(BASEX_PATHTOROOT);
85+
tr.setReturnFormat(BASEX_RETURNFORMAT);
86+
for (final NtcirPattern ntcirPattern : tr.extractPatterns()) {
87+
if (ntcirPattern.getNum().endsWith("29")) {
88+
System.out.println(ntcirPattern.getxQueryExpression());
89+
}
90+
}
91+
}
9292

93-
@Test
94-
public void testSetRestricLength() throws Exception {
95-
final String NoLenghtxQuery = getTopicReader( WIKIPEDIA_RESOURCE ).setRestrictLength( false )
96-
.extractPatterns().get( 0 ).getxQueryExpression();
97-
assertEquals( "declare default element namespace \"http://www.w3.org/1998/Math/MathML\";\n" +
98-
"for $m in db2-fn:xmlcolumn(\"math.math_mathml\") return\n" +
99-
"for $x in $m//*:apply\n" +
100-
"[*[1]/name() = 'gt' and *[2]/name() = 'apply' and *[2][*[1]/name() = 'times' and *[2]/name() = 'ci' and *[2][./text() = 'W'] and *[3]/name() = 'interval' and *[3][*[1]/name() = 'cn' and *[1][./text() = '2'] and *[2]/name() = 'ci' and *[2][./text() = 'k']]] and *[3]/name() = 'apply' and *[3][*[1]/name() = 'divide' and *[2]/name() = 'apply' and *[2][*[1]/name() = 'csymbol' and *[1][./text() = 'superscript'] and *[2]/name() = 'cn' and *[2][./text() = '2'] and *[3]/name() = 'ci' and *[3][./text() = 'k']] and *[3]/name() = 'apply' and *[3][*[1]/name() = 'csymbol' and *[1][./text() = 'superscript'] and *[2]/name() = 'ci' and *[2][./text() = 'k'] and *[3]/name() = 'ci' and *[3][./text() = 'ε']]]]\n\n" +
101-
"return\n" +
102-
"data($m/*[1]/@alttext)", NoLenghtxQuery );
103-
}
93+
@Test
94+
public void testSetRestricLength() throws Exception {
95+
final String NoLenghtxQuery = getTopicReader(WIKIPEDIA_RESOURCE).setRestrictLength(false)
96+
.extractPatterns().get(0).getxQueryExpression();
97+
assertEquals("declare default element namespace \"http://www.w3.org/1998/Math/MathML\";\n" +
98+
"for $m in db2-fn:xmlcolumn(\"math.math_mathml\") return\n" +
99+
"for $x in $m//*:apply\n" +
100+
"[*[1]/name() = 'gt' and *[2]/name() = 'apply' and *[2][*[1]/name() = 'times' and *[2]/name() = 'ci' and *[2][./text() = 'W'] and *[3]/name() = 'interval' and *[3][*[1]/name() = 'cn' and *[1][./text() = '2'] and *[2]/name() = 'ci' and *[2][./text() = 'k']]] and *[3]/name() = 'apply' and *[3][*[1]/name() = 'divide' and *[2]/name() = 'apply' and *[2][*[1]/name() = 'csymbol' and *[1][./text() = 'superscript'] and *[2]/name() = 'cn' and *[2][./text() = '2'] and *[3]/name() = 'ci' and *[3][./text() = 'k']] and *[3]/name() = 'apply' and *[3][*[1]/name() = 'csymbol' and *[1][./text() = 'superscript'] and *[2]/name() = 'ci' and *[2][./text() = 'k'] and *[3]/name() = 'ci' and *[3][./text() = 'ε']]]]\n\n" +
101+
"return\n" +
102+
"data($m/*[1]/@alttext)", NoLenghtxQuery);
103+
}
104104

105-
@Test
106-
public void testAlternativeConstructor() throws Exception{
107-
final URL resource = getClass().getClassLoader().getResource( ARXIV_RESOURCE );
108-
DocumentBuilder documentBuilder = XMLHelper.getDocumentBuilder( true );
109-
Document topics = documentBuilder.parse( new File( resource.toURI() ) );
110-
new NtcirTopicReader( topics );
111-
new NtcirTopicReader( topics, "", "", "", false );
112-
}
105+
@Test
106+
public void testAlternativeConstructor() throws Exception {
107+
final URL resource = getClass().getClassLoader().getResource(ARXIV_RESOURCE);
108+
DocumentBuilder documentBuilder = XMLHelper.getDocumentBuilder(true);
109+
Document topics = documentBuilder.parse(new File(resource.toURI()));
110+
new NtcirTopicReader(topics);
111+
new NtcirTopicReader(topics, "", "", "", false);
112+
}
113113
}

0 commit comments

Comments
 (0)