Search in sources :

Example 26 with User

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

the class QuestionTest method should_update_information_status_and_last_touched_by.

@Test
public void should_update_information_status_and_last_touched_by() throws Exception {
    User artur = user("", "");
    User leo = user("", "");
    artur.setId(1l);
    leo.setId(2l);
    Question comoFaz = question.withTitle("titulo").withDescription("descricao").withAuthor(artur).build();
    QuestionInformation comoFazEditedInformation = new QuestionInformationBuilder().with(leo).build();
    comoFaz.updateWith(comoFazEditedInformation, updater);
    comoFaz.approve(comoFazEditedInformation);
    assertEquals(comoFaz.getLastTouchedBy().getId(), leo.getId());
}
Also used : User(org.mamute.model.User) QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) Question(org.mamute.model.Question) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 27 with User

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

the class QuestionTest method should_not_be_touched_when_marked_as_solved.

@Test
public void should_not_be_touched_when_marked_as_solved() {
    Question shouldILiveForever = question.build();
    User touchedBy = shouldILiveForever.getLastTouchedBy();
    User leo = user("", "");
    Answer yes = answer("my answer", shouldILiveForever, leo);
    assertEquals(User.GHOST, shouldILiveForever.getLastTouchedBy());
    shouldILiveForever.markAsSolvedBy(yes);
    assertEquals(touchedBy, shouldILiveForever.getLastTouchedBy());
}
Also used : Answer(org.mamute.model.Answer) User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 28 with User

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

the class QuestionTest method should_return_false_if_is_author_and_there_is_solution.

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

Example 29 with User

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

the class QuestionTest method should_verify_that_a_user_already_answered_question.

@Test
public void should_verify_that_a_user_already_answered_question() throws Exception {
    Question q = question.build();
    User author = user("author", "author@brutal.com", 1l);
    User other = user("other", "other@brutal.com", 2l);
    answer("my answer", q, author);
    assertTrue(q.alreadyAnsweredBy(author));
    assertFalse(q.alreadyAnsweredBy(other));
}
Also used : User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 30 with User

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

the class UpdatablesAndPendingHistoryTest method should_build_group_informations_by_updatable.

@Test
public void should_build_group_informations_by_updatable() {
    List<Object[]> updatableAndInformations = new ArrayList<>();
    User author = user("name", "emaiil");
    QuestionInformationBuilder builder = new QuestionInformationBuilder().with(author);
    QuestionInformation info1 = builder.withTitle("title1").build();
    QuestionInformation info2 = builder.withTitle("title2").build();
    Question question1 = new Question(info1, author);
    question1.setId(1l);
    QuestionInformation info3 = builder.withTitle("title3").build();
    QuestionInformation info4 = builder.withTitle("title4").build();
    Question question2 = new Question(info3, author);
    question2.setId(2l);
    updatableAndInformations.add(new Object[] { question1, info1 });
    updatableAndInformations.add(new Object[] { question1, info2 });
    updatableAndInformations.add(new Object[] { question2, info3 });
    updatableAndInformations.add(new Object[] { question2, info4 });
    ModeratableAndPendingHistory updatablesAndPendingHistory = new ModeratableAndPendingHistory(updatableAndInformations);
    List<Information> pendingInfoForQ1 = updatablesAndPendingHistory.pendingInfoFor(question1);
    List<Information> pendingInfoForQ2 = updatablesAndPendingHistory.pendingInfoFor(question2);
    assertEquals(2, pendingInfoForQ1.size());
    assertEquals("title1", ((QuestionInformation) pendingInfoForQ1.get(0)).getTitle());
    assertEquals("title2", ((QuestionInformation) pendingInfoForQ1.get(1)).getTitle());
    assertEquals(2, pendingInfoForQ2.size());
    assertEquals("title3", ((QuestionInformation) pendingInfoForQ2.get(0)).getTitle());
    assertEquals("title4", ((QuestionInformation) pendingInfoForQ2.get(1)).getTitle());
}
Also used : User(org.mamute.model.User) ModeratableAndPendingHistory(org.mamute.model.ModeratableAndPendingHistory) QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) ArrayList(java.util.ArrayList) Question(org.mamute.model.Question) Information(org.mamute.model.Information) QuestionInformation(org.mamute.model.QuestionInformation) QuestionInformation(org.mamute.model.QuestionInformation) 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