Search in sources :

Example 1 with AnswerInformation

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

the class InformationDAOTest method newPendingChangesAnswer.

private void newPendingChangesAnswer(Answer answer, int times) {
    for (int i = 0; i < times; i++) {
        AnswerInformation pendingInfo = new AnswerInformation(notMarked("info2 info2 info2 info2 info2 info2 info2 "), currentAuthor, answer, "new answer");
        answer.enqueueChange(pendingInfo, PENDING);
    }
}
Also used : AnswerInformation(org.mamute.model.AnswerInformation)

Example 2 with AnswerInformation

use of org.mamute.model.AnswerInformation 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)

Example 3 with AnswerInformation

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

the class AnswerTest method return_true_if_answer_has_pending_edits.

@Test
public void return_true_if_answer_has_pending_edits() throws Exception {
    Question myQuestion = question.withTitle("question title").withDescription("description").withAuthor(author).build();
    Answer answer = answer("blablablab", myQuestion, author);
    assertFalse(answer.hasPendingEdits());
    AnswerInformation approved = new AnswerInformation(notMarked("blablabalblab"), new LoggedUser(editUser, null), answer, "");
    answer.enqueueChange(approved, PENDING);
    assertTrue(answer.hasPendingEdits());
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) LoggedUser(org.mamute.model.LoggedUser) AnswerInformation(org.mamute.model.AnswerInformation) Test(org.junit.Test)

Example 4 with AnswerInformation

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

the class DaoManager method answerQuestion.

public Answer answerQuestion(User author, Question question, String description, boolean watching) {
    this.session.beginTransaction();
    LoggedUser loggedUser = new LoggedUser(author, null);
    AnswerInformation information = new AnswerInformation(notMarked(description), loggedUser, "new answer");
    Answer answer = new Answer(information, question, author);
    this.answerDao.save(answer);
    this.session.getTransaction().commit();
    return answer;
}
Also used : Answer(org.mamute.model.Answer) LoggedUser(org.mamute.model.LoggedUser) AnswerInformation(org.mamute.model.AnswerInformation)

Aggregations

AnswerInformation (org.mamute.model.AnswerInformation)4 Answer (org.mamute.model.Answer)3 LoggedUser (org.mamute.model.LoggedUser)3 Test (org.junit.Test)2 Question (org.mamute.model.Question)2 Information (org.mamute.model.Information)1