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));
}
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));
}
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));
}
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);
}
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());
}
Aggregations