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,14 +15,13 @@
package google.registry.tmch;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableList;
import google.registry.tmch.LordnLog.Result;
import java.util.Map.Entry;
import org.joda.time.DateTime;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -30,9 +29,6 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class LordnLogTest {
@Rule
public final ExpectedException thrown = ExpectedException.none();
public static final ImmutableList<String> EXAMPLE_FROM_RFC =
ImmutableList.of(
"1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,"
@ -89,29 +85,33 @@ public class LordnLogTest {
@Test
public void testFailure_noDnLineMismatch() throws Exception {
thrown.expect(IllegalArgumentException.class);
LordnLog.parse(ImmutableList.of(
"1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,1",
"roid,result-code"));
assertThrows(
IllegalArgumentException.class,
() ->
LordnLog.parse(
ImmutableList.of(
"1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,1",
"roid,result-code")));
}
@Test
public void testFailure_parseNull() throws Exception {
thrown.expect(NullPointerException.class);
LordnLog.parse(null);
assertThrows(NullPointerException.class, () -> LordnLog.parse(null));
}
@Test
public void testFailure_parseEmpty() throws Exception {
thrown.expect(Exception.class);
LordnLog.parse(ImmutableList.of());
assertThrows(Exception.class, () -> LordnLog.parse(ImmutableList.of()));
}
@Test
public void testFailure_parseMissingHeaderLine() throws Exception {
thrown.expect(Exception.class);
LordnLog.parse(ImmutableList.of(
"1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,0"));
assertThrows(
Exception.class,
() ->
LordnLog.parse(
ImmutableList.of(
"1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,0")));
}
@Test