Search in sources :

Example 1 with LoggedUser

use of org.mamute.model.LoggedUser 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));
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) 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 2 with LoggedUser

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

the class VoteDAOTest method beforeTest.

@Before
public void beforeTest() {
    votes = new VoteDAO(session);
    currentUser = user("Current User", "currentUser@email.com");
    otherUser = user("Other User", "otherUser@email.com");
    session.save(otherUser);
    session.save(currentUser);
    tags.add(tag("bla"));
    for (Tag tag : tags) {
        session.save(tag);
    }
    InvisibleForUsersRule invisibleRule = new InvisibleForUsersRule(new LoggedUser(currentUser, null));
    votingMachine = new VotingMachine(votes, new KarmaCalculator(), new ReputationEventDAO(session, invisibleRule), new MassiveVote(), new RetrieveKarmaDownvote());
}
Also used : VotingMachine(org.mamute.model.vote.VotingMachine) RetrieveKarmaDownvote(org.mamute.controllers.RetrieveKarmaDownvote) ReputationEventDAO(org.mamute.dao.ReputationEventDAO) KarmaCalculator(org.mamute.reputation.rules.KarmaCalculator) LoggedUser(org.mamute.model.LoggedUser) MassiveVote(org.mamute.model.vote.MassiveVote) SuspectMassiveVote(org.mamute.dto.SuspectMassiveVote) VoteDAO(org.mamute.dao.VoteDAO) Tag(org.mamute.model.Tag) InvisibleForUsersRule(org.mamute.dao.InvisibleForUsersRule) Before(org.junit.Before)

Example 3 with LoggedUser

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

the class WatcherDAOTest method set_up.

@Before
public void set_up() {
    User leo = user("Leonardo", "leo@leo.com");
    session.save(leo);
    Tag java = tag("java");
    session.save(java);
    question = question(leo, java);
    session.save(question);
    watchers = new WatcherDAO(session, new InvisibleForUsersRule(new LoggedUser(leo, null)));
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) WatcherDAO(org.mamute.dao.WatcherDAO) LoggedUser(org.mamute.model.LoggedUser) Tag(org.mamute.model.Tag) InvisibleForUsersRule(org.mamute.dao.InvisibleForUsersRule) Before(org.junit.Before)

Example 4 with LoggedUser

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

the class UpdaterTest method should_be_pending_if_is_not_author.

@Test
public void should_be_pending_if_is_not_author() {
    User user = user("chico", "chico@gmail.com", nextId());
    QuestionInformation newInformation = new QuestionInformation("title", notMarked("description"), new LoggedUser(user, null));
    UpdateStatus update = updater.update(myQuestion, newInformation);
    assertEquals(UpdateStatus.PENDING, update);
    assertTrue(myQuestion.getHistory().contains(newInformation));
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) UpdateStatus(org.mamute.model.UpdateStatus) LoggedUser(org.mamute.model.LoggedUser) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 5 with LoggedUser

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

the class InformationDAOTest method setup.

@Before
public void setup() {
    author = user("namename", "email@gmail.com");
    currentAuthor = new LoggedUser(author, null);
    java = new Tag("java", "", null);
    session.save(author);
    session.save(java);
    informations = new InformationDAO(session);
    question = newQuestion(author);
}
Also used : LoggedUser(org.mamute.model.LoggedUser) Tag(org.mamute.model.Tag) 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