1 package org.apache.maven.doxia.index;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.TestCase;
23
24
25
26
27
28 public class IndexEntryTest
29 extends TestCase
30 {
31
32
33
34 public void testIndexEntry()
35 {
36 IndexEntry root = new IndexEntry( null );
37
38 assertIndexEntry( root, null, 0, null, null );
39
40
41
42
43
44 IndexEntry chapter1 = new IndexEntry( root, "chapter-1" );
45
46 assertIndexEntry( root, null, 1, null, null );
47
48 assertIndexEntry( chapter1, root, 0, null, null );
49
50
51
52
53
54 IndexEntry chapter2 = new IndexEntry( root, "chapter-2" );
55
56 assertIndexEntry( root, null, 2, null, null );
57
58 assertIndexEntry( chapter1, root, 0, null, chapter2 );
59 assertIndexEntry( chapter2, root, 0, chapter1, null );
60
61 chapter2.setTitle( "Title 2" );
62 assertTrue( chapter2.toString().contains( "Title 2" ) );
63 }
64
65 private void assertIndexEntry( IndexEntry entry, IndexEntry parent, int childCount,
66 IndexEntry prevEntry, IndexEntry nextEntry )
67 {
68 assertEquals( parent, entry.getParent() );
69
70 assertEquals( childCount, entry.getChildEntries().size() );
71
72 assertEquals( prevEntry, entry.getPrevEntry() );
73
74 assertEquals( nextEntry, entry.getNextEntry() );
75 }
76 }