Automatically refactor more exception testing to use new JUnit rules

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179072309
This commit is contained in:
mcilwain 2017-12-14 11:40:04 -08:00 committed by Ben McIlwain
parent d5d29959b4
commit 9157930983
100 changed files with 3900 additions and 3192 deletions

View file

@ -18,6 +18,7 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.loadRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@ -101,23 +102,20 @@ public class DomainClaimsCheckFlowTest
@Test
public void testFailure_TooManyIds() throws Exception {
setEppInput("domain_check_claims_51.xml");
thrown.expect(TooManyResourceChecksException.class);
runFlow();
assertThrows(TooManyResourceChecksException.class, () -> runFlow());
}
@Test
public void testFailure_tldDoesntExist() throws Exception {
setEppInput("domain_check_claims_bad_tld.xml");
thrown.expect(TldDoesNotExistException.class);
runFlow();
assertThrows(TldDoesNotExistException.class, () -> runFlow());
}
@Test
public void testFailure_notAuthorizedForTld() throws Exception {
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -138,8 +136,7 @@ public class DomainClaimsCheckFlowTest
createTld("tld", TldState.PREDELEGATION);
persistResource(Registry.get("tld").asBuilder().build());
setEppInput("domain_check_claims.xml");
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -147,8 +144,7 @@ public class DomainClaimsCheckFlowTest
createTld("tld", TldState.SUNRISE);
persistResource(Registry.get("tld").asBuilder().build());
setEppInput("domain_check_claims.xml");
thrown.expect(DomainClaimsCheckNotAllowedInSunrise.class);
runFlow();
assertThrows(DomainClaimsCheckNotAllowedInSunrise.class, () -> runFlow());
}
@Test
@ -158,8 +154,7 @@ public class DomainClaimsCheckFlowTest
persistResource(
Registry.get("tld2").asBuilder().setClaimsPeriodEnd(clock.nowUtc().minusMillis(1)).build());
setEppInput("domain_check_claims_multiple_tlds.xml");
thrown.expect(ClaimsPeriodEndedException.class);
runFlow();
assertThrows(ClaimsPeriodEndedException.class, () -> runFlow());
}
@Test