mirror of
https://github.com/google/nomulus
synced 2026-09-06 16:17:13 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user