Search in sources :

Example 6 with Question

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

the class QuestionTest method should_update_information_status_and_last_touched_by.

@Test
public void should_update_information_status_and_last_touched_by() throws Exception {
    User artur = user("", "");
    User leo = user("", "");
    artur.setId(1l);
    leo.setId(2l);
    Question comoFaz = question.withTitle("titulo").withDescription("descricao").withAuthor(artur).build();
    QuestionInformation comoFazEditedInformation = new QuestionInformationBuilder().with(leo).build();
    comoFaz.updateWith(comoFazEditedInformation, updater);
    comoFaz.approve(comoFazEditedInformation);
    assertEquals(comoFaz.getLastTouchedBy().getId(), leo.getId());
}
Also used : User(org.mamute.model.User) QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) Question(org.mamute.model.Question) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 7 with Question

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

the class QuestionTest method should_return_false_if_is_author_and_there_is_solution.

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

Example 8 with Question

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

the class SolrQuestionIndexTest method createQuestion.

private Question createQuestion(Long id, String title, String description, Tag... tags) {
    Question question = questionBuilder.withId(id).withTitle(title).withDescription(description).withTags(Arrays.<Tag>asList(tags)).withAuthor(author).build();
    sut.indexQuestion(question);
    return question;
}
Also used : Question(org.mamute.model.Question)

Example 9 with Question

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

the class AnswerAndVotesTest method should_fill_value_with_null_only_answers_that_has_no_currentUserVote.

@Test
public void should_fill_value_with_null_only_answers_that_has_no_currentUserVote() {
    Question q = question.build();
    Object[] first = new Object[] { answerFor(q, 1), mock(Vote.class) };
    Object[] second = new Object[] { answerFor(q, 2), mock(Vote.class) };
    Answer third = answerFor(q, 3);
    List<Object[]> voteList = new ArrayList<>();
    voteList.add(first);
    voteList.add(second);
    List<Answer> answers = new ArrayList<>();
    answers.add((Answer) first[0]);
    answers.add((Answer) second[0]);
    answers.add(third);
    AnswerAndVotes votes = new AnswerAndVotes(q, answers, voteList);
    Map<Answer, Vote> map = votes.getVotes();
    assertEquals(first[1], map.get(first[0]));
    assertEquals(second[1], map.get(second[0]));
    assertEquals(null, map.get(third));
    assertTrue(map.containsKey(third));
}
Also used : Answer(org.mamute.model.Answer) Vote(org.mamute.model.Vote) ArrayList(java.util.ArrayList) Question(org.mamute.model.Question) AnswerAndVotes(org.mamute.model.AnswerAndVotes) Test(org.junit.Test)

Example 10 with Question

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

the class AnswerTest method should_approve_answer_info.

@Test
public void should_approve_answer_info() throws Exception {
    Question myQuestion = question.withTitle("question title").withDescription("description").withAuthor(author).build();
    Answer answer = answer("blablablab", myQuestion, author);
    Information approved = new AnswerInformation(notMarked("blablabalblab"), new LoggedUser(editUser, null), answer, "");
    answer.approve(approved);
    assertEquals(approved, answer.getInformation());
    assertEquals(editUser, answer.getLastTouchedBy());
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) LoggedUser(org.mamute.model.LoggedUser) AnswerInformation(org.mamute.model.AnswerInformation) Information(org.mamute.model.Information) AnswerInformation(org.mamute.model.AnswerInformation) 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