Search in sources :

Example 76 with Question

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);
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

Example 77 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_moderator.

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

Example 78 with Question

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));
}
Also used : Answer(org.mamute.model.Answer) Comment(org.mamute.model.Comment) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 79 with Question

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());
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

Example 80 with Question

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));
}
Also used : AuthorRule(org.mamute.auth.rules.AuthorRule) User(org.mamute.model.User) QuestionBuilder(org.mamute.builder.QuestionBuilder) Question(org.mamute.model.Question) Moderatable(org.mamute.model.interfaces.Moderatable) 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