use of org.mamute.model.Question in project mamute by caelum.
the class QuestionDAOTest method should_throw_constraint_exception_if_description_is_null.
@Test(expected = ConstraintViolationException.class)
public void should_throw_constraint_exception_if_description_is_null() {
Question myQuestion = question.withTitle(VALID_TITLE).withDescription((String) null).withAuthor(author).build();
questionsBeingAuthor.save(myQuestion);
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionDAOTest method should_not_ignore_invisible_ones_if_user_is_moderator.
@Test
public void should_not_ignore_invisible_ones_if_user_is_moderator() {
Question javaQuestion = javaQuestion();
assertContains(javaQuestion, questionsBeingModerator);
javaQuestion.remove();
assertContains(javaQuestion, questionsBeingModerator);
}
use of org.mamute.model.Question in project mamute by caelum.
the class VoteDAOTest method should_find_question_from_votable.
@Test
public void should_find_question_from_votable() throws Exception {
Question question = question(currentUser, tags);
Answer answer = answer("answer answer answer answer answer", question, currentUser);
Comment comment = comment(currentUser, "blabla blabla blabla blabla blabla blabla");
question.add(comment);
session.save(question);
session.save(answer);
session.save(comment);
assertEquals(question, votes.contextOf(question));
assertEquals(question, votes.contextOf(answer));
assertEquals(question, votes.contextOf(comment));
}
use of org.mamute.model.Question in project mamute by caelum.
the class FlaggableDAOTest method should_turn_every_question_of_user_into_invisible.
@Test
public void should_turn_every_question_of_user_into_invisible() {
Question q1 = question(author, java);
Question q2 = question(author, java);
Question q3 = question(anyone, java);
session.save(q1);
session.save(q2);
session.save(q3);
flaggables.turnAllInvisibleWith(author);
List<Question> visibleQuestions = questions.allVisibleByIds(ImmutableList.of(q1.getId(), q2.getId(), q3.getId()));
assertNotNull(visibleQuestions);
assertEquals(1, visibleQuestions.size());
assertEquals(q3.getId(), visibleQuestions.get(0).getId());
}
use of org.mamute.model.Question in project mamute by caelum.
the class AuthorRuleTest method should_allow_moderatable_author.
@Test
public void should_allow_moderatable_author() {
AuthorRule<Moderatable> rule = new AuthorRule<>();
User author = user("author", "author@brutal.com", 1l);
User other = user("other", "other@brutal.com", 2l);
Question question = new QuestionBuilder().withAuthor(author).build();
assertFalse(rule.isAllowed(other, question));
assertTrue(rule.isAllowed(author, question));
}
Aggregations