use of org.mamute.model.User in project mamute by caelum.
the class UserLogger method logUser.
public void logUser(@Observes MethodReady methodReady) {
String userName = "anonymous";
if (loggedUser.isLoggedIn()) {
User user = loggedUser.getCurrent();
String name = user.getName();
String id = user.getId().toString();
userName = format("%s (id=%s)", name, id);
}
String realIp = clientIp.get();
String uri = request.getRequestURI();
String method = getMethod();
String log = format("%s -> %s from %s %s", method, uri, userName, realIp);
LOG.info(log);
}
use of org.mamute.model.User in project mamute by caelum.
the class AnswerQuestionTest method should_not_display_answer_form_when_already_answered.
@Test
public void should_not_display_answer_form_when_already_answered() {
Question question = createQuestionWithDao(moderator(), "Titulo da questao hahaha", "Descricao da questao longa demais", tag("java"));
User karmaNigga = karmaNigga();
answerQuestionWithDao(karmaNigga, question, "Resposta da questao do teste de edicao", false);
UserFlow navigation = login(navigate(), karmaNigga.getEmail());
navigation = goToQuestionPage(navigation, question);
VRaptorTestResult questionPage = navigation.followRedirect().execute();
questionPage.wasStatus(200).isValid();
Elements answerForm = getElementsByClass(questionPage.getResponseBody(), "answer-form");
assertTrue(answerForm.isEmpty());
}
use of org.mamute.model.User in project mamute by caelum.
the class AuthTest method should_log_in.
@Test
public void should_log_in() {
User user = randomUser();
UserFlow navigation = login(navigate(), user.getEmail());
VRaptorTestResult loginResult = navigation.followRedirect().execute();
loginResult.wasStatus(200).isValid();
LoggedUser loggedUser = loginResult.getObject("currentUser");
User currentUser = loggedUser.getCurrent();
assertThat(currentUser.getId(), equalTo(user.getId()));
}
use of org.mamute.model.User in project mamute by caelum.
the class EditAnswerTest method should_edit_answer_of_other_author.
@Test
public void should_edit_answer_of_other_author() throws Exception {
User moderator = moderator();
Question question = createQuestionWithDao(moderator, "Titulo da questao hahaha", "Descricao da questao longa demais", tag("java"));
Answer answer = answerQuestionWithDao(moderator, question, "Resposta da questao do teste de edicao", false);
String newDescription = "my new description of the first answer";
UserFlow navigation = login(navigate(), karmaNigga().getEmail());
navigation = editAnswerWithFlow(navigation, answer, newDescription, "comment");
VRaptorTestResult answerEdited = navigation.followRedirect().execute();
answerEdited.wasStatus(200).isValid();
List<String> messagesList = messagesList(answerEdited);
assertTrue(messagesList.contains(message("status.pending")));
}
use of org.mamute.model.User in project mamute by caelum.
the class EditAnswerTest method should_edit_and_automatically_approve_moderator.
@Test
public void should_edit_and_automatically_approve_moderator() throws Exception {
User moderator = moderator();
Question question = createQuestionWithDao(moderator, "Titulo da questao hahaha", "Descricao da questao longa demais", tag("java"));
Answer answer = answerQuestionWithDao(karmaNigga(), question, "Resposta da questao do teste de edicao", false);
String newDescription = "my new description of the first answer";
UserFlow navigation = login(navigate(), moderator.getEmail());
navigation = editAnswerWithFlow(navigation, answer, newDescription, "comment");
VRaptorTestResult answerEdited = navigation.followRedirect().execute();
answerEdited.wasStatus(200).isValid();
List<String> messagesList = messagesList(answerEdited);
assertTrue(messagesList.contains(message("status.no_need_to_approve")));
AnswerAndVotes answerAndVotes = answerEdited.getObject("answers");
List<Answer> answers = new ArrayList<Answer>(answerAndVotes.getVotes().keySet());
assertEquals(newDescription, answers.get(0).getDescription());
}
Aggregations