mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 00:42:12 +02:00
Manually migrate some ExceptionRules to Junit 4.13 style asserts
These testing helper functions can't be handled by the automatic refactoring tool because they're taking in expected exception details as parameters. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=178832406
This commit is contained in:
parent
c2ed7429d3
commit
52ce49a02c
12 changed files with 60 additions and 56 deletions
|
@ -25,6 +25,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
|||
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
|
||||
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
|
||||
|
||||
|
@ -240,12 +241,10 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
|||
runFlow();
|
||||
}
|
||||
|
||||
private void doFailingHostNameTest(
|
||||
String hostName,
|
||||
Class<? extends Throwable> exception) throws Exception {
|
||||
private void doFailingHostNameTest(String hostName, Class<? extends Throwable> exception)
|
||||
throws Exception {
|
||||
setEppHostCreateInputWithIps(hostName);
|
||||
thrown.expect(exception);
|
||||
runFlow();
|
||||
assertThrows(exception, this::runFlow);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.flows.host;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
||||
|
@ -23,6 +24,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
|||
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -97,12 +99,12 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
|||
private void doFailingStatusTest(StatusValue statusValue, Class<? extends Exception> exception)
|
||||
throws Exception {
|
||||
persistResource(
|
||||
newHostResource("ns1.example.tld").asBuilder()
|
||||
newHostResource("ns1.example.tld")
|
||||
.asBuilder()
|
||||
.setStatusValues(ImmutableSet.of(statusValue))
|
||||
.build());
|
||||
thrown.expect(exception);
|
||||
thrown.expectMessage(statusValue.getXmlName());
|
||||
runFlow();
|
||||
Exception e = expectThrows(exception, this::runFlow);
|
||||
assertThat(e).hasMessageThat().contains(statusValue.getXmlName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -33,6 +33,8 @@ import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
|
|||
import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources;
|
||||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
|
||||
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
|
||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||
|
@ -371,8 +373,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
DomainResource domain = persistActiveDomain("example.tld");
|
||||
persistActiveHost(oldHostName());
|
||||
assertThat(domain.getSubordinateHosts()).isEmpty();
|
||||
thrown.expect(CannotRenameExternalHostException.class);
|
||||
runFlow();
|
||||
expectThrows(CannotRenameExternalHostException.class, this::runFlow);
|
||||
assertNoDnsTasksEnqueued();
|
||||
}
|
||||
|
||||
|
@ -1183,8 +1184,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
hostName,
|
||||
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
|
||||
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
|
||||
thrown.expect(exception);
|
||||
runFlow();
|
||||
assertThrows(exception, this::runFlow);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue