Search in sources :

Example 1 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment in project mamute by caelum.

the class UpdaterTest method before_test.

@Before
public void before_test() throws IOException {
    ServletContext ctx = mock(ServletContext.class);
    EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
    this.updater = new Updater(env);
    author = user("author", "author@gmail", nextId());
    myQuestion = question.withTitle("titel").withDescription("description").withAuthor(author).build();
}
Also used : EnvironmentKarma(org.mamute.brutauth.auth.rules.EnvironmentKarma) MamuteEnvironment(org.mamute.vraptor.environment.MamuteEnvironment) Updater(org.mamute.model.Updater) ServletContext(javax.servlet.ServletContext) Before(org.junit.Before)

Example 2 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment in project mamute by caelum.

the class UserTest method user_with_enough_karma_should_approve_question_information.

@Test
public void user_with_enough_karma_should_approve_question_information() throws Exception {
    Information approvedInfo = new QuestionInformation("edited title", notMarked("edited desc"), new LoggedUser(otherUser, null), new ArrayList<Tag>(), "comment");
    ServletContext ctx = mock(ServletContext.class);
    EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
    moderatorWannabe.approve(myQuestion, approvedInfo, env);
    assertEquals(approvedInfo, myQuestion.getInformation());
    assertTrue(myQuestion.getInformation().isModerated());
}
Also used : EnvironmentKarma(org.mamute.brutauth.auth.rules.EnvironmentKarma) MamuteEnvironment(org.mamute.vraptor.environment.MamuteEnvironment) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Example 3 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment in project mamute by caelum.

the class UserTest method user_with_enough_karma_should_approve_answer_information.

@Test
public void user_with_enough_karma_should_approve_answer_information() throws Exception {
    Answer answer = answer("answer description", myQuestion, author);
    AnswerInformation approvedInfo = answerInformation("new description", otherUser, answer);
    ServletContext ctx = mock(ServletContext.class);
    EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
    moderatorWannabe.approve(answer, approvedInfo, env);
    assertEquals(approvedInfo, answer.getInformation());
    assertTrue(answer.getInformation().isModerated());
}
Also used : EnvironmentKarma(org.mamute.brutauth.auth.rules.EnvironmentKarma) MamuteEnvironment(org.mamute.vraptor.environment.MamuteEnvironment) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Example 4 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment in project mamute by caelum.

the class UserTest method moderator_should_approve_question_information.

@Test
public void moderator_should_approve_question_information() throws Exception {
    Information approvedInfo = new QuestionInformation("edited title", notMarked("edited desc"), new LoggedUser(otherUser, null), new ArrayList<Tag>(), "comment");
    ServletContext ctx = mock(ServletContext.class);
    EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
    moderator.approve(myQuestion, approvedInfo, env);
    assertEquals(approvedInfo, myQuestion.getInformation());
    assertTrue(myQuestion.getInformation().isModerated());
}
Also used : EnvironmentKarma(org.mamute.brutauth.auth.rules.EnvironmentKarma) MamuteEnvironment(org.mamute.vraptor.environment.MamuteEnvironment) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Example 5 with MamuteEnvironment

use of org.mamute.vraptor.environment.MamuteEnvironment in project mamute by caelum.

the class EditAnswerRuleTest method loggedUser_with_enough_karma_should_be_allowed_to_edit.

@Test
public void loggedUser_with_enough_karma_should_be_allowed_to_edit() throws IOException {
    LoggedUser loggedUserWithEnoughKarma = loggedUser("loggedUser", "loggedUser@brutal.com", NOT_AUTHOR);
    loggedUserWithEnoughKarma.getCurrent().increaseKarma(20);
    ServletContext ctx = mock(ServletContext.class);
    EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
    assertTrue(new EditAnswerRule(loggedUserWithEnoughKarma, env).isAllowed(answer));
}
Also used : EnvironmentKarma(org.mamute.brutauth.auth.rules.EnvironmentKarma) MamuteEnvironment(org.mamute.vraptor.environment.MamuteEnvironment) EditAnswerRule(org.mamute.brutauth.auth.rules.EditAnswerRule) ServletContext(javax.servlet.ServletContext) LoggedUser(org.mamute.model.LoggedUser) Test(org.junit.Test)

Aggregations

ServletContext (javax.servlet.ServletContext)14 EnvironmentKarma (org.mamute.brutauth.auth.rules.EnvironmentKarma)14 MamuteEnvironment (org.mamute.vraptor.environment.MamuteEnvironment)14 Test (org.junit.Test)12 LoggedUser (org.mamute.model.LoggedUser)6 EditAnswerRule (org.mamute.brutauth.auth.rules.EditAnswerRule)4 EditQuestionRule (org.mamute.brutauth.auth.rules.EditQuestionRule)4 Before (org.junit.Before)2 Updater (org.mamute.model.Updater)1