use of org.mamute.dao.InvisibleForUsersRule 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());
}
use of org.mamute.dao.InvisibleForUsersRule 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)));
}
use of org.mamute.dao.InvisibleForUsersRule 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.dao.InvisibleForUsersRule 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.dao.InvisibleForUsersRule 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);
}
Aggregations