mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Add success exception for TestExtraLogicManager
TestExtraLogicManager is pretty kludgy, and should be replaced with injection, mocking, etc. But in the meantime, using a dedicated error to signal its success, rather than IllegalArgumentException as was done before, at least makes things a little easier to follow. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=134832315
This commit is contained in:
parent
237e588d6c
commit
3d5ab8d068
7 changed files with 36 additions and 11 deletions
|
@ -106,6 +106,7 @@ import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpToken;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
import google.registry.model.domain.TestExtraLogicManager;
|
||||||
|
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
||||||
import google.registry.model.domain.launch.ApplicationStatus;
|
import google.registry.model.domain.launch.ApplicationStatus;
|
||||||
import google.registry.model.domain.launch.LaunchNotice;
|
import google.registry.model.domain.launch.LaunchNotice;
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
|
@ -1616,7 +1617,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||||
public void testSuccess_flags() throws Exception {
|
public void testSuccess_flags() throws Exception {
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
setEppInput("domain_create_flags.xml", ImmutableMap.of("FEE", "42"));
|
setEppInput("domain_create_flags.xml", ImmutableMap.of("FEE", "42"));
|
||||||
thrown.expect(IllegalArgumentException.class, "flag1,flag2");
|
thrown.expect(TestExtraLogicManagerSuccessException.class, "flag1,flag2");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
import google.registry.model.domain.TestExtraLogicManager;
|
||||||
|
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
|
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -707,7 +708,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
public void testSuccess_flags() throws Exception {
|
public void testSuccess_flags() throws Exception {
|
||||||
setEppInput("domain_delete_flags.xml");
|
setEppInput("domain_delete_flags.xml");
|
||||||
setupSuccessfulTest();
|
setupSuccessfulTest();
|
||||||
thrown.expect(IllegalArgumentException.class, "deleted");
|
thrown.expect(TestExtraLogicManagerSuccessException.class, "deleted");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ import google.registry.model.billing.BillingEvent.Reason;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
import google.registry.model.domain.TestExtraLogicManager;
|
||||||
|
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
|
@ -616,7 +617,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
||||||
public void testSuccess_flags() throws Exception {
|
public void testSuccess_flags() throws Exception {
|
||||||
setEppInput("domain_renew_flags.xml");
|
setEppInput("domain_renew_flags.xml");
|
||||||
persistDomain();
|
persistDomain();
|
||||||
thrown.expect(IllegalArgumentException.class, "renewed");
|
thrown.expect(TestExtraLogicManagerSuccessException.class, "renewed");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ import google.registry.model.billing.BillingEvent.Reason;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
import google.registry.model.domain.TestExtraLogicManager;
|
||||||
|
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
|
@ -556,7 +557,7 @@ public class DomainRestoreRequestFlowTest extends
|
||||||
public void testSuccess_flags() throws Exception {
|
public void testSuccess_flags() throws Exception {
|
||||||
setEppInput("domain_update_restore_request_flags.xml");
|
setEppInput("domain_update_restore_request_flags.xml");
|
||||||
persistPendingDeleteDomain();
|
persistPendingDeleteDomain();
|
||||||
thrown.expect(IllegalArgumentException.class, "restored");
|
thrown.expect(TestExtraLogicManagerSuccessException.class, "restored");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ import google.registry.model.domain.DomainAuthInfo;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
import google.registry.model.domain.TestExtraLogicManager;
|
||||||
|
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -769,7 +770,8 @@ public class DomainTransferRequestFlowTest
|
||||||
setEppInput("domain_transfer_request_flags.xml");
|
setEppInput("domain_transfer_request_flags.xml");
|
||||||
setupDomain("example", "flags");
|
setupDomain("example", "flags");
|
||||||
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
|
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
|
||||||
thrown.expect(IllegalArgumentException.class, "add:flag1,flag2;remove:flag3,flag4");
|
thrown.expect(
|
||||||
|
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ import google.registry.model.domain.DesignatedContact.Type;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
import google.registry.model.domain.TestExtraLogicManager;
|
||||||
|
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -1197,7 +1198,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
setEppInput("domain_update_addremove_flags.xml", ImmutableMap.of("DOMAIN", "update-0"));
|
setEppInput("domain_update_addremove_flags.xml", ImmutableMap.of("DOMAIN", "update-0"));
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistDomain();
|
persistDomain();
|
||||||
thrown.expect(IllegalArgumentException.class, "add:flag1,flag2;remove:flag3,flag4");
|
thrown.expect(
|
||||||
|
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,7 +1221,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
ImmutableMap.of("DOMAIN", "update-0", "FEE", "0.00"));
|
ImmutableMap.of("DOMAIN", "update-0", "FEE", "0.00"));
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistDomain();
|
persistDomain();
|
||||||
thrown.expect(IllegalArgumentException.class, "add:flag1,flag2;remove:flag3,flag4");
|
thrown.expect(
|
||||||
|
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1229,7 +1232,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
setEppInput("domain_update_addremove_flags.xml", ImmutableMap.of("DOMAIN", "renew-0"));
|
setEppInput("domain_update_addremove_flags.xml", ImmutableMap.of("DOMAIN", "renew-0"));
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistDomain();
|
persistDomain();
|
||||||
thrown.expect(IllegalArgumentException.class, "add:flag1,flag2;remove:flag3,flag4");
|
thrown.expect(
|
||||||
|
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1251,7 +1255,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
ImmutableMap.of("DOMAIN", "renew-0", "FEE", "0.00"));
|
ImmutableMap.of("DOMAIN", "renew-0", "FEE", "0.00"));
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistDomain();
|
persistDomain();
|
||||||
thrown.expect(IllegalArgumentException.class, "add:flag1,flag2;remove:flag3,flag4");
|
thrown.expect(
|
||||||
|
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1284,7 +1289,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
ImmutableMap.of("DOMAIN", "update-13", "FEE", "13.00"));
|
ImmutableMap.of("DOMAIN", "update-13", "FEE", "13.00"));
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistDomain();
|
persistDomain();
|
||||||
thrown.expect(IllegalArgumentException.class, "add:flag1,flag2;remove:flag3,flag4");
|
thrown.expect(
|
||||||
|
TestExtraLogicManagerSuccessException.class, "add:flag1,flag2;remove:flag3,flag4");
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,19 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
|
|
||||||
private String messageToThrow = null;
|
private String messageToThrow = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy exception used to signal success. This is thrown by the commitAdditionalLogicChanges
|
||||||
|
* method to indicate to the test that everything worked properly, because the
|
||||||
|
* TestExtraLogicManager instance used by the flow will have been created deep in the flow and is
|
||||||
|
* not accessible to the test code directly. We should fix this when we make the extra flow logic
|
||||||
|
* injected.
|
||||||
|
*/
|
||||||
|
public static class TestExtraLogicManagerSuccessException extends RuntimeException {
|
||||||
|
TestExtraLogicManagerSuccessException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getExtensionFlags(
|
public List<String> getExtensionFlags(
|
||||||
DomainResource domainResource, String clientId, DateTime asOfDate) {
|
DomainResource domainResource, String clientId, DateTime asOfDate) {
|
||||||
|
@ -221,6 +234,6 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
public void commitAdditionalLogicChanges() {
|
public void commitAdditionalLogicChanges() {
|
||||||
checkNotNull(messageToThrow);
|
checkNotNull(messageToThrow);
|
||||||
// Throw a specific exception as a signal to the test code that we made it through to here.
|
// Throw a specific exception as a signal to the test code that we made it through to here.
|
||||||
throw new IllegalArgumentException(messageToThrow);
|
throw new TestExtraLogicManagerSuccessException(messageToThrow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue