mirror of
https://github.com/google/nomulus.git
synced 2025-07-25 20:18:34 +02:00
Get rid of custom ExceptionRule methods
The only remaining methods on ExceptionRule after this are methods that also exist on ExpectedException, which will allow us to, in the next CL, swap out the one for the other and then run the automated refactoring to turn it all into assertThrows/expectThrows. Note that there were some assertions about root causes that couldn't easily be turned into ExpectedException invocations, so I simply converted them directly to usages of assertThrows/expectThrows. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=178623431
This commit is contained in:
parent
68a26f5b6e
commit
b825a2b5a8
144 changed files with 1176 additions and 894 deletions
|
@ -182,8 +182,8 @@ public class BillingEventTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_syntheticFlagWithoutCreationTime() {
|
||||
thrown.expect(
|
||||
IllegalStateException.class,
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage(
|
||||
"Synthetic creation time must be set if and only if the SYNTHETIC flag is set.");
|
||||
oneTime.asBuilder()
|
||||
.setFlags(ImmutableSet.of(BillingEvent.Flag.SYNTHETIC))
|
||||
|
@ -193,8 +193,8 @@ public class BillingEventTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_syntheticCreationTimeWithoutFlag() {
|
||||
thrown.expect(
|
||||
IllegalStateException.class,
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage(
|
||||
"Synthetic creation time must be set if and only if the SYNTHETIC flag is set");
|
||||
oneTime.asBuilder()
|
||||
.setSyntheticCreationTime(now.plusDays(10))
|
||||
|
@ -203,8 +203,8 @@ public class BillingEventTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_syntheticFlagWithoutCancellationMatchingKey() {
|
||||
thrown.expect(
|
||||
IllegalStateException.class,
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage(
|
||||
"Cancellation matching billing event must be set if and only if the SYNTHETIC flag is set");
|
||||
oneTime.asBuilder()
|
||||
.setFlags(ImmutableSet.of(BillingEvent.Flag.SYNTHETIC))
|
||||
|
@ -214,8 +214,8 @@ public class BillingEventTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_cancellationMatchingKeyWithoutFlag() {
|
||||
thrown.expect(
|
||||
IllegalStateException.class,
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage(
|
||||
"Cancellation matching billing event must be set if and only if the SYNTHETIC flag is set");
|
||||
oneTime.asBuilder()
|
||||
.setCancellationMatchingBillingEvent(Key.create(recurring))
|
||||
|
@ -250,7 +250,8 @@ public class BillingEventTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_cancellation_forGracePeriodWithoutBillingEvent() {
|
||||
thrown.expect(IllegalArgumentException.class, "grace period without billing event");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("grace period without billing event");
|
||||
BillingEvent.Cancellation.forGracePeriod(
|
||||
GracePeriod.createWithoutBillingEvent(
|
||||
GracePeriodStatus.REDEMPTION,
|
||||
|
@ -262,13 +263,15 @@ public class BillingEventTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_cancellationWithNoBillingEvent() {
|
||||
thrown.expect(IllegalStateException.class, "exactly one billing event");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("exactly one billing event");
|
||||
cancellationOneTime.asBuilder().setOneTimeEventKey(null).setRecurringEventKey(null).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cancellationWithBothBillingEvents() {
|
||||
thrown.expect(IllegalStateException.class, "exactly one billing event");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("exactly one billing event");
|
||||
cancellationOneTime.asBuilder()
|
||||
.setOneTimeEventKey(Key.create(oneTime))
|
||||
.setRecurringEventKey(Key.create(recurring))
|
||||
|
|
|
@ -100,7 +100,8 @@ public final class RegistrarBillingEntryTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testBadTimeOrdering_causesError() throws Exception {
|
||||
thrown.expect(IllegalStateException.class, "Created timestamp not after previous");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("Created timestamp not after previous");
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(
|
||||
new RegistrarBillingEntry.Builder()
|
||||
|
@ -120,7 +121,8 @@ public final class RegistrarBillingEntryTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testRegistrarMismatch_causesError() throws Exception {
|
||||
thrown.expect(IllegalStateException.class, "Parent not same as previous");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("Parent not same as previous");
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(
|
||||
new RegistrarBillingEntry.Builder()
|
||||
|
@ -160,7 +162,8 @@ public final class RegistrarBillingEntryTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testZeroAmount_causesError() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Amount can't be zero");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Amount can't be zero");
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(null)
|
||||
.setParent(loadRegistrar("NewRegistrar"))
|
||||
|
|
|
@ -81,20 +81,23 @@ public class RegistrarCreditTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_missingTld() throws Exception {
|
||||
thrown.expect(NullPointerException.class, "tld");
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("tld");
|
||||
promoCredit.asBuilder().setTld(null).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_NonexistentTld() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "example");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("example");
|
||||
promoCredit.asBuilder().setTld("example").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_CurrencyDoesNotMatchTldCurrency() throws Exception {
|
||||
assertThat(Registry.get("tld").getCurrency()).isEqualTo(USD);
|
||||
thrown.expect(IllegalArgumentException.class, "currency");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("currency");
|
||||
promoCredit.asBuilder().setTld("tld").setCurrency(JPY).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,50 +74,54 @@ public class CursorTest extends EntityTestCase {
|
|||
clock.advanceOneMilli();
|
||||
final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z");
|
||||
final DomainResource domain = persistActiveDomain("notaregistry.tld");
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "Class required for cursor does not match scope class");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Class required for cursor does not match scope class");
|
||||
ofy().transact(() -> ofy().save().entity(Cursor.create(RDE_UPLOAD, time, domain)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidScopeOnKeyCreate() throws Exception {
|
||||
createTld("tld");
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "Class required for cursor does not match scope class");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Class required for cursor does not match scope class");
|
||||
Cursor.createKey(RDE_UPLOAD, persistActiveDomain("notaregistry.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_createGlobalKeyForScopedCursorType() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Cursor type is not a global cursor");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Cursor type is not a global cursor");
|
||||
Cursor.createGlobalKey(RDE_UPLOAD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidScopeOnGlobalKeyCreate() throws Exception {
|
||||
createTld("tld");
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "Class required for cursor does not match scope class");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Class required for cursor does not match scope class");
|
||||
Cursor.createKey(RECURRING_BILLING, persistActiveDomain("notaregistry.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nullScope() throws Exception {
|
||||
thrown.expect(NullPointerException.class, "Cursor scope cannot be null");
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("Cursor scope cannot be null");
|
||||
Cursor.create(RECURRING_BILLING, START_OF_TIME, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nullCursorType() throws Exception {
|
||||
createTld("tld");
|
||||
thrown.expect(NullPointerException.class, "Cursor type cannot be null");
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("Cursor type cannot be null");
|
||||
Cursor.create(null, START_OF_TIME, Registry.get("tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nullTime() throws Exception {
|
||||
createTld("tld");
|
||||
thrown.expect(NullPointerException.class, "Cursor time cannot be null");
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("Cursor time cannot be null");
|
||||
Cursor.create(RDE_UPLOAD, null, Registry.get("tld"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,8 @@ public class ContactResourceTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testSetCreationTime_cantBeCalledTwice() {
|
||||
thrown.expect(IllegalStateException.class, "creationTime can only be set once");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("creationTime can only be set once");
|
||||
contactResource.asBuilder().setCreationTime(END_OF_TIME);
|
||||
}
|
||||
|
||||
|
|
|
@ -445,15 +445,15 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_uppercaseDomainName() {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "Domain name must be in puny-coded, lower-case form");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Domain name must be in puny-coded, lower-case form");
|
||||
domain.asBuilder().setFullyQualifiedDomainName("AAA.BBB");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_utf8DomainName() {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "Domain name must be in puny-coded, lower-case form");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Domain name must be in puny-coded, lower-case form");
|
||||
domain.asBuilder().setFullyQualifiedDomainName("みんな.みんな");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,13 +96,15 @@ public class GracePeriodTest {
|
|||
|
||||
@Test
|
||||
public void testFailure_forBillingEvent_autoRenew() {
|
||||
thrown.expect(IllegalArgumentException.class, "autorenew");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("autorenew");
|
||||
GracePeriod.forBillingEvent(GracePeriodStatus.AUTO_RENEW, onetime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_createForRecurring_notAutoRenew() {
|
||||
thrown.expect(IllegalArgumentException.class, "autorenew");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("autorenew");
|
||||
GracePeriod.createForRecurring(
|
||||
GracePeriodStatus.RENEW,
|
||||
now.plusDays(1),
|
||||
|
|
|
@ -163,15 +163,15 @@ public class HostResourceTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_uppercaseHostName() {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "Host name must be in puny-coded, lower-case form");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Host name must be in puny-coded, lower-case form");
|
||||
host.asBuilder().setFullyQualifiedHostName("AAA.BBB.CCC");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_utf8HostName() {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "Host name must be in puny-coded, lower-case form");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Host name must be in puny-coded, lower-case form");
|
||||
host.asBuilder().setFullyQualifiedHostName("みんな.みんな.みんな");
|
||||
}
|
||||
|
||||
|
|
|
@ -49,13 +49,15 @@ public class DomainApplicationIndexTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_create_nullReferences() {
|
||||
thrown.expect(IllegalArgumentException.class, "Keys must not be null or empty.");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Keys must not be null or empty.");
|
||||
DomainApplicationIndex.createWithSpecifiedKeys("blah.com", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_create_emptyReferences() {
|
||||
thrown.expect(IllegalArgumentException.class, "Keys must not be null or empty.");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Keys must not be null or empty.");
|
||||
createWithSpecifiedKeys("blah.com", ImmutableSet.<Key<DomainApplication>>of());
|
||||
}
|
||||
|
||||
|
|
|
@ -69,13 +69,15 @@ public class CommitLogBucketTest {
|
|||
|
||||
@Test
|
||||
public void test_getBucketKey_bucketNumberTooLow_throws() {
|
||||
thrown.expect(IllegalArgumentException.class, "0 not in [");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("0 not in [");
|
||||
getBucketKey(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getBucketKey_bucketNumberTooHigh_throws() {
|
||||
thrown.expect(IllegalArgumentException.class, "11 not in [");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("11 not in [");
|
||||
getBucketKey(11);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,25 +60,29 @@ public class CommitLogCheckpointTest {
|
|||
|
||||
@Test
|
||||
public void test_create_notEnoughBucketTimestamps_throws() {
|
||||
thrown.expect(IllegalArgumentException.class, "Bucket ids are incorrect");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Bucket ids are incorrect");
|
||||
CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(1, T1, 2, T2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_create_tooManyBucketTimestamps_throws() {
|
||||
thrown.expect(IllegalArgumentException.class, "Bucket ids are incorrect");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Bucket ids are incorrect");
|
||||
CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(1, T1, 2, T2, 3, T3, 4, T1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_create_wrongBucketIds_throws() {
|
||||
thrown.expect(IllegalArgumentException.class, "Bucket ids are incorrect");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Bucket ids are incorrect");
|
||||
CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(0, T1, 1, T2, 2, T3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_create_wrongBucketIdOrder_throws() {
|
||||
thrown.expect(IllegalArgumentException.class, "Bucket ids are incorrect");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Bucket ids are incorrect");
|
||||
CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(2, T2, 1, T1, 3, T3));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,8 @@ public class OfyCommitLogTest {
|
|||
public void testTransactNew_deleteNotBackedUpKind_throws() throws Exception {
|
||||
final CommitLogManifest backupsArentAllowedOnMe =
|
||||
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of());
|
||||
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @NotBackedUp");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Can't save/delete a @NotBackedUp");
|
||||
ofy().transactNew(() -> ofy().delete().entity(backupsArentAllowedOnMe));
|
||||
}
|
||||
|
||||
|
@ -171,41 +172,47 @@ public class OfyCommitLogTest {
|
|||
public void testTransactNew_saveNotBackedUpKind_throws() throws Exception {
|
||||
final CommitLogManifest backupsArentAllowedOnMe =
|
||||
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of());
|
||||
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @NotBackedUp");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Can't save/delete a @NotBackedUp");
|
||||
ofy().transactNew(() -> ofy().save().entity(backupsArentAllowedOnMe));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactNew_deleteVirtualEntityKey_throws() throws Exception {
|
||||
final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual");
|
||||
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Can't save/delete a @VirtualEntity");
|
||||
ofy().transactNew(() -> ofy().delete().key(virtualEntityKey));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactNew_saveVirtualEntity_throws() throws Exception {
|
||||
final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual");
|
||||
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Can't save/delete a @VirtualEntity");
|
||||
ofy().transactNew(() -> ofy().save().entity(virtualEntity));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_deleteWithoutBackup_withVirtualEntityKey_throws() throws Exception {
|
||||
final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual");
|
||||
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Can't save/delete a @VirtualEntity");
|
||||
ofy().deleteWithoutBackup().key(virtualEntityKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_saveWithoutBackup_withVirtualEntity_throws() throws Exception {
|
||||
final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual");
|
||||
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Can't save/delete a @VirtualEntity");
|
||||
ofy().saveWithoutBackup().entity(virtualEntity);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransact_twoSavesOnSameKey_throws() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Multiple entries with same key");
|
||||
ofy()
|
||||
.transact(
|
||||
() -> {
|
||||
|
@ -216,7 +223,8 @@ public class OfyCommitLogTest {
|
|||
|
||||
@Test
|
||||
public void testTransact_saveAndDeleteSameKey_throws() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Multiple entries with same key");
|
||||
ofy()
|
||||
.transact(
|
||||
() -> {
|
||||
|
|
|
@ -92,9 +92,8 @@ public class OfyTest {
|
|||
.getUpdateAutoTimestamp().getTimestamp();
|
||||
// Set the clock in Ofy to the same time as the backup group root's save time.
|
||||
Ofy ofy = new Ofy(new FakeClock(groupTimestamp));
|
||||
thrown.expect(
|
||||
TimestampInversionException.class,
|
||||
String.format(
|
||||
thrown.expect(TimestampInversionException.class);
|
||||
thrown.expectMessage(String.format(
|
||||
"Timestamp inversion between transaction time (%s) and entities rooted under:\n"
|
||||
+ "{Key<?>(ContactResource(\"2-ROID\"))=%s}",
|
||||
groupTimestamp,
|
||||
|
@ -122,7 +121,8 @@ public class OfyTest {
|
|||
|
||||
@Test
|
||||
public void testSavingKeyTwice() {
|
||||
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Multiple entries with same key");
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
|
@ -133,7 +133,8 @@ public class OfyTest {
|
|||
|
||||
@Test
|
||||
public void testDeletingKeyTwice() {
|
||||
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Multiple entries with same key");
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
|
@ -144,7 +145,8 @@ public class OfyTest {
|
|||
|
||||
@Test
|
||||
public void testSaveDeleteKey() {
|
||||
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Multiple entries with same key");
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
|
@ -155,7 +157,8 @@ public class OfyTest {
|
|||
|
||||
@Test
|
||||
public void testDeleteSaveKey() {
|
||||
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Multiple entries with same key");
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
|
@ -372,13 +375,15 @@ public class OfyTest {
|
|||
|
||||
@Test
|
||||
public void test_getBaseEntityClassFromEntityOrKey_unregisteredEntity() {
|
||||
thrown.expect(IllegalStateException.class, "SystemClock");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("SystemClock");
|
||||
getBaseEntityClassFromEntityOrKey(new SystemClock());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getBaseEntityClassFromEntityOrKey_unregisteredEntityKey() {
|
||||
thrown.expect(IllegalArgumentException.class, "UnknownKind");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("UnknownKind");
|
||||
getBaseEntityClassFromEntityOrKey(Key.create(
|
||||
com.google.appengine.api.datastore.KeyFactory.createKey("UnknownKind", 1)));
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ public class RdeRevisionTest {
|
|||
|
||||
@Test
|
||||
public void testSaveRevision_objectDoesntExist_newRevisionIsOne_throwsVe() throws Exception {
|
||||
thrown.expect(VerifyException.class, "object missing");
|
||||
thrown.expect(VerifyException.class);
|
||||
thrown.expectMessage("object missing");
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
|
@ -81,7 +82,8 @@ public class RdeRevisionTest {
|
|||
@Test
|
||||
public void testSaveRevision_objectExistsAtZero_newRevisionIsZero_throwsVe() throws Exception {
|
||||
save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0);
|
||||
thrown.expect(VerifyException.class, "object already created");
|
||||
thrown.expect(VerifyException.class);
|
||||
thrown.expectMessage("object already created");
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
|
@ -108,7 +110,8 @@ public class RdeRevisionTest {
|
|||
@Test
|
||||
public void testSaveRevision_objectExistsAtZero_newRevisionIsTwo_throwsVe() throws Exception {
|
||||
save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0);
|
||||
thrown.expect(VerifyException.class, "should be at 1 ");
|
||||
thrown.expect(VerifyException.class);
|
||||
thrown.expectMessage("should be at 1 ");
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
|
@ -118,7 +121,8 @@ public class RdeRevisionTest {
|
|||
|
||||
@Test
|
||||
public void testSaveRevision_negativeRevision_throwsIae() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Negative revision");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Negative revision");
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
|
@ -128,7 +132,8 @@ public class RdeRevisionTest {
|
|||
|
||||
@Test
|
||||
public void testSaveRevision_callerNotInTransaction_throwsIse() throws Exception {
|
||||
thrown.expect(IllegalStateException.class, "transaction");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("transaction");
|
||||
saveRevision("frenzy", DateTime.parse("1984-12-18TZ"), FULL, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,19 +143,22 @@ public class RegistrarTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_passwordNull() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Password must be 6-16 characters long.");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Password must be 6-16 characters long.");
|
||||
new Registrar.Builder().setPassword(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_passwordTooShort() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Password must be 6-16 characters long.");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Password must be 6-16 characters long.");
|
||||
new Registrar.Builder().setPassword("abcde");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_passwordTooLong() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Password must be 6-16 characters long.");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Password must be 6-16 characters long.");
|
||||
new Registrar.Builder().setPassword("abcdefghijklmnopq");
|
||||
}
|
||||
|
||||
|
@ -315,21 +318,22 @@ public class RegistrarTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_missingRegistrarType() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Registrar type cannot be null");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar type cannot be null");
|
||||
new Registrar.Builder().setRegistrarName("blah").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingRegistrarName() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Registrar name cannot be null");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar name cannot be null");
|
||||
new Registrar.Builder().setClientId("blahid").setType(Registrar.Type.TEST).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingAddress() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"Must specify at least one of localized or internationalized address");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Must specify at least one of localized or internationalized address");
|
||||
new Registrar.Builder()
|
||||
.setClientId("blahid")
|
||||
.setType(Registrar.Type.TEST)
|
||||
|
@ -416,25 +420,29 @@ public class RegistrarTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_loadByClientId_clientIdIsNull() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "clientId must be specified");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("clientId must be specified");
|
||||
Registrar.loadByClientId(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_loadByClientId_clientIdIsEmpty() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "clientId must be specified");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("clientId must be specified");
|
||||
Registrar.loadByClientId("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_loadByClientIdCached_clientIdIsNull() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "clientId must be specified");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("clientId must be specified");
|
||||
Registrar.loadByClientIdCached(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_loadByClientIdCached_clientIdIsEmpty() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "clientId must be specified");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("clientId must be specified");
|
||||
Registrar.loadByClientIdCached("");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,8 +202,8 @@ public class RegistryTest extends EntityTestCase {
|
|||
ReservedList rl3 = persistReservedList(
|
||||
"tld-reserved057",
|
||||
"lol,RESERVED_FOR_ANCHOR_TENANT,another_conflict");
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"auth code conflicts for labels: [lol=[conflict1, conflict2, another_conflict]]");
|
||||
@SuppressWarnings("unused")
|
||||
Registry unused = Registry.get("tld").asBuilder().setReservedLists(rl1, rl2, rl3).build();
|
||||
|
@ -354,29 +354,31 @@ public class RegistryTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_tldNeverSet() {
|
||||
thrown.expect(IllegalArgumentException.class, "No registry TLD specified");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("No registry TLD specified");
|
||||
new Registry.Builder().build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setTldStr_null() {
|
||||
thrown.expect(IllegalArgumentException.class, "TLD must not be null");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("TLD must not be null");
|
||||
new Registry.Builder().setTldStr(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setTldStr_invalidTld() {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"Cannot create registry for TLD that is not a valid, canonical domain name");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown
|
||||
.expectMessage("Cannot create registry for TLD that is not a valid, canonical domain name");
|
||||
new Registry.Builder().setTldStr(".tld").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setTldStr_nonCanonicalTld() {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"Cannot create registry for TLD that is not a valid, canonical domain name");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown
|
||||
.expectMessage("Cannot create registry for TLD that is not a valid, canonical domain name");
|
||||
new Registry.Builder().setTldStr("TLD").build();
|
||||
}
|
||||
|
||||
|
@ -400,39 +402,44 @@ public class RegistryTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_pricingEngineIsRequired() {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "All registries must have a configured pricing engine");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("All registries must have a configured pricing engine");
|
||||
new Registry.Builder().setTldStr("invalid").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeRenewBillingCostTransitionValue() {
|
||||
thrown.expect(IllegalArgumentException.class, "billing cost cannot be negative");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("billing cost cannot be negative");
|
||||
Registry.get("tld").asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, -42)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeCreateBillingCost() {
|
||||
thrown.expect(IllegalArgumentException.class, "createBillingCost cannot be negative");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("createBillingCost cannot be negative");
|
||||
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, -42));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeRestoreBillingCost() {
|
||||
thrown.expect(IllegalArgumentException.class, "restoreBillingCost cannot be negative");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("restoreBillingCost cannot be negative");
|
||||
Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, -42));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeServerStatusChangeBillingCost() {
|
||||
thrown.expect(IllegalArgumentException.class, "billing cost cannot be negative");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("billing cost cannot be negative");
|
||||
Registry.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(USD, -42));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_renewBillingCostTransitionValue_wrongCurrency() {
|
||||
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("cost must be in the registry's currency");
|
||||
Registry.get("tld").asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 42)))
|
||||
.build();
|
||||
|
@ -440,19 +447,22 @@ public class RegistryTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_createBillingCost_wrongCurrency() {
|
||||
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("cost must be in the registry's currency");
|
||||
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(EUR, 42)).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_restoreBillingCost_wrongCurrency() {
|
||||
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("cost must be in the registry's currency");
|
||||
Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(EUR, 42)).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_serverStatusChangeBillingCost_wrongCurrency() {
|
||||
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("cost must be in the registry's currency");
|
||||
Registry.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(EUR, 42)).build();
|
||||
}
|
||||
|
||||
|
@ -483,8 +493,8 @@ public class RegistryTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_eapFee_wrongCurrency() {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "All EAP fees must be in the registry's currency");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("All EAP fees must be in the registry's currency");
|
||||
Registry.get("tld").asBuilder()
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.build();
|
||||
|
|
|
@ -80,8 +80,8 @@ public class PremiumListTest {
|
|||
|
||||
@Test
|
||||
public void testParse_cannotIncludeDuplicateLabels() {
|
||||
thrown.expect(
|
||||
IllegalStateException.class,
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage(
|
||||
"List 'tld' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]");
|
||||
PremiumList.get("tld")
|
||||
.get()
|
||||
|
|
|
@ -112,7 +112,8 @@ public class PremiumListUtilsTest {
|
|||
public void testGetPremiumPrice_throwsExceptionWhenNonExistentPremiumListConfigured()
|
||||
throws Exception {
|
||||
deletePremiumList(PremiumList.get("tld").get());
|
||||
thrown.expect(IllegalStateException.class, "Could not load premium list 'tld'");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("Could not load premium list 'tld'");
|
||||
getPremiumPrice("blah", Registry.get("tld"));
|
||||
}
|
||||
|
||||
|
|
|
@ -269,8 +269,8 @@ public class ReservedListTest {
|
|||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "foo")).isTrue();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "bar")).isFalse();
|
||||
persistReservedList("reserved2", "lol,RESERVED_FOR_ANCHOR_TENANT,bar");
|
||||
thrown.expect(
|
||||
IllegalStateException.class, "There are conflicting auth codes for domain: lol.tld");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("There are conflicting auth codes for domain: lol.tld");
|
||||
matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "bar");
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,8 @@ public class ReservedListTest {
|
|||
|
||||
@Test
|
||||
public void testSave_badSyntax() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Could not parse line in reserved list");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Could not parse line in reserved list");
|
||||
persistReservedList("tld", "lol,FULLY_BLOCKED,e,e # yup");
|
||||
}
|
||||
|
||||
|
@ -480,9 +481,8 @@ public class ReservedListTest {
|
|||
|
||||
@Test
|
||||
public void testSave_additionalRestrictionWithIncompatibleReservationType() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"Only anchor tenant and nameserver restricted reservations "
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Only anchor tenant and nameserver restricted reservations "
|
||||
+ "should have restrictions imposed");
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
|
@ -494,7 +494,8 @@ public class ReservedListTest {
|
|||
|
||||
@Test
|
||||
public void testSave_badNameservers_invalidSyntax() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Not a valid domain name: 'ns@.domain.tld'");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Not a valid domain name: 'ns@.domain.tld'");
|
||||
persistReservedList(
|
||||
"reserved1",
|
||||
"lol,NAMESERVER_RESTRICTED,ns1.domain.tld:ns2.domain.tld",
|
||||
|
@ -503,7 +504,8 @@ public class ReservedListTest {
|
|||
|
||||
@Test
|
||||
public void testSave_badNameservers_tooFewPartsForHostname() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "domain.tld is not a valid nameserver hostname");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("domain.tld is not a valid nameserver hostname");
|
||||
persistReservedList(
|
||||
"reserved1",
|
||||
"lol,NAMESERVER_RESTRICTED,ns1.domain.tld:ns2.domain.tld",
|
||||
|
@ -512,8 +514,8 @@ public class ReservedListTest {
|
|||
|
||||
@Test
|
||||
public void testSave_noPasswordWithAnchorTenantReservation() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class,
|
||||
"Anchor tenant reservations must have an auth code configured");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Anchor tenant reservations must have an auth code configured");
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
|
@ -524,8 +526,8 @@ public class ReservedListTest {
|
|||
|
||||
@Test
|
||||
public void testSave_noNameserversWithNameserverRestrictedReservation() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"Nameserver restricted reservations must have at least one nameserver configured");
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
|
@ -538,8 +540,8 @@ public class ReservedListTest {
|
|||
@Test
|
||||
public void testParse_cannotIncludeDuplicateLabels() {
|
||||
ReservedList rl = new ReservedList.Builder().setName("blah").build();
|
||||
thrown.expect(
|
||||
IllegalStateException.class,
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage(
|
||||
"List 'blah' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]");
|
||||
rl.parse(
|
||||
ImmutableList.of(
|
||||
|
|
|
@ -49,7 +49,8 @@ public class KmsSecretRevisionTest {
|
|||
|
||||
@Test
|
||||
public void test_setEncryptedValue_tooLong_throwsException() {
|
||||
thrown.expect(IllegalArgumentException.class, "Secret is greater than 67108864 bytes");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Secret is greater than 67108864 bytes");
|
||||
secretRevision =
|
||||
persistResource(
|
||||
new KmsSecretRevision.Builder()
|
||||
|
|
|
@ -138,7 +138,8 @@ public class LockTest {
|
|||
|
||||
@Test
|
||||
public void testFailure_emptyResourceName() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "resourceName cannot be null or empty");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("resourceName cannot be null or empty");
|
||||
Lock.acquire("", "", TWO_MILLIS, requestStatusChecker);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue