mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 23:03:34 +02: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:
parent
fe7cc4f782
commit
c416b3892d
17 changed files with 124 additions and 172 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue