Search in sources :

Example 21 with VRaptorTestResult

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

the class ForgotPasswordTest method should_accept_recovery_for_existant_email.

@Test
public void should_accept_recovery_for_existant_email() {
    UserFlow navigation = tryToSendResetPasswordEmail(user.getEmail());
    VRaptorTestResult sentEmail = navigation.followRedirect().execute();
    sentEmail.wasStatus(200).isValid();
    List<String> errorsList = errorsList(sentEmail);
    assertTrue(errorsList.isEmpty());
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 22 with VRaptorTestResult

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

the class ForgotPasswordTest method should_loggin_automatically_after_reseted_password_user.

@Test
public void should_loggin_automatically_after_reseted_password_user() {
    VRaptorTestResult newPassword = resetPassword();
    LoggedUser logged = newPassword.getObject("currentUser");
    assertEquals(user.getEmail(), logged.getCurrent().getEmail());
}
Also used : LoggedUser(org.mamute.model.LoggedUser) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 23 with VRaptorTestResult

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

the class ForgotPasswordTest method resetPassword.

private VRaptorTestResult resetPassword() {
    UserFlow sentEmailNavigate = tryToSendResetPasswordEmail(user.getEmail());
    VRaptorTestResult sentEmail = sentEmailNavigate.followRedirect().execute();
    sentEmail.wasStatus(200).isValid();
    String urlFromPasswordToken = manager.getURLFromPasswordToken(user.getEmail());
    UserFlow newPasswordNavigate = tryToSetNewPassword(password, urlFromPasswordToken);
    VRaptorTestResult newPassword = newPasswordNavigate.followRedirect().execute();
    newPassword.wasStatus(200).isValid();
    return newPassword;
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult)

Example 24 with VRaptorTestResult

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

the class ForgotPasswordTest method should_loggin_for_reseted_password_user.

@Test
public void should_loggin_for_reseted_password_user() {
    resetPassword();
    UserFlow navigation3 = loginWithPassword(navigate(), user.getEmail(), password);
    VRaptorTestResult loginResult = navigation3.followRedirect().execute();
    loginResult.wasStatus(200).isValid();
    LoggedUser loggedUser = loginResult.getObject("currentUser");
    assertEquals(user.getEmail(), loggedUser.getCurrent().getEmail());
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) LoggedUser(org.mamute.model.LoggedUser) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 25 with VRaptorTestResult

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