Search in sources :

Example 76 with User

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

the class AuthorRuleTest method should_allow_moderatable_author.

@Test
public void should_allow_moderatable_author() {
    AuthorRule<Moderatable> rule = new AuthorRule<>();
    User author = user("author", "author@brutal.com", 1l);
    User other = user("other", "other@brutal.com", 2l);
    Question question = new QuestionBuilder().withAuthor(author).build();
    assertFalse(rule.isAllowed(other, question));
    assertTrue(rule.isAllowed(author, question));
}
Also used : AuthorRule(org.mamute.auth.rules.AuthorRule) User(org.mamute.model.User) QuestionBuilder(org.mamute.builder.QuestionBuilder) Question(org.mamute.model.Question) Moderatable(org.mamute.model.interfaces.Moderatable) Test(org.junit.Test)

Example 77 with User

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

the class MinimumKarmaRuleTest method should_disallow_user_with_low_karma.

@Test
public void should_disallow_user_with_low_karma() {
    User noob = user("noob", "noob@brutal.com");
    setKarma(noob, 1l);
    assertFalse(rule.isAllowed(noob, null));
}
Also used : User(org.mamute.model.User) Test(org.junit.Test)

Example 78 with User

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

the class MinimumKarmaRuleTest method should_allow_user_with_enough_karma.

@Test
public void should_allow_user_with_enough_karma() {
    User u = user("user with 10 karma", "karma@brutal.com");
    setKarma(u, 10l);
    assertTrue(rule.isAllowed(u, null));
}
Also used : User(org.mamute.model.User) Test(org.junit.Test)

Example 79 with User

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

the class IndexSyncJob method generateUser.

private InvisibleForUsersRule generateUser() {
    User user = new User(fromTrustedText("System"), "system");
    LoggedUser loggedUser = new LoggedUser(user, null);
    return new InvisibleForUsersRule(loggedUser);
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) LoggedUser(org.mamute.model.LoggedUser) InvisibleForUsersRule(org.mamute.dao.InvisibleForUsersRule)

Example 80 with User

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

the class CommentTest method should_verify_that_user_flagged_a_comment.

@Test
public void should_verify_that_user_flagged_a_comment() {
    User author = user("name", "email@email", 1l);
    User other = user("other", "other@brutal.com", 2l);
    User commentAuthor = user("name", "email@email", 1l);
    Comment comment = comment(commentAuthor, "comment");
    Flag flag = new Flag(FlagType.RUDE, author);
    comment.add(flag);
    assertTrue(comment.alreadyFlaggedBy(author));
    assertFalse(comment.alreadyFlaggedBy(other));
}
Also used : Comment(org.mamute.model.Comment) User(org.mamute.model.User) Flag(org.mamute.model.Flag) Test(org.junit.Test)

Aggregations

User (org.mamute.model.User)97 Test (org.junit.Test)56 Question (org.mamute.model.Question)28 LoggedUser (org.mamute.model.LoggedUser)25 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)9 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)9 Answer (org.mamute.model.Answer)9 LoginMethod (org.mamute.model.LoginMethod)9 Post (br.com.caelum.vraptor.Post)7 Before (org.junit.Before)7 Tag (org.mamute.model.Tag)7 QuestionInformation (org.mamute.model.QuestionInformation)6 Email (org.apache.commons.mail.Email)5 UserPersonalInfo (org.mamute.dto.UserPersonalInfo)5 ReputationEvent (org.mamute.model.ReputationEvent)5 ArrayList (java.util.ArrayList)4 Watcher (org.mamute.model.watch.Watcher)4 DateTime (org.joda.time.DateTime)3 Elements (org.jsoup.select.Elements)3 DaoManager (org.mamute.integration.util.DaoManager)3