mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02: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:
parent
36ad38e5df
commit
7dc224627f
125 changed files with 1970 additions and 1982 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue