GroovyScriptMessageValidator extends AbstractMessageValidator<ScriptValidationContext> { @Override public ScriptValidationContext findValidationContext(List<ValidationContext> validationContexts) { for (ValidationContext validationContext : validationContexts) { if (getRequiredValidationContextType().isInstance(validationContext) && ((ScriptValidationContext)validationContext).getScriptType().equals(ScriptTypes.GROOVY)) { return (ScriptValidationContext) validationContext; } } return null; } GroovyScriptMessageValidator();  GroovyScriptMessageValidator(ClassPathResource scriptTemplateResource); @Override void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ScriptValidationContext validationContext); @Override ScriptValidationContext findValidationContext(List<ValidationContext> validationContexts); @Override boolean supportsMessageType(String messageType, Message message);  }
@Test public void shouldFindProperValidationContext() { List<ValidationContext> validationContexts = new ArrayList<>(); validationContexts.add(new HeaderValidationContext()); validationContexts.add(new XmlMessageValidationContext()); validationContexts.add(new JsonMessageValidationContext()); validationContexts.add(new ScriptValidationContext("scala")); Assert.assertNull(validator.findValidationContext(validationContexts)); validationContexts.add(new ScriptValidationContext(ScriptTypes.GROOVY)); Assert.assertNotNull(validator.findValidationContext(validationContexts)); }