Skip to content

Commit 4557807

Browse files
author
Eugen Paraschiv
committed
testing work for guava ordering
1 parent e8a904d commit 4557807

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.baeldung.guava.collections;
2+
3+
import java.util.Arrays;
4+
import java.util.Collections;
5+
import java.util.List;
6+
7+
import org.junit.Test;
8+
9+
import com.google.common.collect.Ordering;
10+
11+
public class GuavaOrderingExamplesTest {
12+
13+
// tests
14+
15+
@Test
16+
public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() {
17+
final List<Integer> nums = Arrays.asList(3, 5, 4, null, 1, 2);
18+
Collections.sort(nums, Ordering.natural().nullsLast());
19+
System.out.println(nums);
20+
}
21+
22+
@Test
23+
public final void givenCollectionWithNulls_whenSortingWithNullsFirst_thenNullsAreFirst() {
24+
final List<Integer> nums = Arrays.asList(3, 5, 4, null, 1, 2);
25+
Collections.sort(nums, Ordering.natural().nullsFirst());
26+
System.out.println(nums);
27+
}
28+
29+
}

0 commit comments

Comments
 (0)