Search in sources :

Example 1 with MessageFactory

use of org.mamute.factory.MessageFactory in project mamute by caelum.

the class EmailValidatorTest method setup.

@Before
public void setup() {
    users = mock(UserDAO.class);
    messageFactory = mock(MessageFactory.class);
    validator = new MockValidator();
    emailValidator = new EmailValidator(validator, users, messageFactory);
    existant = "existant@brutal.com";
    unexistant = "unexistant@brutal.com";
    when(users.existsWithEmail(existant)).thenReturn(true);
    when(users.existsWithEmail(unexistant)).thenReturn(false);
    when(users.existsWithEmail(null)).thenReturn(false);
}
Also used : EmailValidator(org.mamute.validators.EmailValidator) UserDAO(org.mamute.dao.UserDAO) MessageFactory(org.mamute.factory.MessageFactory) MockValidator(br.com.caelum.vraptor.util.test.MockValidator) Before(org.junit.Before)

Example 2 with MessageFactory

use of org.mamute.factory.MessageFactory in project mamute by caelum.

the class TagsValidatorTest method setup.

@Before
public void setup() {
    environment = mock(Environment.class);
    when(environment.get("tags.sanitizer.regex")).thenReturn("[a-zA-Z0-9-]");
    messageFactory = new MessageFactory(bundle);
    validator = new MockValidator();
    tagsValidator = new TagsValidator(environment, validator, messageFactory);
    User user = user("any", "any@brutal.com");
    java = new Tag("java", "", user);
    ruby = new Tag("ruby", "", user);
    rails = new Tag("rails", "", user);
    nonalpha = new Tag("java,mysql", "", user);
}
Also used : User(org.mamute.model.User) MessageFactory(org.mamute.factory.MessageFactory) MockValidator(br.com.caelum.vraptor.util.test.MockValidator) Environment(br.com.caelum.vraptor.environment.Environment) Tag(org.mamute.model.Tag) Before(org.junit.Before)

Example 3 with MessageFactory

use of org.mamute.factory.MessageFactory in project mamute by caelum.

the class SignupValidatorTest method setup.

@Before
public void setup() {
    validator = new MockValidator();
    messageFactory = new MessageFactory(bundle);
    emailValidator = new EmailValidator(validator, users, messageFactory);
    javax.validation.Validator javaxValidator = Validation.buildDefaultValidatorFactory().getValidator();
    BrutalValidator brutalValidator = new BrutalValidator(javaxValidator, validator, messageFactory);
    userValidator = new UserValidator(validator, emailValidator, messageFactory, brutalValidator);
    signupValidator = new SignupValidator(validator, userValidator, messageFactory, users);
    when(users.existsWithEmail(VALID_EMAIL)).thenReturn(false);
    when(users.existsWithName(VALID_USER_NAME)).thenReturn(false);
}
Also used : MessageFactory(org.mamute.factory.MessageFactory) MockValidator(br.com.caelum.vraptor.util.test.MockValidator) BrutalValidator(org.mamute.controllers.BrutalValidator) Before(org.junit.Before)

Example 4 with MessageFactory

use of org.mamute.factory.MessageFactory in project mamute by caelum.

the class UserPersonalInfoValidatorTest method setup.

@Before
public void setup() {
    this.bundle = mock(BundleFormatter.class);
    this.validEmail = "artur.adam@email.com.br";
    this.users = mock(UserDAO.class);
    this.validator = new MockValidator();
    this.messageFactory = new MessageFactory(mock(ResourceBundle.class));
    this.emailValidator = new EmailValidator(validator, users, messageFactory);
    javax.validation.Validator javaxValidator = Validation.buildDefaultValidatorFactory().getValidator();
    BrutalValidator brutalValidator = new BrutalValidator(javaxValidator, validator, messageFactory);
    this.infoValidator = new UserPersonalInfoValidator(validator, emailValidator, messageFactory, bundle, brutalValidator);
}
Also used : UserDAO(org.mamute.dao.UserDAO) MessageFactory(org.mamute.factory.MessageFactory) MockValidator(br.com.caelum.vraptor.util.test.MockValidator) BundleFormatter(br.com.caelum.vraptor.simplemail.template.BundleFormatter) BrutalValidator(org.mamute.controllers.BrutalValidator) Before(org.junit.Before)

Aggregations

MockValidator (br.com.caelum.vraptor.util.test.MockValidator)4 Before (org.junit.Before)4 MessageFactory (org.mamute.factory.MessageFactory)4 BrutalValidator (org.mamute.controllers.BrutalValidator)2 UserDAO (org.mamute.dao.UserDAO)2 Environment (br.com.caelum.vraptor.environment.Environment)1 BundleFormatter (br.com.caelum.vraptor.simplemail.template.BundleFormatter)1 Tag (org.mamute.model.Tag)1 User (org.mamute.model.User)1 EmailValidator (org.mamute.validators.EmailValidator)1