use of org.mamute.model.Answer in project mamute by caelum.
the class EditAnswerTest method should_edit_and_automatically_approve_author_edit.
@Test
public void should_edit_and_automatically_approve_author_edit() throws Exception {
Question question = createQuestionWithDao(moderator(), "Titulo da questao hahaha", "Descricao da questao longa demais", tag("java"));
User karmaNigga = karmaNigga();
Answer answer = answerQuestionWithDao(karmaNigga, question, "Resposta da questao do teste de edicao", false);
String newDescription = "my new description of the first answer";
UserFlow navigation = login(navigate(), karmaNigga.getEmail());
navigation = editAnswerWithFlow(navigation, answer, newDescription, "comment");
VRaptorTestResult answerEdited = navigation.followRedirect().execute();
answerEdited.wasStatus(200).isValid();
List<String> messagesList = messagesList(answerEdited);
assertTrue(messagesList.contains(message("status.no_need_to_approve")));
AnswerAndVotes answerAndVotes = answerEdited.getObject("answers");
List<Answer> answers = new ArrayList<Answer>(answerAndVotes.getVotes().keySet());
assertEquals(newDescription, answers.get(0).getDescription());
}
use of org.mamute.model.Answer 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;
}
use of org.mamute.model.Answer 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.Answer in project mamute by caelum.
the class WithUserPaginatedDAOTest method setup.
@Before
public void setup() {
session.save(author);
session.save(upVote);
session.save(upVote2);
session.save(upVote3);
session.save(defaultTag);
InvisibleForUsersRule invisibleFilter = new InvisibleForUsersRule(new LoggedUser(author, null));
questionsWithUser = new WithUserPaginatedDAO<Question>(session, Question.class, UserRole.AUTHOR, invisibleFilter);
answersWithUser = new WithUserPaginatedDAO<Answer>(session, Answer.class, UserRole.AUTHOR, invisibleFilter);
}
use of org.mamute.model.Answer in project mamute by caelum.
the class AttachmentRepositoryTest method should_detach_from_answer.
@Test
public void should_detach_from_answer() {
final User author = user("question owner", "question@owner.local");
session.save(author);
final Attachment attachment = createAttachment("test");
attachmentRepository.save(attachment);
final Tag tag = tag("testtag");
session.save(tag);
final Question question = question(author, tag);
session.save(question);
final Answer answer = answer("answer answer answer answer answer", question, author);
answer.getAttachments().add(attachment);
session.save(answer);
attachmentRepository.delete(answer.getAttachments());
assertEquals(0, answer.getAttachments().size());
}
Aggregations