Example using attributeHasFieldErrors and attributeHasNoError
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 Failed Validation - missing ssn param | |
DefaultRequestBuilder requestBad = post(url) | |
.param("isEmployee", "true"); | |
MockMvcBuilders.standaloneSetup(controller).build() | |
.perform(requestBad) | |
.andExpect(status().isOk()) | |
.andExpect(model().attributeHasFieldErrors("lookupBean", "ssn")); |
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
// No errors found on lookupBean | |
DefaultRequestBuilder requestBad = post(url) | |
.param("isEmployee", "true"); | |
MockMvcBuilders.standaloneSetup(controller).build() | |
.perform(requestBad) | |
.andExpect(status().isOk()) | |
.andExpect(model().attributeHasNoErrors("lookupBean")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment