Example usage for org.springframework.validation BeanPropertyBindingResult getAllErrors

List of usage examples for org.springframework.validation BeanPropertyBindingResult getAllErrors

Introduction

In this page you can find the example usage for org.springframework.validation BeanPropertyBindingResult getAllErrors.

Prototype

@Override
    public List<ObjectError> getAllErrors() 

Source Link

Usage

From source file:org.oncoblocks.centromere.core.test.DataImportTests.java

@Test
public void validationTest() throws Exception {
    EntrezGene gene = new EntrezGene();
    BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(gene, gene.getClass().getName());
    validator.validate(gene, bindingResult);
    if (bindingResult.hasErrors()) {
        for (ObjectError error : bindingResult.getAllErrors()) {
            System.out.println(error.toString());
        }/*  w  w  w . j a  v  a 2 s  .  c o m*/
    } else {
        fail("Validation did not catch missing field.");
    }
}