Search in sources :

Example 66 with Question

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

the class QuestionTest method should_remove_vote_values_and_update_vote_count.

@Test
public void should_remove_vote_values_and_update_vote_count() {
    Question myQuestion = question.build();
    assertEquals(0l, myQuestion.getVoteCount());
    Vote firstVote = new Vote(null, VoteType.UP);
    myQuestion.substitute(null, firstVote);
    assertEquals(1l, myQuestion.getVoteCount());
    myQuestion.substitute(firstVote, new Vote(null, VoteType.DOWN));
    assertEquals(-1l, myQuestion.getVoteCount());
    myQuestion.substitute(null, new Vote(null, VoteType.DOWN));
    assertEquals(-2l, myQuestion.getVoteCount());
}
Also used : Vote(org.mamute.model.Vote) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 67 with Question

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

the class QuestionTest method should_verify_if_is_visible_when_visible.

@Test
public void should_verify_if_is_visible_when_visible() {
    Question shouldILiveForever = question.build();
    boolean isVisibleForModerator = shouldILiveForever.isVisibleFor(null);
    assertTrue(isVisibleForModerator);
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

Example 68 with Question

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

the class QuestionTest method should_verify_if_is_visible_for_null.

@Test
public void should_verify_if_is_visible_for_null() {
    Question shouldILiveForever = question.build();
    shouldILiveForever.remove();
    boolean isVisibleForNull = shouldILiveForever.isVisibleFor(null);
    assertFalse(isVisibleForNull);
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

Example 69 with Question

use of org.mamute.model.Question 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 70 with Question

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

the class QuestionDAOTest method should_not_ignore_invisible_ones_if_user_is_author.

@Test
public void should_not_ignore_invisible_ones_if_user_is_author() {
    Question javaQuestion = javaQuestion();
    assertContains(javaQuestion, questionsBeingAuthor);
    javaQuestion.remove();
    assertContains(javaQuestion, questionsBeingAuthor);
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

Aggregations

Question (org.mamute.model.Question)96 Test (org.junit.Test)74 User (org.mamute.model.User)28 Answer (org.mamute.model.Answer)24 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)15 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)15 Tag (org.mamute.model.Tag)9 ArrayList (java.util.ArrayList)8 QuestionBuilder (org.mamute.builder.QuestionBuilder)7 QuestionInformation (org.mamute.model.QuestionInformation)7 DateTime (org.joda.time.DateTime)6 LoggedUser (org.mamute.model.LoggedUser)5 QuestionInformationBuilder (org.mamute.model.QuestionInformationBuilder)5 Elements (org.jsoup.select.Elements)4 AnswerAndVotes (org.mamute.model.AnswerAndVotes)4 Comment (org.mamute.model.Comment)4 Get (br.com.caelum.vraptor.Get)3 Before (org.junit.Before)3 DaoManager (org.mamute.integration.util.DaoManager)3 AnswerInformation (org.mamute.model.AnswerInformation)3