Avoid deprecated comparators in tests
Issue: SPR-14779
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,12 +23,13 @@ import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
/**
|
||||
* Test for {@link ComparableComparator}.
|
||||
* Test for {@link CompoundComparator}.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Chris Beams
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Deprecated
|
||||
public class CompoundComparatorTests {
|
||||
|
||||
@Rule
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,10 +30,11 @@ import static org.junit.Assert.*;
|
||||
* @author Chris Beams
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public class InvertibleComparatorTests {
|
||||
|
||||
private Comparator<Integer> comparator = new ComparableComparator<>();
|
||||
private final Comparator<Integer> comparator = new ComparableComparator<>();
|
||||
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void shouldNeedComparator() throws Exception {
|
||||
@@ -47,16 +48,14 @@ public class InvertibleComparatorTests {
|
||||
|
||||
@Test
|
||||
public void shouldDefaultToAscending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<>(comparator);
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator);
|
||||
assertThat(invertibleComparator.isAscending(), is(true));
|
||||
assertThat(invertibleComparator.compare(1, 2), is(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldInvert() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<>(comparator);
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator);
|
||||
assertThat(invertibleComparator.isAscending(), is(true));
|
||||
assertThat(invertibleComparator.compare(1, 2), is(-1));
|
||||
invertibleComparator.invertOrder();
|
||||
@@ -66,15 +65,13 @@ public class InvertibleComparatorTests {
|
||||
|
||||
@Test
|
||||
public void shouldCompareAscending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<>(comparator, true);
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator, true);
|
||||
assertThat(invertibleComparator.compare(1, 2), is(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCompareDescending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<>(comparator, false);
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator, false);
|
||||
assertThat(invertibleComparator.compare(1, 2), is(1));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user