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 google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
|
@ -273,18 +272,14 @@ public class MutatingCommandTest {
|
|||
+ "\n"
|
||||
+ "Update Registrar@Registrar2\n"
|
||||
+ "blockPremiumNames: false -> true\n");
|
||||
try {
|
||||
command.execute();
|
||||
assertWithMessage("Expected transaction to fail with IllegalStateException").fail();
|
||||
} catch (IllegalStateException e) {
|
||||
assertThat(e.getMessage()).contains("Entity changed since init() was called.");
|
||||
assertThat(ofy().load().entity(host1).now()).isNull();
|
||||
assertThat(ofy().load().entity(host2).now()).isEqualTo(newHost2);
|
||||
|
||||
// These two shouldn't've changed.
|
||||
assertThat(ofy().load().entity(registrar1).now()).isEqualTo(registrar1);
|
||||
assertThat(ofy().load().entity(registrar2).now()).isEqualTo(registrar2);
|
||||
}
|
||||
IllegalStateException thrown = expectThrows(IllegalStateException.class, command::execute);
|
||||
assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called.");
|
||||
assertThat(ofy().load().entity(host1).now()).isNull();
|
||||
assertThat(ofy().load().entity(host2).now()).isEqualTo(newHost2);
|
||||
// These two shouldn't've changed.
|
||||
assertThat(ofy().load().entity(registrar1).now()).isEqualTo(registrar1);
|
||||
assertThat(ofy().load().entity(registrar2).now()).isEqualTo(registrar2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue