use of org.springframework.webflow.validation.DefaultValidationContext in project cas by apereo.
the class UsernamePasswordCredentialTests method verifyInvalidEvent.
@Test
public void verifyInvalidEvent() {
ApplicationContextProvider.holdApplicationContext(applicationContext);
val input = new UsernamePasswordCredential(null, "Mellon", StringUtils.EMPTY, Map.of());
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val validationContext = new DefaultValidationContext(context, "whatever", mock(MappingResults.class));
input.validate(validationContext);
assertFalse(context.getMessageContext().hasErrorMessages());
}
use of org.springframework.webflow.validation.DefaultValidationContext in project cas by apereo.
the class UsernamePasswordCredentialTests method verifyOperation.
@Test
public void verifyOperation() {
ApplicationContextProvider.holdApplicationContext(applicationContext);
val input = new UsernamePasswordCredential("casuser", "Mellon", StringUtils.EMPTY, Map.of());
assertTrue(input.isValid());
assertEquals(UsernamePasswordCredential.class, input.getClass());
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val validationContext = new DefaultValidationContext(context, "submit", mock(MappingResults.class));
input.validate(validationContext);
assertTrue(context.getMessageContext().hasErrorMessages());
}
Aggregations