mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 08:52:12 +02:00
Merge JUnitBackport's expectThrows into assertThrows
More information: https://github.com/junit-team/junit5/issues/531 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=187034408
This commit is contained in:
parent
f96a0b7da9
commit
606b470cd0
180 changed files with 1325 additions and 1381 deletions
|
@ -19,7 +19,7 @@ import static google.registry.model.ofy.CommitLogBucket.getBucketKey;
|
|||
import static google.registry.model.ofy.CommitLogBucket.loadAllBuckets;
|
||||
import static google.registry.model.ofy.CommitLogBucket.loadBucket;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
|
@ -66,14 +66,14 @@ public class CommitLogBucketTest {
|
|||
@Test
|
||||
public void test_getBucketKey_bucketNumberTooLow_throws() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> getBucketKey(0));
|
||||
assertThrows(IllegalArgumentException.class, () -> getBucketKey(0));
|
||||
assertThat(thrown).hasMessageThat().contains("0 not in [");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getBucketKey_bucketNumberTooHigh_throws() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> getBucketKey(11));
|
||||
assertThrows(IllegalArgumentException.class, () -> getBucketKey(11));
|
||||
assertThat(thrown).hasMessageThat().contains("11 not in [");
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
package google.registry.model.ofy;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class CommitLogCheckpointTest {
|
|||
@Test
|
||||
public void test_create_notEnoughBucketTimestamps_throws() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(1, T1, 2, T2)));
|
||||
assertThat(thrown).hasMessageThat().contains("Bucket ids are incorrect");
|
||||
|
@ -67,7 +67,7 @@ public class CommitLogCheckpointTest {
|
|||
@Test
|
||||
public void test_create_tooManyBucketTimestamps_throws() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
CommitLogCheckpoint.create(
|
||||
|
@ -78,7 +78,7 @@ public class CommitLogCheckpointTest {
|
|||
@Test
|
||||
public void test_create_wrongBucketIds_throws() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
CommitLogCheckpoint.create(
|
||||
|
@ -89,7 +89,7 @@ public class CommitLogCheckpointTest {
|
|||
@Test
|
||||
public void test_create_wrongBucketIdOrder_throws() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
CommitLogCheckpoint.create(
|
||||
|
|
|
@ -20,7 +20,7 @@ import static com.googlecode.objectify.ObjectifyService.register;
|
|||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.model.ofy.CommitLogBucket.getBucketKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
|
@ -161,7 +161,7 @@ public class OfyCommitLogTest {
|
|||
final CommitLogManifest backupsArentAllowedOnMe =
|
||||
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.of());
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> ofy().transactNew(() -> ofy().delete().entity(backupsArentAllowedOnMe)));
|
||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @NotBackedUp");
|
||||
|
@ -172,7 +172,7 @@ public class OfyCommitLogTest {
|
|||
final CommitLogManifest backupsArentAllowedOnMe =
|
||||
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.of());
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> ofy().transactNew(() -> ofy().save().entity(backupsArentAllowedOnMe)));
|
||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @NotBackedUp");
|
||||
|
@ -182,7 +182,7 @@ public class OfyCommitLogTest {
|
|||
public void testTransactNew_deleteVirtualEntityKey_throws() throws Exception {
|
||||
final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> ofy().transactNew(() -> ofy().delete().key(virtualEntityKey)));
|
||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
||||
|
@ -192,7 +192,7 @@ public class OfyCommitLogTest {
|
|||
public void testTransactNew_saveVirtualEntity_throws() throws Exception {
|
||||
final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> ofy().transactNew(() -> ofy().save().entity(virtualEntity)));
|
||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
||||
|
@ -202,7 +202,7 @@ public class OfyCommitLogTest {
|
|||
public void test_deleteWithoutBackup_withVirtualEntityKey_throws() throws Exception {
|
||||
final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> ofy().deleteWithoutBackup().key(virtualEntityKey));
|
||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
||||
|
@ -212,7 +212,7 @@ public class OfyCommitLogTest {
|
|||
public void test_saveWithoutBackup_withVirtualEntity_throws() throws Exception {
|
||||
final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class, () -> ofy().saveWithoutBackup().entity(virtualEntity));
|
||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ public class OfyCommitLogTest {
|
|||
@Test
|
||||
public void testTransact_twoSavesOnSameKey_throws() throws Exception {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
ofy()
|
||||
|
@ -235,7 +235,7 @@ public class OfyCommitLogTest {
|
|||
@Test
|
||||
public void testTransact_saveAndDeleteSameKey_throws() throws Exception {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
ofy()
|
||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.model.ofy;
|
|||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.initOfy;
|
||||
import static google.registry.testing.DatastoreHelper.newContactResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
|
||||
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
|
||||
|
@ -72,7 +72,7 @@ public class OfyFilterTest {
|
|||
@Test
|
||||
public void testFilterRegistersTypes() throws Exception {
|
||||
UnregisteredEntity entity = new UnregisteredEntity(5L);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () -> Key.create(entity));
|
||||
IllegalStateException e = assertThrows(IllegalStateException.class, () -> Key.create(entity));
|
||||
assertThat(e)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
|
|
|
@ -24,7 +24,6 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
|||
import static google.registry.testing.DatastoreHelper.newContactResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
@ -90,7 +89,7 @@ public class OfyTest {
|
|||
// Set the clock in Ofy to the same time as the backup group root's save time.
|
||||
Ofy ofy = new Ofy(new FakeClock(groupTimestamp));
|
||||
TimestampInversionException thrown =
|
||||
expectThrows(TimestampInversionException.class, () -> ofy.transact(work));
|
||||
assertThrows(TimestampInversionException.class, () -> ofy.transact(work));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
|
@ -121,7 +120,7 @@ public class OfyTest {
|
|||
@Test
|
||||
public void testSavingKeyTwice() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
ofy()
|
||||
|
@ -139,7 +138,7 @@ public class OfyTest {
|
|||
@Test
|
||||
public void testDeletingKeyTwice() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
ofy()
|
||||
|
@ -157,7 +156,7 @@ public class OfyTest {
|
|||
@Test
|
||||
public void testSaveDeleteKey() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
ofy()
|
||||
|
@ -175,7 +174,7 @@ public class OfyTest {
|
|||
@Test
|
||||
public void testDeleteSaveKey() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
ofy()
|
||||
|
@ -404,7 +403,7 @@ public class OfyTest {
|
|||
@Test
|
||||
public void test_getBaseEntityClassFromEntityOrKey_unregisteredEntity() {
|
||||
IllegalStateException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalStateException.class,
|
||||
() -> getBaseEntityClassFromEntityOrKey(new SystemClock()));
|
||||
assertThat(thrown).hasMessageThat().contains("SystemClock");
|
||||
|
@ -413,7 +412,7 @@ public class OfyTest {
|
|||
@Test
|
||||
public void test_getBaseEntityClassFromEntityOrKey_unregisteredEntityKey() {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
getBaseEntityClassFromEntityOrKey(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue