Search in sources :

Example 86 with User

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

the class QuestionTest method should_return_false_if_is__not_author.

@Test
public void should_return_false_if_is__not_author() throws Exception {
    User author = user("Fernanda", "bla@bla.com", 1l);
    User user = user("Chico", "bla@b.com", 2L);
    Question question = question(author);
    assertFalse(question.canMarkAsSolution(user));
    Answer answer = answer("", question, author);
    question.markAsSolvedBy(answer);
    assertFalse(question.canMarkAsSolution(user));
}
Also used : Answer(org.mamute.model.Answer) User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 87 with User

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

the class UpdaterTest method should_update_if_is_moderator.

@Test
public void should_update_if_is_moderator() {
    User moderator = user("moderator", "moderator@brutal", nextId()).asModerator();
    QuestionInformation newInformation = new QuestionInformation("title", notMarked("description"), new LoggedUser(moderator, null));
    UpdateStatus update = updater.update(myQuestion, newInformation);
    assertEquals(UpdateStatus.NO_NEED_TO_APPROVE, update);
    assertTrue(myQuestion.getHistory().contains(newInformation));
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) UpdateStatus(org.mamute.model.UpdateStatus) LoggedUser(org.mamute.model.LoggedUser) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 88 with User

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

the class SolrQuestionIndexTest method setup.

@Before
public void setup() throws IOException, SolrServerException, InterruptedException {
    author = new User(fromTrustedText("Leonardo"), "leo@leo");
    eli5 = new Tag("eli5", "Explain Like I'm 5", author);
    eli12 = new Tag("eli12", "Explain Like I'm 12", author);
    science = new Tag("science", "Science!", author);
    hobby = new Tag("hobby", "Hobbies and stuff", author);
    whyIsSkyBlue = createQuestion(1L, "Why is the sky blue?", "I wanna know why is sky blue", science, eli5);
    whereDoBabiesComeFrom = createQuestion(2L, "Where do babies come from?", "My mom said I came from a bird", science, eli12);
    howShipInBottle = createQuestion(3L, "How do they get the ship in the bottle?", "I wanna know this for my school work", hobby);
}
Also used : User(org.mamute.model.User) Tag(org.mamute.model.Tag) Before(org.junit.Before)

Example 89 with User

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

the class SignupValidatorTest method should_verify_email_without_domain.

@Test
public void should_verify_email_without_domain() {
    User user = user("nome muito grande ai meu deus", "invalidgmail.com");
    boolean valid = signupValidator.validate(user, VALID_PASSWORD, VALID_PASSWORD);
    assertFalse(valid);
}
Also used : User(org.mamute.model.User) Test(org.junit.Test)

Example 90 with User

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

the class SignupValidatorTest method should_verify_large_password.

@Test
public void should_verify_large_password() throws Exception {
    when(users.existsWithEmail(VALID_EMAIL)).thenReturn(false);
    String password = 666 * 100 + "";
    User user = user(VALID_USER_NAME, VALID_EMAIL);
    boolean valid = signupValidator.validate(user, password, password);
    assertFalse(valid);
}
Also used : User(org.mamute.model.User) 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