use of org.mamute.model.Question in project mamute by caelum.
the class AnswerQuestionTest method should_answer_when_logged_in.
@Test
public void should_answer_when_logged_in() {
Question question = createQuestionWithDao(moderator(), "Titulo da questao hahaha", "Descricao da questao longa demais", tag("java"));
String description = "Resposta da questao do teste de edicao";
UserFlow navigation = login(navigate(), karmaNigga().getEmail());
navigation = answerQuestionWithFlow(navigation, question, description, false);
VRaptorTestResult questionAnswered = navigation.followRedirect().execute();
questionAnswered.wasStatus(200).isValid();
AnswerAndVotes answerAndVotes = questionAnswered.getObject("answers");
List<Answer> answers = new ArrayList<Answer>(answerAndVotes.getVotes().keySet());
Assert.assertEquals(description, answers.get(0).getDescription());
}
use of org.mamute.model.Question in project mamute by caelum.
the class AnswerQuestionTest method should_not_display_answer_form_when_not_logged_in.
@Test
public void should_not_display_answer_form_when_not_logged_in() {
Question question = createQuestionWithDao(moderator(), "Titulo da questao hahaha", "Descricao da questao longa demais", tag("java"));
UserFlow navigation = goToQuestionPage(navigate(), question);
VRaptorTestResult questionPage = navigation.followRedirect().execute();
questionPage.wasStatus(200).isValid();
Elements answerForm = getElementsByClass(questionPage.getResponseBody(), "answer-form");
assertTrue(answerForm.isEmpty());
}
use of org.mamute.model.Question in project mamute by caelum.
the class EditQuestionTest method should_edit_and_automatically_approve_moderator.
@Test
public void should_edit_and_automatically_approve_moderator() throws Exception {
Question question = createQuestionWithDao(karmaNigga(), "Title title title title title title title", "Description description description description description", tag("java"));
String newTitle = "NEW title title title title title title title";
String newDescription = "NEW description description description description description";
UserFlow navigation = login(navigate(), moderator().getEmail());
navigation = editQuestionWithFlow(navigation, question, newTitle, newDescription, "edited question woots!", "java");
VRaptorTestResult editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
List<String> messagesList = messagesList(editedQuestion);
assertTrue(messagesList.contains(message("status.no_need_to_approve")));
Question fetchQuestion = editedQuestion.getObject("question");
assertEquals(newTitle, fetchQuestion.getTitle());
assertEquals(newDescription, fetchQuestion.getDescription());
}
use of org.mamute.model.Question in project mamute by caelum.
the class ListTest method should_list_unsolved_questions.
@Test
public void should_list_unsolved_questions() {
UserFlow navigation = unsolvedQuestions();
VRaptorTestResult unsolved = navigation.execute();
unsolved.wasStatus(200).isValid();
List<Question> questions = unsolved.getObject("questions");
boolean onlyUnsolved = true;
for (Question q : questions) {
if (q.getAnswersCount() != 0) {
onlyUnsolved = false;
break;
}
}
assertTrue(onlyUnsolved);
}
use of org.mamute.model.Question in project mamute by caelum.
the class EditAnswerTest method should_edit_and_automatically_approve_moderator.
@Test
public void should_edit_and_automatically_approve_moderator() throws Exception {
User moderator = moderator();
Question question = createQuestionWithDao(moderator, "Titulo da questao hahaha", "Descricao da questao longa demais", tag("java"));
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(), moderator.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());
}
Aggregations