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,11 +15,10 @@
package google.registry.rdap;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.request.HttpException.UnprocessableEntityException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -27,9 +26,6 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RdapSearchPatternTest {
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Test
public void testNoWildcards_ok() throws Exception {
RdapSearchPattern rdapSearchPattern = RdapSearchPattern.create("example.lol", true);
@ -56,20 +52,19 @@ public class RdapSearchPatternTest {
@Test
public void testMultipleWildcards_unprocessable() throws Exception {
thrown.expect(UnprocessableEntityException.class);
RdapSearchPattern.create("ex*am*.lol", true);
assertThrows(
UnprocessableEntityException.class, () -> RdapSearchPattern.create("ex*am*.lol", true));
}
@Test
public void testWildcardNotAtEnd_unprocessable() throws Exception {
thrown.expect(UnprocessableEntityException.class);
RdapSearchPattern.create("ex*am", true);
assertThrows(UnprocessableEntityException.class, () -> RdapSearchPattern.create("ex*am", true));
}
@Test
public void testWildcardNotAtEndWithTld_unprocessable() throws Exception {
thrown.expect(UnprocessableEntityException.class);
RdapSearchPattern.create("ex*am.lol", true);
assertThrows(
UnprocessableEntityException.class, () -> RdapSearchPattern.create("ex*am.lol", true));
}
@Test
@ -82,14 +77,14 @@ public class RdapSearchPatternTest {
@Test
public void testZeroLengthSuffix_unprocessable() throws Exception {
thrown.expect(UnprocessableEntityException.class);
RdapSearchPattern.create("exam*.", true);
assertThrows(
UnprocessableEntityException.class, () -> RdapSearchPattern.create("exam*.", true));
}
@Test
public void testDisallowedSuffix_unprocessable() throws Exception {
thrown.expect(UnprocessableEntityException.class);
RdapSearchPattern.create("exam*.lol", false);
assertThrows(
UnprocessableEntityException.class, () -> RdapSearchPattern.create("exam*.lol", false));
}
@Test