Search in sources :

Example 21 with LoggedUser

use of org.mamute.model.LoggedUser 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 22 with LoggedUser

use of org.mamute.model.LoggedUser 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 23 with LoggedUser

use of org.mamute.model.LoggedUser in project mamute by caelum.

the class DaoManager method answerQuestion.

public Answer answerQuestion(User author, Question question, String description, boolean watching) {
    this.session.beginTransaction();
    LoggedUser loggedUser = new LoggedUser(author, null);
    AnswerInformation information = new AnswerInformation(notMarked(description), loggedUser, "new answer");
    Answer answer = new Answer(information, question, author);
    this.answerDao.save(answer);
    this.session.getTransaction().commit();
    return answer;
}
Also used : Answer(org.mamute.model.Answer) LoggedUser(org.mamute.model.LoggedUser) AnswerInformation(org.mamute.model.AnswerInformation)

Example 24 with LoggedUser

use of org.mamute.model.LoggedUser in project mamute by caelum.

the class ReputationEventDAOTest method setup.

@Before
public void setup() {
    reputationEvents = new ReputationEventDAO(session, new InvisibleForUsersRule(new LoggedUser(author, null)));
    author = user("Brutal User", "brutal@brutal.com");
    tag = tag("java");
    questionInvolved1 = question(author, tag);
    questionInvolved2 = question(author, tag);
    questionInvolved3 = question(author, tag);
    session.save(author);
    session.save(tag);
    session.save(questionInvolved1);
    session.save(questionInvolved2);
    session.save(questionInvolved3);
}
Also used : LoggedUser(org.mamute.model.LoggedUser) Before(org.junit.Before)

Example 25 with LoggedUser

use of org.mamute.model.LoggedUser in project mamute by caelum.

the class WithUserPaginatedDAOTest method setup.

@Before
public void setup() {
    session.save(author);
    session.save(upVote);
    session.save(upVote2);
    session.save(upVote3);
    session.save(defaultTag);
    InvisibleForUsersRule invisibleFilter = new InvisibleForUsersRule(new LoggedUser(author, null));
    questionsWithUser = new WithUserPaginatedDAO<Question>(session, Question.class, UserRole.AUTHOR, invisibleFilter);
    answersWithUser = new WithUserPaginatedDAO<Answer>(session, Answer.class, UserRole.AUTHOR, invisibleFilter);
}
Also used : Answer(org.mamute.model.Answer) LoggedUser(org.mamute.model.LoggedUser) Question(org.mamute.model.Question) InvisibleForUsersRule(org.mamute.dao.InvisibleForUsersRule) Before(org.junit.Before)

Aggregations

LoggedUser (org.mamute.model.LoggedUser)36 Test (org.junit.Test)24 Before (org.junit.Before)9 User (org.mamute.model.User)9 InvisibleForUsersRule (org.mamute.dao.InvisibleForUsersRule)7 ServletContext (javax.servlet.ServletContext)6 EnvironmentKarma (org.mamute.brutauth.auth.rules.EnvironmentKarma)6 MamuteEnvironment (org.mamute.vraptor.environment.MamuteEnvironment)6 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)4 Criterion (org.hibernate.criterion.Criterion)4 Answer (org.mamute.model.Answer)4 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)3 EditAnswerRule (org.mamute.brutauth.auth.rules.EditAnswerRule)3 EditQuestionRule (org.mamute.brutauth.auth.rules.EditQuestionRule)3 AnswerInformation (org.mamute.model.AnswerInformation)3 Comment (org.mamute.model.Comment)3 Question (org.mamute.model.Question)3 QuestionInformation (org.mamute.model.QuestionInformation)3 Tag (org.mamute.model.Tag)3 UpdateStatus (org.mamute.model.UpdateStatus)3