1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.syntax

File SyntaxTest.java

 

Code metrics

0
23
5
1
86
49
5
0.22
4.6
5
1

Classes

Class Line # Actions
SyntaxTest 32 23 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 5 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.syntax;
21   
22    import org.junit.Test;
23   
24    import static org.junit.Assert.*;
25   
26    /**
27    * Unit tests for {@link org.xwiki.rendering.syntax.Syntax}.
28    *
29    * @version $Id: 31e2cfa428e3ae4554a0f9e3838a34a9b24a599c $
30    * @since 1.5M2
31    */
 
32    public class SyntaxTest
33    {
 
34  1 toggle @Test
35    public void testEquality()
36    {
37  1 Syntax syntax1 = new Syntax(new SyntaxType("mytype", "My Type"), "1.0");
38  1 Syntax syntax2 = new Syntax(new SyntaxType("mytype", "My Type"), "1.0");
39  1 Syntax syntax3 = new Syntax(new SyntaxType("mytype", "Still same type"), "1.0");
40   
41  1 assertEquals("mytype", syntax1.getType().getId());
42  1 assertEquals("My Type", syntax1.getType().getName());
43   
44  1 assertEquals(syntax2, syntax1);
45    // The syntax type name is not part of the equality test.
46  1 assertEquals(syntax3, syntax1);
47    }
48   
 
49  1 toggle @Test
50    public void testNonEquality()
51    {
52  1 Syntax syntax1 = new Syntax(SyntaxType.XWIKI, "1.0");
53  1 Syntax syntax2 = new Syntax(SyntaxType.XWIKI, "2.0");
54  1 Syntax syntax3 = new Syntax(SyntaxType.CONFLUENCE, "1.0");
55   
56  1 assertFalse(syntax2.equals(syntax1));
57  1 assertFalse(syntax3.equals(syntax1));
58    }
59   
 
60  1 toggle @Test
61    public void testToString()
62    {
63  1 Syntax syntax = new Syntax(SyntaxType.XWIKI, "1.0");
64  1 assertEquals("XWiki 1.0", syntax.toString());
65  1 assertEquals("xwiki/1.0", syntax.toIdString());
66    }
67   
 
68  1 toggle @Test
69    public void getWellKnownSyntaxes()
70    {
71  1 assertEquals(18, SyntaxType.getSyntaxTypes().size());
72  1 assertEquals(new SyntaxType("xwiki", "XWiki"), SyntaxType.getSyntaxTypes().get("xwiki"));
73    }
74   
 
75  1 toggle @Test
76    public void comparisons()
77    {
78  1 Syntax syntax1 = new Syntax(new SyntaxType("mytype1", "BBB"), "1.0");
79  1 Syntax syntax2 = new Syntax(new SyntaxType("mytype2", "AAA"), "1.0");
80  1 Syntax syntax3 = new Syntax(new SyntaxType("mytype3", "BBB"), "1.1");
81   
82  1 assertEquals(0, syntax1.compareTo(syntax1));
83  1 assertTrue(syntax1.compareTo(syntax2) > 0);
84  1 assertTrue(syntax3.compareTo(syntax1) > 0);
85    }
86    }