Is there some way to validate the messages added by my Validators when testing my web flows? I can't figure out how to access the messages.
I'm having good luck testing my flows by creating JUnit classes derived from AbstractXmlFlowExecutionTests. I can successfully populate fields in my model object, resume the flow, and confirm the transitions fire as expected. But I can't figure out how to access the Messages added by the Validators.
(please excuse my pseudo-code)
Specifically, let's say I have a model object and separate validator
In my test method, after I resume my flow, I successfully assertCurrentStateEquals(). But then I'd like to confirm that the proper message was added. How can I access that message associated with my "value" field?Code:public class Criteria { private long value; public long getValue() { return value; } public void setValue(long argValue) { value = argValue }; } public class CriteriaValidator { public void validateSearchUsingValue(Criteria argCriteria, ValidationContext argContext) { if (argCriteria.getValue() < 0) { MessageBuilder msgBuilder = new MessageBuilder().error(); msgBuilder.source("value"); msgBuilder.code("cocode.domain.cannotBeNegative"); msgBuilder.args(new Object[] { argCriteria.getValue() }); argContext.getMessageContext().addMessage(msgBuilder.build()); } }
Thanks in advance.


Reply With Quote