Automatically refactor more exception testing to use new JUnit rules

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178911894
This commit is contained in:
mcilwain 2017-08-14 09:20:03 -04:00 committed by Ben McIlwain
parent 36ad38e5df
commit 7dc224627f
125 changed files with 1970 additions and 1982 deletions

View file

@ -15,6 +15,7 @@
package google.registry.util;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.util.CollectionUtils.nullToEmpty;
import static google.registry.util.CollectionUtils.partitionMap;
@ -22,9 +23,7 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -32,9 +31,6 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class CollectionUtilsTest {
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Test
public void testNullToEmptyMap_leavesNonNullAlone() {
Map<String, Integer> map = ImmutableMap.of("hello", 1);
@ -65,14 +61,12 @@ public class CollectionUtilsTest {
@Test
public void testPartitionMap_negativePartitionSize() {
thrown.expect(IllegalArgumentException.class);
partitionMap(ImmutableMap.of("A", "b"), -2);
assertThrows(IllegalArgumentException.class, () -> partitionMap(ImmutableMap.of("A", "b"), -2));
}
@Test
public void testPartitionMap_nullMap() {
thrown.expect(NullPointerException.class);
partitionMap(null, 100);
assertThrows(NullPointerException.class, () -> partitionMap(null, 100));
}
@Test