Permalink
Browse files

Merge JUnitBackport's expectThrows into assertThrows

More information: junit-team/junit5#531

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187034408
  • Loading branch information...
cushon authored and jianglai committed Feb 26, 2018
1 parent f96a0b7 commit 606b470cd04a84df1570d61b5fa70bb53e6a290f
Showing with 1,325 additions and 1,381 deletions.
  1. +2 −2 javatests/google/registry/batch/DeleteProberDataActionTest.java
  2. +3 −3 javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java
  3. +3 −3 javatests/google/registry/dns/DnsInjectionTest.java
  4. +3 −3 javatests/google/registry/dns/DnsQueueTest.java
  5. +3 −3 javatests/google/registry/dns/PublishDnsUpdatesActionTest.java
  6. +1 −2 javatests/google/registry/dns/RefreshDnsActionTest.java
  7. +3 −4 javatests/google/registry/dns/writer/dnsupdate/DnsMessageTransportTest.java
  8. +3 −3 javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java
  9. +1 −2 javatests/google/registry/export/BigqueryPollJobActionTest.java
  10. +5 −5 javatests/google/registry/export/CheckSnapshotActionTest.java
  11. +3 −3 javatests/google/registry/export/ExportReservedTermsActionTest.java
  12. +3 −3 javatests/google/registry/export/LoadSnapshotActionTest.java
  13. +10 −10 javatests/google/registry/export/PublishDetailReportActionTest.java
  14. +2 −2 javatests/google/registry/export/UpdateSnapshotViewActionTest.java
  15. +7 −7 javatests/google/registry/flows/ExtensionManagerTest.java
  16. +2 −2 javatests/google/registry/flows/ResourceFlowTestCase.java
  17. +3 −3 javatests/google/registry/flows/TlsCredentialsTest.java
  18. +2 −2 javatests/google/registry/flows/contact/ContactCheckFlowTest.java
  19. +4 −4 javatests/google/registry/flows/contact/ContactCreateFlowTest.java
  20. +7 −7 javatests/google/registry/flows/contact/ContactDeleteFlowTest.java
  21. +3 −3 javatests/google/registry/flows/contact/ContactInfoFlowTest.java
  22. +15 −14 javatests/google/registry/flows/contact/ContactTransferApproveFlowTest.java
  23. +12 −12 javatests/google/registry/flows/contact/ContactTransferCancelFlowTest.java
  24. +7 −7 javatests/google/registry/flows/contact/ContactTransferQueryFlowTest.java
  25. +12 −12 javatests/google/registry/flows/contact/ContactTransferRejectFlowTest.java
  26. +10 −10 javatests/google/registry/flows/contact/ContactTransferRequestFlowTest.java
  27. +11 −11 javatests/google/registry/flows/contact/ContactUpdateFlowTest.java
  28. +15 −15 javatests/google/registry/flows/domain/DomainAllocateFlowTest.java
  29. +88 −88 javatests/google/registry/flows/domain/DomainApplicationCreateFlowTest.java
  30. +13 −13 javatests/google/registry/flows/domain/DomainApplicationDeleteFlowTest.java
  31. +7 −7 javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java
  32. +31 −31 javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java
  33. +31 −31 javatests/google/registry/flows/domain/DomainCheckFlowTest.java
  34. +8 −8 javatests/google/registry/flows/domain/DomainClaimsCheckFlowTest.java
  35. +94 −94 javatests/google/registry/flows/domain/DomainCreateFlowTest.java
  36. +12 −12 javatests/google/registry/flows/domain/DomainDeleteFlowTest.java
  37. +17 −17 javatests/google/registry/flows/domain/DomainInfoFlowTest.java
  38. +32 −32 javatests/google/registry/flows/domain/DomainRenewFlowTest.java
  39. +32 −32 javatests/google/registry/flows/domain/DomainRestoreRequestFlowTest.java
  40. +14 −14 javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java
  41. +14 −14 javatests/google/registry/flows/domain/DomainTransferCancelFlowTest.java
  42. +7 −7 javatests/google/registry/flows/domain/DomainTransferQueryFlowTest.java
  43. +14 −14 javatests/google/registry/flows/domain/DomainTransferRejectFlowTest.java
  44. +32 −33 javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java
  45. +39 −39 javatests/google/registry/flows/domain/DomainUpdateFlowTest.java
  46. +4 −4 javatests/google/registry/flows/domain/token/AllocationTokenFlowUtilsTest.java
  47. +2 −2 javatests/google/registry/flows/host/HostCheckFlowTest.java
  48. +14 −14 javatests/google/registry/flows/host/HostCreateFlowTest.java
  49. +12 −12 javatests/google/registry/flows/host/HostDeleteFlowTest.java
  50. +6 −6 javatests/google/registry/flows/host/HostInfoFlowTest.java
  51. +31 −31 javatests/google/registry/flows/host/HostUpdateFlowTest.java
  52. +2 −3 javatests/google/registry/flows/poll/PollAckFlowTest.java
  53. +2 −2 javatests/google/registry/flows/poll/PollRequestFlowTest.java
  54. +2 −2 javatests/google/registry/flows/session/LoginFlowTestCase.java
  55. +2 −2 javatests/google/registry/flows/session/LogoutFlowTest.java
  56. +1 −2 javatests/google/registry/groups/DirectoryGroupsConnectionTest.java
  57. +4 −5 javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java
  58. +8 −8 javatests/google/registry/model/billing/BillingEventTest.java
  59. +3 −4 javatests/google/registry/model/billing/RegistrarBillingEntryTest.java
  60. +4 −4 javatests/google/registry/model/billing/RegistrarCreditTest.java
  61. +8 −8 javatests/google/registry/model/common/CursorTest.java
  62. +2 −2 javatests/google/registry/model/contact/ContactResourceTest.java
  63. +3 −3 javatests/google/registry/model/domain/AllocationTokenTest.java
  64. +3 −3 javatests/google/registry/model/domain/DomainResourceTest.java
  65. +3 −3 javatests/google/registry/model/domain/GracePeriodTest.java
  66. +3 −3 javatests/google/registry/model/host/HostResourceTest.java
  67. +3 −3 javatests/google/registry/model/index/DomainApplicationIndexTest.java
  68. +3 −3 javatests/google/registry/model/ofy/CommitLogBucketTest.java
  69. +5 −5 javatests/google/registry/model/ofy/CommitLogCheckpointTest.java
  70. +9 −9 javatests/google/registry/model/ofy/OfyCommitLogTest.java
  71. +2 −2 javatests/google/registry/model/ofy/OfyFilterTest.java
  72. +7 −8 javatests/google/registry/model/ofy/OfyTest.java
  73. +6 −6 javatests/google/registry/model/rde/RdeRevisionTest.java
  74. +10 −11 javatests/google/registry/model/registrar/RegistrarTest.java
  75. +16 −17 javatests/google/registry/model/registry/RegistryTest.java
  76. +1 −2 javatests/google/registry/model/registry/label/PremiumListTest.java
  77. +2 −2 javatests/google/registry/model/registry/label/PremiumListUtilsTest.java
  78. +8 −9 javatests/google/registry/model/registry/label/ReservedListTest.java
  79. +2 −2 javatests/google/registry/model/server/KmsSecretRevisionTest.java
  80. +2 −2 javatests/google/registry/model/server/LockTest.java
  81. +2 −2 javatests/google/registry/pricing/PricingEngineProxyTest.java
  82. +2 −2 javatests/google/registry/proxy/ProxyModuleTest.java
  83. +4 −4 javatests/google/registry/proxy/handler/BackendMetricsHandlerTest.java
  84. +4 −4 javatests/google/registry/proxy/handler/EppQuotaHandlerTest.java
  85. +4 −4 javatests/google/registry/proxy/handler/WhoisQuotaHandlerTest.java
  86. +3 −3 javatests/google/registry/proxy/quota/QuotaConfigTest.java
  87. +3 −3 javatests/google/registry/rde/EscrowTaskRunnerTest.java
  88. +2 −3 javatests/google/registry/rde/GhostrydeTest.java
  89. +1 −2 javatests/google/registry/rde/RdeReportActionTest.java
  90. +3 −3 javatests/google/registry/rde/RdeUploadActionTest.java
  91. +3 −3 javatests/google/registry/rde/imports/RdeHostInputTest.java
  92. +3 −4 javatests/google/registry/rde/imports/RdeImportUtilsTest.java
  93. +8 −8 javatests/google/registry/rde/imports/RdeParserTest.java
  94. +7 −7 javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java
  95. +2 −2 javatests/google/registry/reporting/ReportingModuleTest.java
  96. +2 −2 javatests/google/registry/reporting/billing/BillingEmailUtilsTest.java
  97. +2 −2 javatests/google/registry/reporting/billing/CopyDetailReportsActionTest.java
  98. +5 −5 javatests/google/registry/reporting/icann/IcannHttpReporterTest.java
  99. +2 −2 javatests/google/registry/reporting/icann/IcannReportingModuleTest.java
  100. +2 −2 javatests/google/registry/reporting/icann/IcannReportingStagingActionTest.java
  101. +2 −2 javatests/google/registry/reporting/icann/IcannReportingUploadActionTest.java
  102. +2 −3 javatests/google/registry/request/RequestModuleTest.java
  103. +8 −8 javatests/google/registry/request/RequestParametersTest.java
  104. +4 −4 javatests/google/registry/request/RouterTest.java
  105. +6 −6 javatests/google/registry/request/auth/RequestAuthenticatorTest.java
  106. +3 −3 javatests/google/registry/request/lock/LockHandlerImplTest.java
  107. +2 −2 javatests/google/registry/storage/drive/DriveConnectionTest.java
  108. +3 −3 javatests/google/registry/tldconfig/idn/IdnTableTest.java
  109. +2 −3 javatests/google/registry/tmch/LordnTaskTest.java
  110. +1 −2 javatests/google/registry/tmch/NordnUploadActionTest.java
  111. +1 −2 javatests/google/registry/tmch/NordnVerifyActionTest.java
  112. +4 −4 javatests/google/registry/tmch/SmdrlCsvParserTest.java
  113. +6 −6 javatests/google/registry/tmch/TmchCertificateAuthorityTest.java
  114. +4 −4 javatests/google/registry/tmch/TmchCrlActionTest.java
  115. +6 −7 javatests/google/registry/tmch/TmchXmlSignatureTest.java
  116. +8 −8 javatests/google/registry/tools/CreateCreditBalanceCommandTest.java
  117. +10 −10 javatests/google/registry/tools/CreateCreditCommandTest.java
  118. +57 −57 javatests/google/registry/tools/CreateDomainCommandTest.java
  119. +1 −2 javatests/google/registry/tools/CreateHostCommandTest.java
  120. +7 −7 javatests/google/registry/tools/CreateLrpTokensCommandTest.java
  121. +4 −4 javatests/google/registry/tools/CreatePremiumListCommandTest.java
  122. +14 −15 javatests/google/registry/tools/CreateRegistrarCommandTest.java
  123. +2 −2 javatests/google/registry/tools/CreateRegistrarGroupsCommandTest.java
  124. +3 −3 javatests/google/registry/tools/CreateReservedListCommandTest.java
  125. +28 −27 javatests/google/registry/tools/CreateTldCommandTest.java
  126. +5 −5 javatests/google/registry/tools/DeleteCreditCommandTest.java
  127. +3 −3 javatests/google/registry/tools/DeletePremiumListCommandTest.java
  128. +3 −3 javatests/google/registry/tools/DeleteReservedListCommandTest.java
  129. +2 −2 javatests/google/registry/tools/EppToolCommandTest.java
  130. +2 −2 javatests/google/registry/tools/GenerateAllocationTokensCommandTest.java
  131. +11 −11 javatests/google/registry/tools/GenerateEscrowDepositCommandTest.java
  132. +1 −2 javatests/google/registry/tools/GetApplicationIdsCommandTest.java
  133. +2 −2 javatests/google/registry/tools/GetLrpTokenCommandTest.java
  134. +2 −3 javatests/google/registry/tools/GetRegistrarCommandTest.java
  135. +5 −6 javatests/google/registry/tools/GetResourceByKeyCommandTest.java
  136. +2 −2 javatests/google/registry/tools/ListCursorsCommandTest.java
  137. +2 −2 javatests/google/registry/tools/ListDomainsCommandTest.java
  138. +3 −3 javatests/google/registry/tools/LockDomainCommandTest.java
  139. +9 −10 javatests/google/registry/tools/MutatingCommandTest.java
  140. +3 −3 javatests/google/registry/tools/RegistrarContactCommandTest.java
  141. +14 −14 javatests/google/registry/tools/SetupOteCommandTest.java
  142. +6 −6 javatests/google/registry/tools/UniformRapidSuspensionCommandTest.java
  143. +3 −3 javatests/google/registry/tools/UnlockDomainCommandTest.java
  144. +2 −3 javatests/google/registry/tools/UpdateApplicationStatusCommandTest.java
  145. +1 −2 javatests/google/registry/tools/UpdateClaimsNoticeCommandTest.java
  146. +1 −2 javatests/google/registry/tools/UpdateCursorsCommandTest.java
  147. +18 −18 javatests/google/registry/tools/UpdateDomainCommandTest.java
  148. +4 −5 javatests/google/registry/tools/UpdateRegistrarCommandTest.java
  149. +2 −2 javatests/google/registry/tools/UpdateReservedListCommandTest.java
  150. +6 −7 javatests/google/registry/tools/UpdateSmdCommandTest.java
  151. +38 −38 javatests/google/registry/tools/UpdateTldCommandTest.java
  152. +2 −2 javatests/google/registry/tools/ValidateEscrowDepositCommandTest.java
  153. +3 −4 javatests/google/registry/tools/ValidateLoginCredentialsCommandTest.java
  154. +3 −3 javatests/google/registry/tools/VerifyOteCommandTest.java
  155. +1 −2 javatests/google/registry/tools/params/DateTimeParameterTest.java
  156. +1 −2 javatests/google/registry/tools/params/DurationParameterTest.java
  157. +2 −2 javatests/google/registry/tools/params/EnumParameterTest.java
  158. +1 −2 javatests/google/registry/tools/params/IntervalParameterTest.java
  159. +1 −2 javatests/google/registry/tools/params/KeyValueMapParameterTest.java
  160. +1 −2 javatests/google/registry/tools/params/MoneyParameterTest.java
  161. +7 −8 javatests/google/registry/tools/params/PathParameterTest.java
  162. +1 −2 javatests/google/registry/tools/params/YearMonthParameterTest.java
  163. +4 −4 javatests/google/registry/tools/server/CreateGroupsActionTest.java
  164. +3 −3 javatests/google/registry/tools/server/DeleteEntityActionTest.java
  165. +9 −10 javatests/google/registry/ui/forms/FormFieldTest.java
  166. +4 −4 javatests/google/registry/ui/forms/FormFieldsTest.java
  167. +3 −3 javatests/google/registry/ui/server/RegistrarFormFieldsTest.java
  168. +2 −2 javatests/google/registry/util/ConcurrentTest.java
  169. +2 −2 javatests/google/registry/util/PosixTarHeaderTest.java
  170. +4 −4 javatests/google/registry/util/RetrierTest.java
  171. +3 −3 javatests/google/registry/util/SerializeUtilsTest.java
  172. +12 −12 javatests/google/registry/util/SqlTemplateTest.java
  173. +1 −2 javatests/google/registry/util/TaskEnqueuerTest.java
  174. +3 −4 javatests/google/registry/util/TeeOutputStreamTest.java
  175. +3 −3 javatests/google/registry/util/TypeUtilsTest.java
  176. +2 −2 javatests/google/registry/util/UrlFetchUtilsTest.java
  177. +2 −2 javatests/google/registry/whois/WhoisHttpServerTest.java
  178. +3 −3 javatests/google/registry/xjc/XjcObjectTest.java
  179. +2 −2 javatests/google/registry/xjc/XmlTestdataTest.java
  180. +3 −18 third_party/junit/google/registry/testing/JUnitBackports.java
