Search in sources :

Example 26 with Answer

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

the class InformationDAOTest method should_find_pending_answers_edits.

@Test
public void should_find_pending_answers_edits() {
    Answer answer = answer("info1 info1 info1 info1 info1 info1 info1 ", question, author);
    session.save(answer);
    newPendingChangesAnswer(answer, 2);
    ModeratableAndPendingHistory pendingByUpdatables = informations.pendingByUpdatables(Answer.class);
    List<Information> pendingInfoForAnswer = pendingByUpdatables.pendingInfoFor(answer);
    assertEquals(2, pendingInfoForAnswer.size());
}
Also used : Answer(org.mamute.model.Answer) ModeratableAndPendingHistory(org.mamute.model.ModeratableAndPendingHistory) QuestionInformation(org.mamute.model.QuestionInformation) Information(org.mamute.model.Information) AnswerInformation(org.mamute.model.AnswerInformation) Test(org.junit.Test)

Example 27 with Answer

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

the class AnswerTest method should_return_that_answer_is_solution_or_not.

@Test
public void should_return_that_answer_is_solution_or_not() {
    Question canILiveForever = question.build();
    Answer yes = answer("Yes", canILiveForever, null);
    assertFalse(yes.isSolution());
    yes.markAsSolution();
    assertTrue(yes.isSolution());
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 28 with Answer

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

the class QuestionTest method can_be_marked_as_solved_by_the_an_answer_that_is_mine.

@Test
public void can_be_marked_as_solved_by_the_an_answer_that_is_mine() {
    Question shouldILiveForever = question.build();
    Answer yes = answer("my answer", shouldILiveForever, null);
    shouldILiveForever.markAsSolvedBy(yes);
    assertEquals(yes, shouldILiveForever.getSolution());
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 29 with Answer

use of org.mamute.model.Answer 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 30 with Answer

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

the class RemoveSolutionFlaggedByModeratorTest method should_remove_solution_from_question.

@Test
public void should_remove_solution_from_question() throws Exception {
    RemoveSolutionFlaggedByModerator action = new RemoveSolutionFlaggedByModerator(loggedModerator);
    Question question = question(user);
    Answer answer = answer("blabla", question, user);
    answer.markAsSolution();
    action.fire(answer);
    assertFalse(answer.isSolution());
    assertFalse(question.isSolved());
}
Also used : Answer(org.mamute.model.Answer) RemoveSolutionFlaggedByModerator(org.mamute.model.flag.RemoveSolutionFlaggedByModerator) Question(org.mamute.model.Question) Test(org.junit.Test)

Aggregations

Answer (org.mamute.model.Answer)31 Test (org.junit.Test)27 Question (org.mamute.model.Question)24 User (org.mamute.model.User)9 ArrayList (java.util.ArrayList)6 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)5 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)5 LoggedUser (org.mamute.model.LoggedUser)5 AnswerAndVotes (org.mamute.model.AnswerAndVotes)4 AnswerInformation (org.mamute.model.AnswerInformation)4 Comment (org.mamute.model.Comment)3 Tag (org.mamute.model.Tag)3 SuspectMassiveVote (org.mamute.dto.SuspectMassiveVote)2 Information (org.mamute.model.Information)2 Vote (org.mamute.model.Vote)2 CustomBrutauthRules (br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules)1 Get (br.com.caelum.vraptor.Get)1 Nullable (javax.annotation.Nullable)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1 DateTime (org.joda.time.DateTime)1