1
+ import static org .assertj .core .api .Assertions .assertThat ;
1
2
import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
2
- import static org .junit .Assert .assertEquals ;
3
- import static org .junit .Assert .assertNull ;
4
3
5
4
import org .junit .Ignore ;
6
5
import org .junit .Test ;
@@ -14,7 +13,7 @@ public void testEmptyList() throws InvalidRecordsException {
14
13
ArrayList <Record > records = new ArrayList <>();
15
14
16
15
TreeNode root = new BuildTree ().buildTree (records );
17
- assertNull (root );
16
+ assertThat (root ). isNull ( );
18
17
}
19
18
20
19
@ Ignore ("Remove to run test" )
@@ -25,7 +24,7 @@ public void testOneRecord() throws InvalidRecordsException {
25
24
records .add (record );
26
25
27
26
TreeNode root = new BuildTree ().buildTree (records );
28
- assertEquals (root .getNodeId (), 0 );
27
+ assertThat (root .getNodeId ()). isEqualTo ( 0 );
29
28
assertNodeIsLeaf (root );
30
29
}
31
30
@@ -42,9 +41,9 @@ public void testThreeRecordsInOrder() throws InvalidRecordsException {
42
41
assertNodeIsLeaf (root .getChildren ().get (0 ));
43
42
assertNodeIsLeaf (root .getChildren ().get (1 ));
44
43
45
- assertEquals (root .getNodeId (), 0 );
46
- assertEquals (root .getChildren ().get (0 ).getNodeId (), 1 );
47
- assertEquals (root .getChildren ().get (1 ).getNodeId (), 2 );
44
+ assertThat (root .getNodeId ()). isEqualTo ( 0 );
45
+ assertThat (root .getChildren ().get (0 ).getNodeId ()). isEqualTo ( 1 );
46
+ assertThat (root .getChildren ().get (1 ).getNodeId ()). isEqualTo ( 2 );
48
47
}
49
48
50
49
@ Ignore ("Remove to run test" )
@@ -60,9 +59,9 @@ public void testThreeRecordsInReverseOrder() throws InvalidRecordsException {
60
59
assertNodeIsLeaf (root .getChildren ().get (0 ));
61
60
assertNodeIsLeaf (root .getChildren ().get (1 ));
62
61
63
- assertEquals (root .getNodeId (), 0 );
64
- assertEquals (root .getChildren ().get (0 ).getNodeId (), 1 );
65
- assertEquals (root .getChildren ().get (1 ).getNodeId (), 2 );
62
+ assertThat (root .getNodeId ()). isEqualTo ( 0 );
63
+ assertThat (root .getChildren ().get (0 ).getNodeId ()). isEqualTo ( 1 );
64
+ assertThat (root .getChildren ().get (1 ).getNodeId ()). isEqualTo ( 2 );
66
65
}
67
66
68
67
@ Ignore ("Remove to run test" )
@@ -80,10 +79,10 @@ public void testRecordsWithMoreThanTwoChildren() throws InvalidRecordsException
80
79
assertNodeIsLeaf (root .getChildren ().get (1 ));
81
80
assertNodeIsLeaf (root .getChildren ().get (2 ));
82
81
83
- assertEquals (root .getNodeId (), 0 );
84
- assertEquals (root .getChildren ().get (0 ).getNodeId (), 1 );
85
- assertEquals (root .getChildren ().get (1 ).getNodeId (), 2 );
86
- assertEquals (root .getChildren ().get (2 ).getNodeId (), 3 );
82
+ assertThat (root .getNodeId ()). isEqualTo ( 0 );
83
+ assertThat (root .getChildren ().get (0 ).getNodeId ()). isEqualTo ( 1 );
84
+ assertThat (root .getChildren ().get (1 ).getNodeId ()). isEqualTo ( 2 );
85
+ assertThat (root .getChildren ().get (2 ).getNodeId ()). isEqualTo ( 3 );
87
86
88
87
}
89
88
@@ -109,13 +108,13 @@ public void testBinaryTree() throws InvalidRecordsException {
109
108
assertNodeIsLeaf (root .getChildren ().get (1 ).getChildren ().get (0 ));
110
109
assertNodeIsLeaf (root .getChildren ().get (1 ).getChildren ().get (1 ));
111
110
112
- assertEquals (root .getNodeId (), 0 );
113
- assertEquals (root .getChildren ().get (0 ).getNodeId (), 1 );
114
- assertEquals (root .getChildren ().get (1 ).getNodeId (), 2 );
115
- assertEquals (root .getChildren ().get (0 ).getChildren ().get (0 ).getNodeId (), 3 );
116
- assertEquals (root .getChildren ().get (0 ).getChildren ().get (1 ).getNodeId (), 4 );
117
- assertEquals (root .getChildren ().get (1 ).getChildren ().get (0 ).getNodeId (), 5 );
118
- assertEquals (root .getChildren ().get (1 ).getChildren ().get (1 ).getNodeId (), 6 );
111
+ assertThat (root .getNodeId ()). isEqualTo ( 0 );
112
+ assertThat (root .getChildren ().get (0 ).getNodeId ()). isEqualTo ( 1 );
113
+ assertThat (root .getChildren ().get (1 ).getNodeId ()). isEqualTo ( 2 );
114
+ assertThat (root .getChildren ().get (0 ).getChildren ().get (0 ).getNodeId ()). isEqualTo ( 3 );
115
+ assertThat (root .getChildren ().get (0 ).getChildren ().get (1 ).getNodeId ()). isEqualTo ( 4 );
116
+ assertThat (root .getChildren ().get (1 ).getChildren ().get (0 ).getNodeId ()). isEqualTo ( 5 );
117
+ assertThat (root .getChildren ().get (1 ).getChildren ().get (1 ).getNodeId ()). isEqualTo ( 6 );
119
118
}
120
119
121
120
@ Ignore ("Remove to run test" )
@@ -139,13 +138,13 @@ public void testUnbalancedTree() throws InvalidRecordsException {
139
138
assertNodeIsLeaf (root .getChildren ().get (0 ).getChildren ().get (2 ));
140
139
assertNodeIsLeaf (root .getChildren ().get (1 ).getChildren ().get (0 ));
141
140
142
- assertEquals (root .getNodeId (), 0 );
143
- assertEquals (root .getChildren ().get (0 ).getNodeId (), 1 );
144
- assertEquals (root .getChildren ().get (1 ).getNodeId (), 2 );
145
- assertEquals (root .getChildren ().get (0 ).getChildren ().get (0 ).getNodeId (), 3 );
146
- assertEquals (root .getChildren ().get (0 ).getChildren ().get (1 ).getNodeId (), 4 );
147
- assertEquals (root .getChildren ().get (0 ).getChildren ().get (2 ).getNodeId (), 5 );
148
- assertEquals (root .getChildren ().get (1 ).getChildren ().get (0 ).getNodeId (), 6 );
141
+ assertThat (root .getNodeId ()). isEqualTo ( 0 );
142
+ assertThat (root .getChildren ().get (0 ).getNodeId ()). isEqualTo ( 1 );
143
+ assertThat (root .getChildren ().get (1 ).getNodeId ()). isEqualTo ( 2 );
144
+ assertThat (root .getChildren ().get (0 ).getChildren ().get (0 ).getNodeId ()). isEqualTo ( 3 );
145
+ assertThat (root .getChildren ().get (0 ).getChildren ().get (1 ).getNodeId ()). isEqualTo ( 4 );
146
+ assertThat (root .getChildren ().get (0 ).getChildren ().get (2 ).getNodeId ()). isEqualTo ( 5 );
147
+ assertThat (root .getChildren ().get (1 ).getChildren ().get (0 ).getNodeId ()). isEqualTo ( 6 );
149
148
}
150
149
151
150
@ Ignore ("Remove to run test" )
@@ -212,10 +211,10 @@ public void testCycleIndirectly() {
212
211
}
213
212
214
213
private void assertNodeIsLeaf (TreeNode node ) {
215
- assertEquals (node .getChildren ().size (), 0 );
214
+ assertThat (node .getChildren ().size ()). isEqualTo ( 0 );
216
215
}
217
216
218
217
private void assertNodeIsBranchWithNNumberOfChildren (TreeNode node , int childrenCount ) {
219
- assertEquals (node .getChildren ().size (), childrenCount );
218
+ assertThat (node .getChildren ().size ()). isEqualTo ( childrenCount );
220
219
}
221
220
}
0 commit comments