Search in sources :

Example 61 with Question

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

the class QuestionTest method should_verify_if_is_visible_for_moderator.

@Test
public void should_verify_if_is_visible_for_moderator() {
    Question shouldILiveForever = question.build();
    shouldILiveForever.remove();
    boolean isVisibleForModerator = shouldILiveForever.isVisibleFor(user("leo", "leo@leo").asModerator());
    assertTrue(isVisibleForModerator);
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

Example 62 with Question

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

the class QuestionTest method should_return_false_if_is__not_author.

@Test
public void should_return_false_if_is__not_author() throws Exception {
    User author = user("Fernanda", "bla@bla.com", 1l);
    User user = user("Chico", "bla@b.com", 2L);
    Question question = question(author);
    assertFalse(question.canMarkAsSolution(user));
    Answer answer = answer("", question, author);
    question.markAsSolvedBy(answer);
    assertFalse(question.canMarkAsSolution(user));
}
Also used : Answer(org.mamute.model.Answer) User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 63 with Question

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

the class InformationDAOTest method newQuestion.

private Question newQuestion(User author) {
    Question question = new QuestionBuilder().withAuthor(author).withTag(java).build();
    session.save(question);
    return question;
}
Also used : QuestionBuilder(org.mamute.builder.QuestionBuilder) Question(org.mamute.model.Question)

Example 64 with Question

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

the class RemoveSolutionFlaggedByModeratorTest method should_remove_solution_from_question.

@Test
public void should_remove_solution_from_question() throws Exception {
    RemoveSolutionFlaggedByModerator action = new RemoveSolutionFlaggedByModerator(loggedModerator);
    Question question = question(user);
    Answer answer = answer("blabla", question, user);
    answer.markAsSolution();
    action.fire(answer);
    assertFalse(answer.isSolution());
    assertFalse(question.isSolved());
}
Also used : Answer(org.mamute.model.Answer) RemoveSolutionFlaggedByModerator(org.mamute.model.flag.RemoveSolutionFlaggedByModerator) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 65 with Question

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

the class QuestionTest method should_set_author_only_once.

@Test
public void should_set_author_only_once() throws Exception {
    Question q = question.build();
    User original = user("original", "original@brutal.com");
    q.setAuthor(original);
    User other = user("other", "other@brutal.com");
    q.setAuthor(other);
    assertEquals(original, q.getAuthor());
}
Also used : User(org.mamute.model.User) 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