use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.
the class AuthTest method should_not_log_in_with_invalid_user.
@Test
public void should_not_log_in_with_invalid_user() {
UserFlow navigation = login(navigate(), "invalidEmail");
VRaptorTestResult loginResult = navigation.followRedirect().execute();
loginResult.wasStatus(200).isValid();
LoggedUser loggedUser = loginResult.getObject("currentUser");
User currentUser = loggedUser.getCurrent();
assertThat(currentUser, equalTo(User.GHOST));
}
use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.
the class AuthTest method should_save_url_when_redirected_to_login.
@Test
public void should_save_url_when_redirected_to_login() {
UserFlow navigation = createQuestionPage(navigate());
VRaptorTestResult navigationResult = navigation.followRedirect().execute();
navigationResult.wasStatus(200).isValid();
Elements redirectInput = getElementsByAttributeAndValue(navigationResult, "name", "redirectUrl");
String redirectUrl = redirectInput.first().attr("value");
String expectedUrl = rootPath(navigationResult).concat("/perguntar");
assertThat(redirectUrl, equalTo(expectedUrl));
}
use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.
the class CommentAnswerTest method should_comment_answer_after_login.
@Test
public void should_comment_answer_after_login() throws Exception {
User moderator = moderator();
Question question = createQuestionWithDao(moderator, "Should comment answer after login", "Yeah, definitely should, who're you to say otherwise?", tag("java"));
Answer answer = answerQuestionWithDao(karmaNigga(), question, "I'm de guy with lots of karma, nigga! So get over here!", false);
String comment = "Oh, right, then I can't do a thing about it.";
UserFlow navigation = login(navigate(), moderator.getEmail());
navigation = commentWithFlow(navigation, answer, comment, false);
VRaptorTestResult commentResult = navigation.followRedirect().execute();
// COULD NOT COMPILE JSP
commentResult.wasStatus(200).isValid();
navigation = login(navigate(), moderator.getEmail());
navigation = goToQuestionPage(navigation, question);
VRaptorTestResult commentedAnswer = navigation.followRedirect().execute();
commentedAnswer.wasStatus(200).isValid();
Elements commentElement = getElementsByClass(commentedAnswer.getResponseBody(), "comment-container");
Elements commentSpan = getElementsByTag(commentElement.html(), "span");
Elements commentParagraph = getElementsByTag(commentSpan.html(), "p");
assertEquals(comment, commentParagraph.html());
}
use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.
the class CreateQuestionTest method should_make_a_question.
@Test
public void should_make_a_question() {
String title = "My new question about java";
String description = "just a question that i have about java hahahhaha";
Tag tag = tag("java");
UserFlow navigation = login(navigate(), karmaNigga().getEmail());
navigation = createQuestionWithFlow(navigation, title, description, tag.getName(), false);
VRaptorTestResult createdQuestion = navigation.followRedirect().execute();
createdQuestion.wasStatus(200).isValid();
Question question = createdQuestion.getObject("question");
Tag questionTag = question.getTags().get(0);
assertThat(question.getTitle(), equalTo(title));
assertThat(question.getDescription(), equalTo(description));
assertThat(questionTag.getName(), equalTo(tag.getName()));
}
use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.
the class EditQuestionTest method should_touch_question.
@Test
public void should_touch_question() throws Exception {
User user = new DaoManager().randomUser();
Question question = createQuestionWithDao(user(user.getEmail()), "Question question question question question", "Description description description description description", tag("java"));
UserFlow navigation = login(navigate(), user.getEmail());
navigation = editQuestionWithFlow(navigation, question, "ASdoA sodi aosido iasod iOASIDoIASOdi", "asd oiasudo iausdoi uasoid uaosiduasoduoasi udaiosud oiasud oiasud oisa", "so diaos diaosi d", "java");
VRaptorTestResult editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
Elements questionElements = getElementsByClass(editedQuestion.getResponseBody(), "edited-touch");
Elements touchImage = getElementsByTag(questionElements.html(), "img");
assertTrue(touchImage.isEmpty());
navigation = login(navigate(), moderator().getEmail());
navigation = editQuestionWithFlow(navigation, question, "Question question question question question", "Description description description description description", "new comment", "java");
editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
questionElements = getElementsByClass(editedQuestion.getResponseBody(), "edited-touch");
touchImage = getElementsByTag(questionElements.html(), "img");
assertFalse(touchImage.isEmpty());
}
Aggregations