Created
September 4, 2014 09:48
-
-
Save toast38coza/5935d2f7c3df6ee8e32c to your computer and use it in GitHub Desktop.
Testing a Spring Web Flow validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testValidateSomeEventId() { | |
// setup: | |
// mock request | |
MockRequestContext requestContext = new MockRequestContext(); | |
// mock message context: | |
MessageContext messages = requestContext.getMessageContext(); | |
messages.clearMessages(); | |
// mock validation context: | |
ValidationContext validationContext = new DefaultValidationContext(requestContext, "start", null); | |
// the model passed to the validator | |
MyModel myModel = new MyModel(); | |
// .. set values on your model as appropriate | |
// item under test | |
MyModelValidator myModelValidator = new MyModelValidator(); | |
myModelValidator.validateSomeEventId(myModel, validationContext); | |
// assertions | |
assertEquals("Assert Validation passed", 0, messages.getAllMessages().length); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment