Advertisement
Guest User

Untitled

a guest
Jan 17th, 2013
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. package org.openmrs.validator;
  2.  
  3.  
  4. import org.junit.Assert;
  5. import org.junit.Test;
  6. import org.openmrs.notification.Alert;
  7. import org.springframework.validation.BindException;
  8. import org.springframework.validation.Errors;
  9.  
  10.  
  11. public class AlertValidatorTest {
  12. /**
  13. * @see AlertValidator#validate(Object,Errors)
  14. * @verifies fail validation if Alert Text is null or empty or whitespace
  15. */
  16. @Test
  17. public void validate_shouldFailValidationIfAlertTextIsNullOrEmptyOrWhitespace()
  18. throws Exception {
  19. Alert alert = new Alert();
  20. alert.setText(null);
  21.  
  22. Errors errors = new BindException(alert, "alert");
  23. new AlertValidator().validate(alert, errors);
  24. Assert.assertTrue(errors.hasFieldErrors("text"));
  25.  
  26. alert.setText("");
  27. errors = new BindException(alert, "alert");
  28. new AlertValidator().validate(alert, errors);
  29. Assert.assertTrue(errors.hasFieldErrors("text"));
  30.  
  31. alert.setText(" ");
  32. errors = new BindException(alert, "alert");
  33. new AlertValidator().validate(alert, errors);
  34. Assert.assertTrue(errors.hasFieldErrors("text"));
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement