mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 16:32:11 +02:00
Merge JUnitBackport's expectThrows into assertThrows
More information: https://github.com/junit-team/junit5/issues/531 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=187034408
This commit is contained in:
parent
f96a0b7da9
commit
606b470cd0
180 changed files with 1325 additions and 1381 deletions
|
@ -16,7 +16,7 @@ package google.registry.rde.imports;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.rde.imports.RdeImportsTestData.loadBytes;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||
import com.google.appengine.tools.cloudstorage.GcsService;
|
||||
|
@ -61,7 +61,7 @@ public class RdeHostInputTest {
|
|||
@Test
|
||||
public void testNegativeShards_throwsIllegalArgumentException() throws Exception {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> getInput(Optional.of(-1)));
|
||||
assertThrows(IllegalArgumentException.class, () -> getInput(Optional.of(-1)));
|
||||
assertThat(thrown).hasMessageThat().contains("Number of shards must be greater than zero");
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class RdeHostInputTest {
|
|||
@Test
|
||||
public void testZeroShards_throwsIllegalArgumentException() throws Exception {
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> getInput(Optional.of(0)));
|
||||
assertThrows(IllegalArgumentException.class, () -> getInput(Optional.of(0)));
|
||||
assertThat(thrown).hasMessageThat().contains("Number of shards must be greater than zero");
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
|||
import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -273,7 +272,7 @@ public class RdeImportUtilsTest extends ShardableTestCase {
|
|||
xmlInput = DEPOSIT_BADTLD_XML.openBufferedStream();
|
||||
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
|
||||
Exception e =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badtld.xml"));
|
||||
assertThat(e).hasMessageThat().isEqualTo("TLD 'badtld' not found in the registry");
|
||||
|
@ -285,7 +284,7 @@ public class RdeImportUtilsTest extends ShardableTestCase {
|
|||
xmlInput = DEPOSIT_GETLD_XML.openBufferedStream();
|
||||
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
|
||||
Exception e =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> rdeImportUtils.validateEscrowFileForImport("invalid-deposit-getld.xml"));
|
||||
assertThat(e)
|
||||
|
@ -299,7 +298,7 @@ public class RdeImportUtilsTest extends ShardableTestCase {
|
|||
xmlInput = DEPOSIT_BADREGISTRAR_XML.openBufferedStream();
|
||||
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
|
||||
Exception e =
|
||||
expectThrows(
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badregistrar.xml"));
|
||||
assertThat(e).hasMessageThat().isEqualTo("Registrar 'RegistrarY' not found in the registry");
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.rde.imports;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.rde.imports.RdeImportsTestData.loadBytes;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.google.common.io.ByteSource;
|
||||
import google.registry.rde.imports.RdeParser.RdeHeader;
|
||||
|
@ -74,7 +74,7 @@ public class RdeParserTest {
|
|||
@Test
|
||||
public void testGetContactNotAtElement_throwsIllegalStateException() throws Exception {
|
||||
try (RdeParser parser = new RdeParser(xml)) {
|
||||
IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getContact);
|
||||
IllegalStateException thrown = assertThrows(IllegalStateException.class, parser::getContact);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Not at element urn:ietf:params:xml:ns:rdeContact-1.0:contact");
|
||||
|
@ -158,7 +158,7 @@ public class RdeParserTest {
|
|||
@Test
|
||||
public void testGetDomainNotAtElement_throwsIllegalStateException() throws Exception {
|
||||
try (RdeParser parser = new RdeParser(xml)) {
|
||||
IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getDomain);
|
||||
IllegalStateException thrown = assertThrows(IllegalStateException.class, parser::getDomain);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Not at element urn:ietf:params:xml:ns:rdeDomain-1.0:domain");
|
||||
|
@ -270,7 +270,7 @@ public class RdeParserTest {
|
|||
@Test
|
||||
public void testGetHostNotAtElement_throwsIllegalStateException() throws Exception {
|
||||
try (RdeParser parser = new RdeParser(xml)) {
|
||||
IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getHost);
|
||||
IllegalStateException thrown = assertThrows(IllegalStateException.class, parser::getHost);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Not at element urn:ietf:params:xml:ns:rdeHost-1.0:host");
|
||||
|
@ -384,7 +384,7 @@ public class RdeParserTest {
|
|||
public void testGetRegistrarNotAtElement_throwsIllegalStateException() throws Exception {
|
||||
try (RdeParser parser = new RdeParser(xml)) {
|
||||
IllegalStateException thrown =
|
||||
expectThrows(IllegalStateException.class, parser::getRegistrar);
|
||||
assertThrows(IllegalStateException.class, parser::getRegistrar);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Not at element urn:ietf:params:xml:ns:rdeRegistrar-1.0:registrar");
|
||||
|
@ -423,7 +423,7 @@ public class RdeParserTest {
|
|||
@Test
|
||||
public void testGetNndnNotAtElement_throwsIllegalStateException() throws Exception {
|
||||
try (RdeParser parser = new RdeParser(xml)) {
|
||||
IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getNndn);
|
||||
IllegalStateException thrown = assertThrows(IllegalStateException.class, parser::getNndn);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Not at element urn:ietf:params:xml:ns:rdeNNDN-1.0:NNDN");
|
||||
|
@ -461,7 +461,7 @@ public class RdeParserTest {
|
|||
@Test
|
||||
public void testGetIdnNotAtElement_throwsIllegalStateException() throws Exception {
|
||||
try (RdeParser parser = new RdeParser(xml)) {
|
||||
IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getIdn);
|
||||
IllegalStateException thrown = assertThrows(IllegalStateException.class, parser::getIdn);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Not at element urn:ietf:params:xml:ns:rdeIDN-1.0:idnTableRef");
|
||||
|
@ -502,7 +502,7 @@ public class RdeParserTest {
|
|||
public void testGetEppParamsNotAtElement_throwsIllegalStateException() throws Exception {
|
||||
try (RdeParser parser = new RdeParser(xml)) {
|
||||
IllegalStateException thrown =
|
||||
expectThrows(IllegalStateException.class, parser::getEppParams);
|
||||
assertThrows(IllegalStateException.class, parser::getEppParams);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Not at element urn:ietf:params:xml:ns:rdeEppParams-1.0:eppParams");
|
||||
|
|
|
@ -26,7 +26,7 @@ import static google.registry.testing.DatastoreHelper.getHistoryEntries;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
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 java.util.Arrays.asList;
|
||||
|
||||
|
@ -214,7 +214,7 @@ public class XjcToDomainResourceConverterTest {
|
|||
persistActiveContact("sh8013");
|
||||
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pendingRestorePeriod.xml");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThrows(IllegalArgumentException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Unsupported grace period status: PENDING_RESTORE");
|
||||
|
@ -270,7 +270,7 @@ public class XjcToDomainResourceConverterTest {
|
|||
persistActiveHost("ns2.example.net");
|
||||
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_host_attrs.xml");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThrows(IllegalArgumentException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThat(thrown).hasMessageThat().contains("Host attributes are not yet supported");
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class XjcToDomainResourceConverterTest {
|
|||
persistActiveHost("ns1.example.net");
|
||||
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_host_objs.xml");
|
||||
IllegalStateException thrown =
|
||||
expectThrows(IllegalStateException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThrows(IllegalStateException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("HostResource not found with name 'ns2.example.net'");
|
||||
|
@ -292,7 +292,7 @@ public class XjcToDomainResourceConverterTest {
|
|||
persistActiveContact("sh8013");
|
||||
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml");
|
||||
IllegalStateException thrown =
|
||||
expectThrows(IllegalStateException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThrows(IllegalStateException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrant not found: 'jd1234'");
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ public class XjcToDomainResourceConverterTest {
|
|||
persistActiveContact("sh8013");
|
||||
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_registrant_missing.xml");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThrows(IllegalArgumentException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Registrant is missing for domain 'example1.example'");
|
||||
|
@ -313,7 +313,7 @@ public class XjcToDomainResourceConverterTest {
|
|||
persistActiveContact("jd1234");
|
||||
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml");
|
||||
IllegalStateException thrown =
|
||||
expectThrows(IllegalStateException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThrows(IllegalStateException.class, () -> convertDomainInTransaction(xjcDomain));
|
||||
assertThat(thrown).hasMessageThat().contains("Contact not found: 'sh8013'");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue