Search in sources :

Example 6 with LoggedUser

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

the class InvisibleForUsersRuleTest method should_not_add_filter_if_user_is_moderator.

@Test
public void should_not_add_filter_if_user_is_moderator() {
    LoggedUser user = new LoggedUser(user("leonardo", "leo@leo.com").asModerator(), null);
    InvisibleForUsersRule invisibleForUsersRule = new InvisibleForUsersRule(user);
    invisibleForUsersRule.addFilter("x", criteria);
    verify(criteria, never()).add(Mockito.any(Criterion.class));
}
Also used : Criterion(org.hibernate.criterion.Criterion) LoggedUser(org.mamute.model.LoggedUser) InvisibleForUsersRule(org.mamute.dao.InvisibleForUsersRule) Test(org.junit.Test)

Example 7 with LoggedUser

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

the class InvisibleForUsersRuleTest method should_add_filter_if_user_is_not_moderator.

@Test
public void should_add_filter_if_user_is_not_moderator() {
    LoggedUser user = new LoggedUser(user("leonardo", "leo@leo.com"), null);
    InvisibleForUsersRule invisibleForUsersRule = new InvisibleForUsersRule(user);
    invisibleForUsersRule.addFilter("x", criteria);
    verify(criteria, only()).add(Mockito.any(Criterion.class));
}
Also used : Criterion(org.hibernate.criterion.Criterion) LoggedUser(org.mamute.model.LoggedUser) InvisibleForUsersRule(org.mamute.dao.InvisibleForUsersRule) Test(org.junit.Test)

Example 8 with LoggedUser

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

the class ModeratorOrVisibleNewsFilterTest method should_not_add_filter_if_user_is_moderator.

@Test
public void should_not_add_filter_if_user_is_moderator() {
    LoggedUser user = new LoggedUser(user("leonardo", "leo@leo.com").asModerator(), null);
    ModeratorOrVisibleNewsFilter moderatorOrVisible = new ModeratorOrVisibleNewsFilter(user, null);
    moderatorOrVisible.addFilter("x", criteria);
    verify(criteria, never()).add(Mockito.any(Criterion.class));
}
Also used : ModeratorOrVisibleNewsFilter(org.mamute.dao.ModeratorOrVisibleNewsFilter) Criterion(org.hibernate.criterion.Criterion) LoggedUser(org.mamute.model.LoggedUser) Test(org.junit.Test)

Example 9 with LoggedUser

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

the class NewsDAOTest method setup.

@Before
public void setup() {
    session.save(regularUser);
    session.save(newsAuthor);
    session.save(moderator);
    VisibleNewsFilter visibleNewsFilter = new VisibleNewsFilter();
    ModeratorOrVisibleNewsFilter moderatorOrVisible = new ModeratorOrVisibleNewsFilter(new LoggedUser(regularUser, null), visibleNewsFilter);
    newsForRegularUsers = new NewsDAO(session, moderatorOrVisible, visibleNewsFilter);
    newsForModerator = new NewsDAO(session, new ModeratorOrVisibleNewsFilter(new LoggedUser(moderator, null), visibleNewsFilter), visibleNewsFilter);
}
Also used : LoggedUser(org.mamute.model.LoggedUser) Before(org.junit.Before)

Example 10 with LoggedUser

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

the class RemoveAnythingFlaggedByModeratorTest method should_remove_comment_after_moderator_flag.

@Test
public void should_remove_comment_after_moderator_flag() {
    RemoveAnythingFlaggedByModerator removeFlaggedByModerator = new RemoveAnythingFlaggedByModerator(new LoggedUser(user, null));
    Comment comment = comment(author, "blablablablba");
    removeFlaggedByModerator.fire(comment);
    assertFalse(comment.isVisible());
}
Also used : Comment(org.mamute.model.Comment) LoggedUser(org.mamute.model.LoggedUser) RemoveAnythingFlaggedByModerator(org.mamute.model.flag.RemoveAnythingFlaggedByModerator) Test(org.junit.Test)

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