@@ -25,7 +25,7 @@
import static google.registry.testing.DatastoreHelper.persistDomainAsDeleted;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DatastoreHelper.persistSimpleResource;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
@@ -207,7 +207,7 @@ public void testFailure_registryAdminClientId_isRequiredForSoftDeletion() throws
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build());
action.registryAdminClientId = null;
IllegalStateException thrown = expectThrows(IllegalStateException.class, this::runMapreduce);
IllegalStateException thrown = assertThrows(IllegalStateException.class, this::runMapreduce);
assertThat(thrown).hasMessageThat().contains("Registry admin client ID must be configured");
}
@@ -28,7 +28,7 @@
import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
import static google.registry.testing.DatastoreHelper.persistPremiumList;
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 static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.USD;
@@ -646,7 +646,7 @@ public void testSuccess_varyingRenewPrices() throws Exception {
public void testFailure_cursorAfterExecutionTime() throws Exception {
action.cursorTimeParam = Optional.of(clock.nowUtc().plusYears(1));
IllegalArgumentException thrown =
expectThrows(IllegalArgumentException.class, this::runMapreduce);
assertThrows(IllegalArgumentException.class, this::runMapreduce);
assertThat(thrown)
.hasMessageThat()
.contains("Cursor time must be earlier than execution time.");
@@ -657,7 +657,7 @@ public void testFailure_cursorAtExecutionTime() throws Exception {
// The clock advances one milli on runMapreduce.
action.cursorTimeParam = Optional.of(clock.nowUtc().plusMillis(1));
IllegalArgumentException thrown =
expectThrows(IllegalArgumentException.class, this::runMapreduce);
assertThrows(IllegalArgumentException.class, this::runMapreduce);
assertThat(thrown)
.hasMessageThat()
.contains("Cursor time must be earlier than execution time.");
@@ -18,7 +18,7 @@
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveSubordinateHost;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
import static org.mockito.Mockito.mock;
@@ -96,7 +96,7 @@ public void testRefreshDns_missingDomain_throwsNotFound() throws Exception {
when(req.getParameter("type")).thenReturn("domain");
when(req.getParameter("name")).thenReturn("example.lol");
NotFoundException thrown =
expectThrows(NotFoundException.class, () -> component.refreshDns().run());
assertThrows(NotFoundException.class, () -> component.refreshDns().run());
assertThat(thrown).hasMessageThat().contains("domain example.lol not found");
}
@@ -114,7 +114,7 @@ public void testRefreshDns_missingHost_throwsNotFound() throws Exception {
when(req.getParameter("type")).thenReturn("host");
when(req.getParameter("name")).thenReturn("ns1.example.lol");
NotFoundException thrown =
expectThrows(NotFoundException.class, () -> component.refreshDns().run());
assertThrows(NotFoundException.class, () -> component.refreshDns().run());
assertThat(thrown).hasMessageThat().contains("host ns1.example.lol not found");
}
}
@@ -16,7 +16,7 @@
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
@@ -64,7 +64,7 @@ public void test_addHostRefreshTask_success() throws Exception {
@Test
public void test_addHostRefreshTask_failsOnUnknownTld() throws Exception {
IllegalArgumentException thrown =
expectThrows(
assertThrows(
IllegalArgumentException.class,
() -> {
try {
@@ -94,7 +94,7 @@ public void test_addDomainRefreshTask_success() throws Exception {
@Test
public void test_addDomainRefreshTask_failsOnUnknownTld() throws Exception {
IllegalArgumentException thrown =
expectThrows(
assertThrows(
IllegalArgumentException.class,
() -> {
try {
@@ -19,7 +19,7 @@
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveSubordinateHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -163,7 +163,7 @@ public void testPublish_commitFails() throws Exception {
ImmutableSet.of(
"ns1.example.xn--q9jyb4c", "ns2.example.xn--q9jyb4c", "ns1.example2.xn--q9jyb4c");
doThrow(new RuntimeException()).when(dnsWriter).commit();
expectThrows(RuntimeException.class, action::run);
assertThrows(RuntimeException.class, action::run);
verify(dnsMetrics).incrementPublishDomainRequests(2, PublishStatus.ACCEPTED);
verify(dnsMetrics).incrementPublishDomainRequests(0, PublishStatus.REJECTED);
@@ -249,7 +249,7 @@ public void testLockIsntAvailable() throws Exception {
action.hosts = ImmutableSet.of("ns1.example.com", "ns2.example.com", "ns1.example2.com");
action.lockHandler = new FakeLockHandler(false);
ServiceUnavailableException thrown =
expectThrows(ServiceUnavailableException.class, action::run);
assertThrows(ServiceUnavailableException.class, action::run);
assertThat(thrown).hasMessageThat().contains("Lock failure");
verifyNoMoreInteractions(dnsWriter);
@@ -20,7 +20,6 @@
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistActiveSubordinateHost;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -77,7 +76,7 @@ public void testSuccess_externalHostNotEnqueued() throws Exception {
persistActiveDomain("example.xn--q9jyb4c");
persistActiveHost("ns1.example.xn--q9jyb4c");
BadRequestException thrown =
expectThrows(
assertThrows(
BadRequestException.class,
() -> {
try {
@@ -17,7 +17,6 @@
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -139,7 +138,7 @@ public void testSentMessageTooLongThrowsException() throws Exception {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
when(mockSocket.getOutputStream()).thenReturn(outputStream);
IllegalArgumentException thrown =
expectThrows(IllegalArgumentException.class, () -> resolver.send(oversize));
assertThrows(IllegalArgumentException.class, () -> resolver.send(oversize));
assertThat(thrown).hasMessageThat().contains("message larger than maximum");
}
@@ -149,7 +148,7 @@ public void testResponseIdMismatchThrowsExeption() throws Exception {
when(mockSocket.getInputStream())
.thenReturn(new ByteArrayInputStream(messageToBytesWithLength(expectedResponse)));
when(mockSocket.getOutputStream()).thenReturn(new ByteArrayOutputStream());
VerifyException thrown = expectThrows(VerifyException.class, () -> resolver.send(simpleQuery));
VerifyException thrown = assertThrows(VerifyException.class, () -> resolver.send(simpleQuery));
assertThat(thrown)
.hasMessageThat()
.contains(
@@ -166,7 +165,7 @@ public void testResponseOpcodeMismatchThrowsException() throws Exception {
when(mockSocket.getInputStream())
.thenReturn(new ByteArrayInputStream(messageToBytesWithLength(expectedResponse)));
when(mockSocket.getOutputStream()).thenReturn(new ByteArrayOutputStream());
VerifyException thrown = expectThrows(VerifyException.class, () -> resolver.send(simpleQuery));
VerifyException thrown = assertThrows(VerifyException.class, () -> resolver.send(simpleQuery));
assertThat(thrown)
.hasMessageThat()
.contains("response opcode 'STATUS' does not match query opcode 'QUERY'");
@@ -26,7 +26,7 @@
import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
@@ -388,7 +388,7 @@ public void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception
persistResource(domain);
when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
VerifyException thrown =
expectThrows(
assertThrows(
VerifyException.class,
() -> {
writer.publishDomain("example.tld");
@@ -407,7 +407,7 @@ public void testPublishHostFails_whenDnsUpdateReturnsError() throws Exception {
persistResource(host);
when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
VerifyException thrown =
expectThrows(
assertThrows(
VerifyException.class,
() -> {
writer.publishHost("ns1.example.tld");
@@ -19,7 +19,6 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assert_;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.logging.Level.INFO;
@@ -203,7 +202,7 @@ public void testFailure_badChainedTaskPayload() throws Exception {
when(bigqueryJobsGet.execute()).thenReturn(
new Job().setStatus(new JobStatus().setState("DONE")));
action.payload = "payload".getBytes(UTF_8);
BadRequestException thrown = expectThrows(BadRequestException.class, action::run);
BadRequestException thrown = assertThrows(BadRequestException.class, action::run);
assertThat(thrown).hasMessageThat().contains("Cannot deserialize task from payload");
}
}
@@ -17,7 +17,7 @@
import static com.google.common.truth.Truth.assertThat;
import static google.registry.export.CheckSnapshotAction.CHECK_SNAPSHOT_KINDS_TO_LOAD_PARAM;
import static google.registry.export.CheckSnapshotAction.CHECK_SNAPSHOT_NAME_PARAM;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
import static org.mockito.Mockito.mock;
@@ -122,7 +122,7 @@ public void testSuccess_enqueuePollTask() throws Exception {
public void testPost_forPendingBackup_returnsNotModified() throws Exception {
setPendingBackup();
NotModifiedException thrown = expectThrows(NotModifiedException.class, action::run);
NotModifiedException thrown = assertThrows(NotModifiedException.class, action::run);
assertThat(thrown).hasMessageThat().contains("Datastore backup some_backup still pending");
}
@@ -138,7 +138,7 @@ public void testPost_forStalePendingBackupBackup_returnsNoContent() throws Excep
.plus(Duration.standardMinutes(3))
.plus(Duration.millis(1234)));
NoContentException thrown = expectThrows(NoContentException.class, action::run);
NoContentException thrown = assertThrows(NoContentException.class, action::run);
assertThat(thrown)
.hasMessageThat()
.contains(
@@ -186,7 +186,7 @@ public void testPost_forBadBackup_returnsBadRequest() throws Exception {
when(backupService.findByName("some_backup"))
.thenThrow(new IllegalArgumentException("No backup found"));
BadRequestException thrown = expectThrows(BadRequestException.class, action::run);
BadRequestException thrown = assertThrows(BadRequestException.class, action::run);
assertThat(thrown).hasMessageThat().contains("Bad backup name some_backup: No backup found");
}
@@ -216,7 +216,7 @@ public void testGet_forBadBackup_returnsError() throws Exception {
when(backupService.findByName("some_backup"))
.thenThrow(new IllegalArgumentException("No backup found"));
BadRequestException thrown = expectThrows(BadRequestException.class, action::run);
BadRequestException thrown = assertThrows(BadRequestException.class, action::run);
assertThat(thrown).hasMessageThat().contains("Bad backup name some_backup: No backup found");
}
}
@@ -20,7 +20,7 @@
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistReservedList;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import static java.nio.charset.StandardCharsets.UTF_8;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import static javax.servlet.http.HttpServletResponse.SC_OK;
@@ -123,14 +123,14 @@ public void test_uploadFileToDrive_failsWhenDriveCannotBeReached() throws Except
any(MediaType.class),
anyString(),
any(byte[].class))).thenThrow(new IOException("errorMessage"));
RuntimeException thrown = expectThrows(RuntimeException.class, () -> runAction("tld"));
RuntimeException thrown = assertThrows(RuntimeException.class, () -> runAction("tld"));
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
assertThat(thrown).hasCauseThat().hasMessageThat().isEqualTo("errorMessage");
}
@Test
public void test_uploadFileToDrive_failsWhenTldDoesntExist() throws Exception {
RuntimeException thrown = expectThrows(RuntimeException.class, () -> runAction("fakeTld"));
RuntimeException thrown = assertThrows(RuntimeException.class, () -> runAction("fakeTld"));
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
assertThat(thrown)
.hasCauseThat()
@@ -22,7 +22,7 @@
import static google.registry.export.LoadSnapshotAction.PATH;
import static google.registry.export.LoadSnapshotAction.QUEUE;
import static google.registry.export.LoadSnapshotAction.enqueueLoadSnapshotTask;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
import static org.joda.time.DateTimeZone.UTC;
import static org.mockito.Matchers.any;
@@ -182,7 +182,7 @@ public void testSuccess_doPost() throws Exception {
@Test
public void testFailure_doPost_badGcsFilename() throws Exception {
action.snapshotFile = "gs://bucket/snapshot";
BadRequestException thrown = expectThrows(BadRequestException.class, action::run);
BadRequestException thrown = assertThrows(BadRequestException.class, action::run);
assertThat(thrown)
.hasMessageThat()
.contains("Error calling load snapshot: backup info file extension missing");
@@ -192,7 +192,7 @@ public void testFailure_doPost_badGcsFilename() throws Exception {
public void testFailure_doPost_bigqueryThrowsException() throws Exception {
when(bigqueryJobsInsert.execute()).thenThrow(new IOException("The Internet has gone missing"));
InternalServerErrorException thrown =
expectThrows(InternalServerErrorException.class, action::run);
assertThrows(InternalServerErrorException.class, action::run);
assertThat(thrown)
.hasMessageThat()
.contains("Error loading snapshot: The Internet has gone missing");
Oops, something went wrong.

0 comments on commit 606b470

Please sign in to comment.