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;
}
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);
}
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;
}
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));
}
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());
}
Aggregations