Search in sources :

Example 11 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.

the class SignupTest method should_sign_up.

@Test
public void should_sign_up() {
    String email = randomEmail();
    UserFlow navigation = signUp(navigate(), "Random User", email, DEFAULT_PASSWORD, DEFAULT_PASSWORD);
    navigation = login(navigation, email);
    VRaptorTestResult signedUpUser = navigation.followRedirect().execute();
    signedUpUser.wasStatus(200).isValid();
    List<String> messagesList = messagesList(signedUpUser);
    assertTrue(messagesList.contains(message("signup.confirmation")));
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 12 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.

the class SignupTest method should_not_sign_up_with_invalid_email.

@Test
public void should_not_sign_up_with_invalid_email() {
    UserFlow navigation = signUp(navigate(), "Marco", "invalidEmail", DEFAULT_PASSWORD, DEFAULT_PASSWORD);
    VRaptorTestResult notSignedUpUser = navigation.followRedirect().execute();
    notSignedUpUser.wasStatus(200).isValid();
    List<String> errorsList = errorsList(notSignedUpUser);
    assertTrue(errorsList.contains(message("user.errors.email.invalid")));
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 13 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult 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());
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) Question(org.mamute.model.Question) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 14 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult 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());
}
Also used : Answer(org.mamute.model.Answer) UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) ArrayList(java.util.ArrayList) Question(org.mamute.model.Question) AnswerAndVotes(org.mamute.model.AnswerAndVotes) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 15 with VRaptorTestResult

use of br.com.caelum.vraptor.test.VRaptorTestResult in project mamute by caelum.

the class AnswerQuestionTest method should_not_display_answer_form_when_already_answered.

@Test
public void should_not_display_answer_form_when_already_answered() {
    Question question = createQuestionWithDao(moderator(), "Titulo da questao hahaha", "Descricao da questao longa demais", tag("java"));
    User karmaNigga = karmaNigga();
    answerQuestionWithDao(karmaNigga, question, "Resposta da questao do teste de edicao", false);
    UserFlow navigation = login(navigate(), karmaNigga.getEmail());
    navigation = goToQuestionPage(navigation, question);
    VRaptorTestResult questionPage = navigation.followRedirect().execute();
    questionPage.wasStatus(200).isValid();
    Elements answerForm = getElementsByClass(questionPage.getResponseBody(), "answer-form");
    assertTrue(answerForm.isEmpty());
}
Also used : User(org.mamute.model.User) UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) Question(org.mamute.model.Question) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Aggregations

VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)28 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)27 Test (org.junit.Test)27 Question (org.mamute.model.Question)15 User (org.mamute.model.User)9 Elements (org.jsoup.select.Elements)5 Answer (org.mamute.model.Answer)5 LoggedUser (org.mamute.model.LoggedUser)4 ArrayList (java.util.ArrayList)3 AnswerAndVotes (org.mamute.model.AnswerAndVotes)3 DaoManager (org.mamute.integration.util.DaoManager)1 Tag (org.mamute.model.Tag)1