Search in sources :

Example 71 with Question

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

the class QuestionDAOTest method androidQuestion.

private Question androidQuestion() {
    Question q = question.withTitle("Some question about android and other stuff?").withDescription(notMarked("Please help solving my question about android! Thanks, guys!")).withAuthor(author).withTag(defaultTag).build();
    session.save(q);
    return q;
}
Also used : Question(org.mamute.model.Question)

Example 72 with Question

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

the class QuestionDAOTest method should_ignore_invisible_ones_if_user_is_not_moderator.

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

Example 73 with Question

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

the class QuestionDAOTest method javaEEQuestion.

private Question javaEEQuestion() {
    Question q = question.withTitle("Some question about java ee and other stuff?").withDescription(notMarked("Please help solving my question about java ee! Thanks, guys!")).withAuthor(author).withTag(defaultTag).build();
    session.save(q);
    return q;
}
Also used : Question(org.mamute.model.Question)

Example 74 with Question

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

the class QuestionDAOTest method should_find_hot_questions_ignoring_invisibles.

@Test
public void should_find_hot_questions_ignoring_invisibles() throws Exception {
    DateTime pastWeek = new DateTime().minusWeeks(1);
    Question oldQuestion = TimeMachine.goTo(pastWeek.minusDays(1)).andExecute(new Block<Question>() {

        @Override
        public Question run() {
            Question question = question(author, java);
            setVoteCount(question, 100);
            return question;
        }
    });
    Question withTenVotes = question(author, java);
    Question withFiveVotes = question(author, java);
    Question withNoVotes = question(author, java);
    Question invisible = question(author, java);
    setVoteCount(withTenVotes, 10);
    setVoteCount(withFiveVotes, 5);
    setVoteCount(invisible, 15);
    invisible.remove();
    session.save(oldQuestion);
    session.save(withTenVotes);
    session.save(withFiveVotes);
    session.save(withNoVotes);
    session.save(invisible);
    session.flush();
    List<Question> questions = questionsForAnyone.hot(pastWeek, 3);
    assertThat(questions, Matchers.containsInAnyOrder(withFiveVotes, withTenVotes, withNoVotes));
}
Also used : Question(org.mamute.model.Question) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 75 with Question

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

the class QuestionDAOTest method should_get_question_list_without_invisible_ones.

@Test
public void should_get_question_list_without_invisible_ones() {
    Question q1 = question(author, java);
    Question q2 = question(author, java);
    Question q3 = question(author, java);
    q3.remove();
    session.save(q1);
    session.save(q2);
    session.save(q3);
    List<Question> questions = questionsForAnyone.allVisibleByIds(ImmutableList.of(q2.getId(), q3.getId(), q1.getId()));
    assertNotNull(questions);
    assertEquals(2, questions.size());
    assertEquals(q2.getId(), questions.get(0).getId());
    assertEquals(q1.getId(), questions.get(1).getId());
}
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