mirror of
https://github.com/google/nomulus.git
synced 2025-05-21 11:49:37 +02:00
Manually migrate exception assertions in RdeImportUtilsTest
It was easier to simply move these over manually than to try to debug the automated tooling. I also changed the case in an exception message. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=178926365
This commit is contained in:
parent
359bab291b
commit
0d3ec66259
2 changed files with 22 additions and 15 deletions
|
@ -158,10 +158,12 @@ public class RdeImportUtils {
|
||||||
TldState currentState = registry.getTldState(clock.nowUtc());
|
TldState currentState = registry.getTldState(clock.nowUtc());
|
||||||
checkArgument(
|
checkArgument(
|
||||||
currentState == TldState.PREDELEGATION,
|
currentState == TldState.PREDELEGATION,
|
||||||
String.format("Tld '%s' is in state %s and cannot be imported", tld, currentState));
|
"TLD '%s' is in state %s and cannot be imported",
|
||||||
|
tld,
|
||||||
|
currentState);
|
||||||
} catch (RegistryNotFoundException e) {
|
} catch (RegistryNotFoundException e) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
String.format("Tld '%s' not found in the registry", tld));
|
String.format("TLD '%s' not found in the registry", tld));
|
||||||
}
|
}
|
||||||
// validate that all registrars exist
|
// validate that all registrars exist
|
||||||
while (parser.nextRegistrar()) {
|
while (parser.nextRegistrar()) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
|
import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
|
@ -59,7 +60,6 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
|
@ -80,9 +80,6 @@ public class RdeImportUtilsTest extends ShardableTestCase {
|
||||||
@Rule
|
@Rule
|
||||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
|
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
|
||||||
|
|
||||||
@Rule
|
|
||||||
public final ExpectedException thrown = ExpectedException.none();
|
|
||||||
|
|
||||||
private final GcsUtils gcsUtils = mock(GcsUtils.class);
|
private final GcsUtils gcsUtils = mock(GcsUtils.class);
|
||||||
|
|
||||||
private RdeImportUtils rdeImportUtils;
|
private RdeImportUtils rdeImportUtils;
|
||||||
|
@ -286,9 +283,11 @@ public class RdeImportUtilsTest extends ShardableTestCase {
|
||||||
public void testValidateEscrowFile_tldNotFound() throws Exception {
|
public void testValidateEscrowFile_tldNotFound() throws Exception {
|
||||||
xmlInput = DEPOSIT_BADTLD_XML.openBufferedStream();
|
xmlInput = DEPOSIT_BADTLD_XML.openBufferedStream();
|
||||||
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
|
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
|
||||||
thrown.expect(IllegalArgumentException.class);
|
Exception e =
|
||||||
thrown.expectMessage("Tld 'badtld' not found in the registry");
|
expectThrows(
|
||||||
rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badtld.xml");
|
IllegalArgumentException.class,
|
||||||
|
() -> rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badtld.xml"));
|
||||||
|
assertThat(e).hasMessageThat().isEqualTo("TLD 'badtld' not found in the registry");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Verifies thrown errer when tld in escrow file is not in PREDELEGATION state */
|
/** Verifies thrown errer when tld in escrow file is not in PREDELEGATION state */
|
||||||
|
@ -296,9 +295,13 @@ public class RdeImportUtilsTest extends ShardableTestCase {
|
||||||
public void testValidateEscrowFile_tldWrongState() throws Exception {
|
public void testValidateEscrowFile_tldWrongState() throws Exception {
|
||||||
xmlInput = DEPOSIT_GETLD_XML.openBufferedStream();
|
xmlInput = DEPOSIT_GETLD_XML.openBufferedStream();
|
||||||
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
|
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
|
||||||
thrown.expect(IllegalArgumentException.class);
|
Exception e =
|
||||||
thrown.expectMessage("Tld 'getld' is in state GENERAL_AVAILABILITY and cannot be imported");
|
expectThrows(
|
||||||
rdeImportUtils.validateEscrowFileForImport("invalid-deposit-getld.xml");
|
IllegalArgumentException.class,
|
||||||
|
() -> rdeImportUtils.validateEscrowFileForImport("invalid-deposit-getld.xml"));
|
||||||
|
assertThat(e)
|
||||||
|
.hasMessageThat()
|
||||||
|
.isEqualTo("TLD 'getld' is in state GENERAL_AVAILABILITY and cannot be imported");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Verifies thrown error when registrar in escrow file is not in the registry */
|
/** Verifies thrown error when registrar in escrow file is not in the registry */
|
||||||
|
@ -306,9 +309,11 @@ public class RdeImportUtilsTest extends ShardableTestCase {
|
||||||
public void testValidateEscrowFile_badRegistrar() throws Exception {
|
public void testValidateEscrowFile_badRegistrar() throws Exception {
|
||||||
xmlInput = DEPOSIT_BADREGISTRAR_XML.openBufferedStream();
|
xmlInput = DEPOSIT_BADREGISTRAR_XML.openBufferedStream();
|
||||||
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
|
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
|
||||||
thrown.expect(IllegalArgumentException.class);
|
Exception e =
|
||||||
thrown.expectMessage("Registrar 'RegistrarY' not found in the registry");
|
expectThrows(
|
||||||
rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badregistrar.xml");
|
IllegalArgumentException.class,
|
||||||
|
() -> rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badregistrar.xml"));
|
||||||
|
assertThat(e).hasMessageThat().isEqualTo("Registrar 'RegistrarY' not found in the registry");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the contact with the specified ROID */
|
/** Gets the contact with the specified ROID */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue