Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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,7 +23,7 @@ import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
/**
|
||||
* Test for {@link ComparableComparator}.
|
||||
* Test for {@link CompoundComparator}.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Chris Beams
|
||||
@@ -36,7 +36,7 @@ public class CompoundComparatorTests {
|
||||
|
||||
@Test
|
||||
public void shouldNeedAtLeastOneComparator() {
|
||||
Comparator<String> c = new CompoundComparator<String>();
|
||||
Comparator<String> c = new CompoundComparator<>();
|
||||
thrown.expect(IllegalStateException.class);
|
||||
c.compare("foo", "bar");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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,33 +30,31 @@ import static org.junit.Assert.*;
|
||||
* @author Chris Beams
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
||||
public class InvertibleComparatorTests {
|
||||
|
||||
private Comparator<Integer> comparator = new ComparableComparator<Integer>();
|
||||
private final Comparator<Integer> comparator = new ComparableComparator<>();
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void shouldNeedComparator() throws Exception {
|
||||
new InvertibleComparator<Object>(null);
|
||||
new InvertibleComparator<>(null);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void shouldNeedComparatorWithAscending() throws Exception {
|
||||
new InvertibleComparator<Object>(null, true);
|
||||
new InvertibleComparator<>(null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDefaultToAscending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<Integer>(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<Integer>(comparator);
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator);
|
||||
assertThat(invertibleComparator.isAscending(), is(true));
|
||||
assertThat(invertibleComparator.compare(1, 2), is(-1));
|
||||
invertibleComparator.invertOrder();
|
||||
@@ -66,15 +64,13 @@ public class InvertibleComparatorTests {
|
||||
|
||||
@Test
|
||||
public void shouldCompareAscending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<Integer>(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<Integer>(comparator, false);
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator, false);
|
||||
assertThat(invertibleComparator.compare(1, 2), is(1));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user