Errors errors = new BeanPropertyBindingResult(order, "validOrder");
orderValidator.validateAddress(null, errors, "billingAddress");
assertEquals(0, errors.getAllErrors().size());
Address address = new Address();
order.setBillingAddress(address);
orderValidator.validateAddress(address, errors, "billingAddress");
assertEquals(4, errors.getAllErrors().size());
assertEquals("error.baddress.addrline1.length", errors.getFieldError("billingAddress.addrLine1").getCode());
assertEquals("error.baddress.city.length", errors.getFieldError("billingAddress.city").getCode());
assertEquals("error.baddress.zipcode.length", errors.getFieldError("billingAddress.zipCode").getCode());
assertEquals("error.baddress.country.length", errors.getFieldError("billingAddress.country").getCode());
address = new Address();
address.setAddressee("1234567890123456789012345678901234567890123456789012345678901234567890");
address.setAddrLine1("123456789012345678901234567890123456789012345678901234567890");
address.setAddrLine2("123456789012345678901234567890123456789012345678901234567890");
address.setCity("1234567890123456789012345678901234567890");
address.setZipCode("1234567890");
address.setState("1234567890");
address.setCountry("123456789012345678901234567890123456789012345678901234567890");
order.setBillingAddress(address);
errors = new BeanPropertyBindingResult(order, "validOrder");
orderValidator.validateAddress(address, errors, "billingAddress");
assertEquals(8, errors.getAllErrors().size());
assertEquals("error.baddress.addresse.length", errors.getFieldError("billingAddress.addressee").getCode());
assertEquals("error.baddress.addrline1.length", errors.getFieldError("billingAddress.addrLine1").getCode());
assertEquals("error.baddress.addrline2.length", errors.getFieldError("billingAddress.addrLine2").getCode());
assertEquals("error.baddress.city.length", errors.getFieldError("billingAddress.city").getCode());
assertEquals("error.baddress.state.length", errors.getFieldError("billingAddress.state").getCode());
assertEquals("error.baddress.zipcode.length", errors.getFieldErrors("billingAddress.zipCode").get(0).getCode());
assertEquals("error.baddress.zipcode.format", errors.getFieldErrors("billingAddress.zipCode").get(1).getCode());
assertEquals("error.baddress.country.length", errors.getFieldError("billingAddress.country").getCode());
address = new Address();
address.setAddressee("John Doe");
address.setAddrLine1("123 4th Street");
address.setCity("Chicago");
address.setState("IL");
address.setZipCode("60606");
address.setCountry("United States");
order.setBillingAddress(address);
errors = new BeanPropertyBindingResult(order, "validOrder");
orderValidator.validateAddress(address, errors, "billingAddress");