mirror of
https://github.com/google/nomulus
synced 2026-09-19 14:34:18 +00:00
Migrate final try/catch test assertions to use assert/expectThrows
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182091814
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
@@ -59,14 +58,13 @@ public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReserve
|
||||
public void testFailure_whenReservedListIsInUse() throws Exception {
|
||||
createTld("xn--q9jyb4c");
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(reservedList).build());
|
||||
try {
|
||||
runCommandForced("--name=" + reservedList.getName());
|
||||
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(ReservedList.get(reservedList.getName())).isPresent();
|
||||
assertThat(e)
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Cannot delete reserved list because it is used on these tld(s): xn--q9jyb4c");
|
||||
}
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--name=" + reservedList.getName()));
|
||||
assertThat(ReservedList.get(reservedList.getName())).isPresent();
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Cannot delete reserved list because it is used on these tld(s): xn--q9jyb4c");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user