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:
mountford 2016-09-30 15:05:11 -07:00 committed by Ben McIlwain
parent 237e588d6c
commit 3d5ab8d068
7 changed files with 36 additions and 11 deletions

View file

@ -43,6 +43,19 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
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
public List<String> getExtensionFlags(
DomainResource domainResource, String clientId, DateTime asOfDate) {
@ -221,6 +234,6 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
public void commitAdditionalLogicChanges() {
checkNotNull(messageToThrow);
// 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);
}
}