Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.openmrs.validator;
- import org.junit.Assert;
- import org.junit.Test;
- import org.openmrs.notification.Alert;
- import org.springframework.validation.BindException;
- import org.springframework.validation.Errors;
- public class AlertValidatorTest {
- /**
- * @see AlertValidator#validate(Object,Errors)
- * @verifies fail validation if Alert Text is null or empty or whitespace
- */
- @Test
- public void validate_shouldFailValidationIfAlertTextIsNullOrEmptyOrWhitespace()
- throws Exception {
- Alert alert = new Alert();
- alert.setText(null);
- Errors errors = new BindException(alert, "alert");
- new AlertValidator().validate(alert, errors);
- Assert.assertTrue(errors.hasFieldErrors("text"));
- alert.setText("");
- errors = new BindException(alert, "alert");
- new AlertValidator().validate(alert, errors);
- Assert.assertTrue(errors.hasFieldErrors("text"));
- alert.setText(" ");
- errors = new BindException(alert, "alert");
- new AlertValidator().validate(alert, errors);
- Assert.assertTrue(errors.hasFieldErrors("text"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement