use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method should_update_information_status_and_last_touched_by.
@Test
public void should_update_information_status_and_last_touched_by() throws Exception {
User artur = user("", "");
User leo = user("", "");
artur.setId(1l);
leo.setId(2l);
Question comoFaz = question.withTitle("titulo").withDescription("descricao").withAuthor(artur).build();
QuestionInformation comoFazEditedInformation = new QuestionInformationBuilder().with(leo).build();
comoFaz.updateWith(comoFazEditedInformation, updater);
comoFaz.approve(comoFazEditedInformation);
assertEquals(comoFaz.getLastTouchedBy().getId(), leo.getId());
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method should_return_false_if_is_author_and_there_is_solution.
@Test
public void should_return_false_if_is_author_and_there_is_solution() throws Exception {
User author = user("Fernanda", "bla@bla.com", 1l);
Question question = question(author);
Answer answer = answer("", question, author);
question.markAsSolvedBy(answer);
assertFalse(question.canMarkAsSolution(author));
}
use of org.mamute.model.Question in project mamute by caelum.
the class SolrQuestionIndexTest method createQuestion.
private Question createQuestion(Long id, String title, String description, Tag... tags) {
Question question = questionBuilder.withId(id).withTitle(title).withDescription(description).withTags(Arrays.<Tag>asList(tags)).withAuthor(author).build();
sut.indexQuestion(question);
return question;
}
use of org.mamute.model.Question in project mamute by caelum.
the class AnswerAndVotesTest method should_fill_value_with_null_only_answers_that_has_no_currentUserVote.
@Test
public void should_fill_value_with_null_only_answers_that_has_no_currentUserVote() {
Question q = question.build();
Object[] first = new Object[] { answerFor(q, 1), mock(Vote.class) };
Object[] second = new Object[] { answerFor(q, 2), mock(Vote.class) };
Answer third = answerFor(q, 3);
List<Object[]> voteList = new ArrayList<>();
voteList.add(first);
voteList.add(second);
List<Answer> answers = new ArrayList<>();
answers.add((Answer) first[0]);
answers.add((Answer) second[0]);
answers.add(third);
AnswerAndVotes votes = new AnswerAndVotes(q, answers, voteList);
Map<Answer, Vote> map = votes.getVotes();
assertEquals(first[1], map.get(first[0]));
assertEquals(second[1], map.get(second[0]));
assertEquals(null, map.get(third));
assertTrue(map.containsKey(third));
}
use of org.mamute.model.Question in project mamute by caelum.
the class AnswerTest method should_approve_answer_info.
@Test
public void should_approve_answer_info() throws Exception {
Question myQuestion = question.withTitle("question title").withDescription("description").withAuthor(author).build();
Answer answer = answer("blablablab", myQuestion, author);
Information approved = new AnswerInformation(notMarked("blablabalblab"), new LoggedUser(editUser, null), answer, "");
answer.approve(approved);
assertEquals(approved, answer.getInformation());
assertEquals(editUser, answer.getLastTouchedBy());
}
Aggregations