testing work for guava ordering

This commit is contained in:
Eugen Paraschiv 2013-10-24 18:14:07 +03:00
parent e8a904de20
commit 4557807f00
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package org.baeldung.guava.collections;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import com.google.common.collect.Ordering;
public class GuavaOrderingExamplesTest {
// tests
@Test
public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() {
final List<Integer> nums = Arrays.asList(3, 5, 4, null, 1, 2);
Collections.sort(nums, Ordering.natural().nullsLast());
System.out.println(nums);
}
@Test
public final void givenCollectionWithNulls_whenSortingWithNullsFirst_thenNullsAreFirst() {
final List<Integer> nums = Arrays.asList(3, 5, 4, null, 1, 2);
Collections.sort(nums, Ordering.natural().nullsFirst());
System.out.println(nums);
}
}