Search in sources :

Example 36 with User

use of org.mamute.model.User in project mamute by caelum.

the class SignupValidatorTest method should_verify_large_name.

@Test
public void should_verify_large_name() throws Exception {
    when(users.existsWithEmail(VALID_EMAIL)).thenReturn(false);
    String name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    User user = user(name, VALID_EMAIL);
    boolean valid = signupValidator.validate(user, VALID_PASSWORD, VALID_PASSWORD);
    assertFalse(valid);
}
Also used : User(org.mamute.model.User) Test(org.junit.Test)

Example 37 with User

use of org.mamute.model.User 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 38 with User

use of org.mamute.model.User in project mamute by caelum.

the class UserPersonalInfoValidatorTest method should_not_validate_user_trying_to_update_name_before_allowed_time.

@Test
public void should_not_validate_user_trying_to_update_name_before_allowed_time() {
    User artur = user("artur com seis caracteres", validEmail);
    UserPersonalInfo info = new UserPersonalInfo(artur).withName(fromTrustedText("newName")).withEmail(artur.getEmail());
    when(bundle.getMessage("date.joda.simple.pattern")).thenReturn("dd/MM/YYYY");
    assertFalse(infoValidator.validate(info));
}
Also used : User(org.mamute.model.User) UserPersonalInfo(org.mamute.dto.UserPersonalInfo) Test(org.junit.Test)

Example 39 with User

use of org.mamute.model.User in project mamute by caelum.

the class UserPersonalInfoValidatorTest method should_pass_validation_with_not_required_elements_null.

@Test
public void should_pass_validation_with_not_required_elements_null() {
    User artur = user("artur com seis caracteres", validEmail);
    UserPersonalInfo info = new UserPersonalInfo(artur).withName(fromTrustedText(artur.getName())).withEmail(artur.getEmail());
    assertTrue(infoValidator.validate(info));
}
Also used : User(org.mamute.model.User) UserPersonalInfo(org.mamute.dto.UserPersonalInfo) Test(org.junit.Test)

Example 40 with User

use of org.mamute.model.User in project mamute by caelum.

the class UserPersonalInfoValidatorTest method should_not_validate_under_twelve_years_old_user.

@Test
public void should_not_validate_under_twelve_years_old_user() {
    User artur = user("artur com seis caracteres", validEmail);
    DateTime hoje = DateTime.now();
    UserPersonalInfo info = new UserPersonalInfo(artur).withName(fromTrustedText(artur.getName())).withEmail(artur.getEmail()).withBirthDate(hoje);
    assertFalse(infoValidator.validate(info));
}
Also used : User(org.mamute.model.User) UserPersonalInfo(org.mamute.dto.UserPersonalInfo) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

User (org.mamute.model.User)97 Test (org.junit.Test)56 Question (org.mamute.model.Question)28 LoggedUser (org.mamute.model.LoggedUser)25 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)9 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)9 Answer (org.mamute.model.Answer)9 LoginMethod (org.mamute.model.LoginMethod)9 Post (br.com.caelum.vraptor.Post)7 Before (org.junit.Before)7 Tag (org.mamute.model.Tag)7 QuestionInformation (org.mamute.model.QuestionInformation)6 Email (org.apache.commons.mail.Email)5 UserPersonalInfo (org.mamute.dto.UserPersonalInfo)5 ReputationEvent (org.mamute.model.ReputationEvent)5 ArrayList (java.util.ArrayList)4 Watcher (org.mamute.model.watch.Watcher)4 DateTime (org.joda.time.DateTime)3 Elements (org.jsoup.select.Elements)3 DaoManager (org.mamute.integration.util.DaoManager)3