use of org.mamute.model.Question in project mamute by caelum.
the class EditAnswerTest method should_edit_answer_of_other_author.
@Test
public void should_edit_answer_of_other_author() throws Exception {
User moderator = moderator();
Question question = createQuestionWithDao(moderator, "Titulo da questao hahaha", "Descricao da questao longa demais", tag("java"));
Answer answer = answerQuestionWithDao(moderator, 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.pending")));
}
use of org.mamute.model.Question 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.Question in project mamute by caelum.
the class DaoManager method createQuestion.
public Question createQuestion(User author, String title, String description, Tag... tags) {
this.session.beginTransaction();
Question question = new QuestionBuilder().withTitle(title).withDescription(description).withTags(Arrays.asList(tags)).withAuthor(author).build();
this.questionDao.save(question);
this.session.getTransaction().commit();
return question;
}
use of org.mamute.model.Question in project mamute by caelum.
the class ListTest method should_list_by_tag.
@Test
public void should_list_by_tag() {
String tag = "java";
UserFlow navigation = tagList(tag);
VRaptorTestResult tagList = navigation.execute();
tagList.wasStatus(200).isValid();
List<Question> questions = tagList.getObject("questions");
boolean onlyTag = true;
for (Question q : questions) {
if (!q.getTagsAsString(" ").contains(tag)) {
onlyTag = false;
break;
}
}
assertTrue(onlyTag);
}
use of org.mamute.model.Question in project mamute by caelum.
the class ListTest method should_not_show_questions_with_too_low_reputation.
@Test
public void should_not_show_questions_with_too_low_reputation() {
UserFlow navigation = home();
VRaptorTestResult home = navigation.execute();
home.wasStatus(200).isInvalid();
List<Question> questions = home.getObject("questions");
boolean showLowReputation = false;
for (Question q : questions) {
if (q.getVoteCount() <= QuestionDAO.SPAM_BOUNDARY) {
showLowReputation = true;
break;
}
}
assertFalse(showLowReputation);
}
Aggregations