55import java .util .Collections ;
66import java .util .List ;
77
8- import static org .junit . Assert . assertEquals ;
8+ import static org .assertj . core . api . Assertions . assertThat ;
99
1010public class ListOpsTest {
1111
1212 @ Test
1313 public void testAppendingEmptyLists () {
14- assertEquals (
15- Collections .emptyList (),
16- ListOps .append (Collections .emptyList (), Collections .emptyList ())
17- );
14+ assertThat (ListOps .append (Collections .emptyList (), Collections .emptyList ())).isEmpty ();
1815 }
1916
2017 @ Ignore ("Remove to run test" )
2118 @ Test
2219 public void testAppendingListToEmptyList () {
23- assertEquals (
24- Arrays .asList ('1' , '2' , '3' , '4' ),
25- ListOps .append (Collections .emptyList (), Arrays .asList ('1' , '2' , '3' , '4' ))
26- );
20+ assertThat (ListOps .append (Collections .emptyList (), Arrays .asList ('1' , '2' , '3' , '4' )))
21+ .containsExactly ('1' , '2' , '3' , '4' );
2722 }
2823
2924 @ Ignore ("Remove to run test" )
3025 @ Test
3126 public void testAppendingNonEmptyLists () {
32- assertEquals (
33- Arrays .asList ("1" , "2" , "2" , "3" , "4" , "5" ),
34- ListOps .append (Arrays .asList ("1" , "2" ), Arrays .asList ("2" , "3" , "4" , "5" ))
35- );
27+ assertThat (ListOps .append (Arrays .asList ("1" , "2" ), Arrays .asList ("2" , "3" , "4" , "5" )))
28+ .containsExactly ("1" , "2" , "2" , "3" , "4" , "5" );
3629 }
3730
3831 @ Ignore ("Remove to run test" )
3932 @ Test
4033 public void testConcatEmptyList () {
41- assertEquals (
42- Collections .emptyList (),
43- ListOps .concat (Collections .emptyList ())
44- );
34+ assertThat (ListOps .concat (Collections .emptyList ())).isEmpty ();
4535 }
4636
4737 @ Ignore ("Remove to run test" )
@@ -54,10 +44,7 @@ public void testConcatListOfLists() {
5444 Arrays .asList ('4' , '5' , '6' )
5545 );
5646
57- assertEquals (
58- Arrays .asList ('1' , '2' , '3' , '4' , '5' , '6' ),
59- ListOps .concat (listOfLists )
60- );
47+ assertThat (ListOps .concat (listOfLists )).containsExactly ('1' , '2' , '3' , '4' , '5' , '6' );
6148 }
6249
6350 @ Ignore ("Remove to run test" )
@@ -79,160 +66,131 @@ public void testConcatListOfNestedLists() {
7966 )
8067 );
8168
82- assertEquals (
83- Arrays . asList (
69+ assertThat ( ListOps . concat ( listOfNestedLists ))
70+ . containsExactly (
8471 Collections .singletonList ('1' ),
8572 Collections .singletonList ('2' ),
8673 Collections .singletonList ('3' ),
8774 Collections .emptyList (),
88- Arrays .asList ('4' , '5' , '6' )
89- ),
90- ListOps .concat (listOfNestedLists )
91- );
75+ Arrays .asList ('4' , '5' , '6' ));
9276 }
9377
9478 @ Ignore ("Remove to run test" )
9579 @ Test
9680 public void testFilteringEmptyList () {
97- assertEquals (
98- Collections .emptyList (),
99- ListOps .filter (Collections .<Integer >emptyList (), integer -> integer % 2 == 1 )
100- );
81+ assertThat (ListOps .filter (Collections .<Integer >emptyList (), integer -> integer % 2 == 1 ))
82+ .isEmpty ();
10183 }
10284
10385 @ Ignore ("Remove to run test" )
10486 @ Test
10587 public void testFilteringNonEmptyList () {
106- assertEquals (
107- Arrays .asList (1 , 3 , 5 ),
108- ListOps .filter (Arrays .asList (1 , 2 , 3 , 5 ), integer -> integer % 2 == 1 )
109- );
88+ assertThat (ListOps .filter (Arrays .asList (1 , 2 , 3 , 5 ), integer -> integer % 2 == 1 ))
89+ .containsExactly (1 , 3 , 5 );
11090 }
11191
11292 @ Ignore ("Remove to run test" )
11393 @ Test
11494 public void testSizeOfEmptyList () {
115- assertEquals ( 0 , ListOps .size (Collections .emptyList ()));
95+ assertThat ( ListOps .size (Collections .emptyList ())). isEqualTo ( 0 );
11696 }
11797
11898 @ Ignore ("Remove to run test" )
11999 @ Test
120100 public void testSizeOfNonEmptyList () {
121- assertEquals ( 4 , ListOps .size (Arrays .asList ("one" , "two" , "three" , "four" )));
101+ assertThat ( ListOps .size (Arrays .asList ("one" , "two" , "three" , "four" ))). isEqualTo ( 4 );
122102 }
123103
124104 @ Ignore ("Remove to run test" )
125105 @ Test
126106 public void testTransformingEmptyList () {
127- assertEquals (
128- Collections .emptyList (),
129- ListOps .map (Collections .<Integer >emptyList (), integer -> integer + 1 )
130- );
107+ assertThat (ListOps .map (Collections .<Integer >emptyList (), integer -> integer + 1 )).isEmpty ();
131108 }
132109
133110 @ Ignore ("Remove to run test" )
134111 @ Test
135112 public void testTransformingNonEmptyList () {
136- assertEquals (
137- Arrays .asList (2 , 4 , 6 , 8 ),
138- ListOps .map (Arrays .asList (1 , 3 , 5 , 7 ), integer -> integer + 1 )
139- );
113+ assertThat (ListOps .map (Arrays .asList (1 , 3 , 5 , 7 ), integer -> integer + 1 ))
114+ .containsExactly (2 , 4 , 6 , 8 );
140115 }
141116
142117 @ Ignore ("Remove to run test" )
143118 @ Test
144119 public void testFoldLeftEmptyList () {
145- assertEquals (
146- new Double (2.0 ), // Boxing required for method overload disambiguation.
120+ assertThat (
147121 ListOps .foldLeft (
148122 Collections .<Double >emptyList (),
149123 2.0 ,
150- (x , y ) -> x * y
151- )
152- );
124+ (x , y ) -> x * y ))
125+ .isEqualTo (2.0 );
153126 }
154127
155128 @ Ignore ("Remove to run test" )
156129 @ Test
157130 public void testFoldLeftDirectionIndependentFunctionAppliedToNonEmptyList () {
158- assertEquals (
159- new Integer (15 ), // Boxing required for method overload disambiguation.
131+ assertThat (
160132 ListOps .foldLeft (
161133 Arrays .asList (1 , 2 , 3 , 4 ),
162134 5 ,
163- (x , y ) -> x + y
164- )
165- );
135+ (x , y ) -> x + y ))
136+ .isEqualTo (15 );
166137 }
167138
168139 @ Ignore ("Remove to run test" )
169140 @ Test
170141 public void testFoldLeftDirectionDependentFunctionAppliedToNonEmptyList () {
171- assertEquals (
172- new Integer (0 ), // Boxing required for method overload disambiguation.
142+ assertThat (
173143 ListOps .foldLeft (
174144 Arrays .asList (2 , 5 ),
175145 5 ,
176- (x , y ) -> x / y
177- )
178- );
146+ (x , y ) -> x / y ))
147+ .isEqualTo (0 );
179148 }
180149
181150 @ Ignore ("Remove to run test" )
182151 @ Test
183152 public void testFoldRightEmptyList () {
184- assertEquals (
185- new Double (2.0 ), // Boxing required for method overload disambiguation.
153+ assertThat (
186154 ListOps .foldRight (
187155 Collections .<Double >emptyList (),
188156 2.0 ,
189- (x , y ) -> x * y
190- )
191- );
157+ (x , y ) -> x * y ))
158+ .isEqualTo (2.0 );
192159 }
193160
194161 @ Ignore ("Remove to run test" )
195162 @ Test
196163 public void testFoldRightDirectionIndependentFunctionAppliedToNonEmptyList () {
197- assertEquals (
198- new Integer (15 ), // Boxing required for method overload disambiguation.
164+ assertThat (
199165 ListOps .foldRight (
200166 Arrays .asList (1 , 2 , 3 , 4 ),
201167 5 ,
202- (x , y ) -> x + y
203- )
204- );
168+ (x , y ) -> x + y ))
169+ .isEqualTo (15 );
205170 }
206171
207172 @ Ignore ("Remove to run test" )
208173 @ Test
209174 public void testFoldRightDirectionDependentFunctionAppliedToNonEmptyList () {
210- assertEquals (
211- new Integer (2 ), // Boxing required for method overload disambiguation.
175+ assertThat (
212176 ListOps .foldRight (
213177 Arrays .asList (2 , 5 ),
214178 5 ,
215- (x , y ) -> x / y
216- )
217- );
179+ (x , y ) -> x / y ))
180+ .isEqualTo (2 );
218181 }
219182
220183 @ Ignore ("Remove to run test" )
221184 @ Test
222185 public void testReversingEmptyList () {
223- assertEquals (
224- Collections .emptyList (),
225- ListOps .reverse (Collections .emptyList ())
226- );
186+ assertThat (ListOps .reverse (Collections .emptyList ())).isEmpty ();
227187 }
228188
229189 @ Ignore ("Remove to run test" )
230190 @ Test
231191 public void testReversingNonEmptyList () {
232- assertEquals (
233- Arrays .asList ('7' , '5' , '3' , '1' ),
234- ListOps .reverse (Arrays .asList ('1' , '3' , '5' , '7' ))
235- );
192+ assertThat (ListOps .reverse (Arrays .asList ('1' , '3' , '5' , '7' )))
193+ .containsExactly ('7' , '5' , '3' , '1' );
236194 }
237195
238196 @ Ignore ("Remove to run test" )
@@ -245,15 +203,12 @@ public void testReversingListOfListIsNotFlattened() {
245203 Arrays .asList ('4' , '5' , '6' )
246204 );
247205
248- assertEquals (
249- Arrays . asList (
206+ assertThat ( ListOps . reverse ( listOfLists ))
207+ . containsExactly (
250208 Arrays .asList ('4' , '5' , '6' ),
251209 Collections .emptyList (),
252210 Collections .singletonList ('3' ),
253- Arrays .asList ('1' , '2' )
254- ),
255- ListOps .reverse (listOfLists )
256- );
211+ Arrays .asList ('1' , '2' ));
257212 }
258213
259214}
0 commit comments