use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.
the class AuthTest method should_log_in.
@Test
public void should_log_in() {
User user = randomUser();
UserFlow navigation = login(navigate(), user.getEmail());
VRaptorTestResult loginResult = navigation.followRedirect().execute();
loginResult.wasStatus(200).isValid();
LoggedUser loggedUser = loginResult.getObject("currentUser");
User currentUser = loggedUser.getCurrent();
assertThat(currentUser.getId(), equalTo(user.getId()));
}
use of br.com.caelum.vraptor.test.VRaptorTestResult 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 br.com.caelum.vraptor.test.VRaptorTestResult 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());
}
use of br.com.caelum.vraptor.test.VRaptorTestResult 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 br.com.caelum.vraptor.test.VRaptorTestResult 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());
}
Aggregations