use of org.mamute.model.Question in project mamute by caelum.
the class UpdatablesAndPendingHistoryTest method should_build_group_informations_by_updatable.
@Test
public void should_build_group_informations_by_updatable() {
List<Object[]> updatableAndInformations = new ArrayList<>();
User author = user("name", "emaiil");
QuestionInformationBuilder builder = new QuestionInformationBuilder().with(author);
QuestionInformation info1 = builder.withTitle("title1").build();
QuestionInformation info2 = builder.withTitle("title2").build();
Question question1 = new Question(info1, author);
question1.setId(1l);
QuestionInformation info3 = builder.withTitle("title3").build();
QuestionInformation info4 = builder.withTitle("title4").build();
Question question2 = new Question(info3, author);
question2.setId(2l);
updatableAndInformations.add(new Object[] { question1, info1 });
updatableAndInformations.add(new Object[] { question1, info2 });
updatableAndInformations.add(new Object[] { question2, info3 });
updatableAndInformations.add(new Object[] { question2, info4 });
ModeratableAndPendingHistory updatablesAndPendingHistory = new ModeratableAndPendingHistory(updatableAndInformations);
List<Information> pendingInfoForQ1 = updatablesAndPendingHistory.pendingInfoFor(question1);
List<Information> pendingInfoForQ2 = updatablesAndPendingHistory.pendingInfoFor(question2);
assertEquals(2, pendingInfoForQ1.size());
assertEquals("title1", ((QuestionInformation) pendingInfoForQ1.get(0)).getTitle());
assertEquals("title2", ((QuestionInformation) pendingInfoForQ1.get(1)).getTitle());
assertEquals(2, pendingInfoForQ2.size());
assertEquals("title3", ((QuestionInformation) pendingInfoForQ2.get(0)).getTitle());
assertEquals("title4", ((QuestionInformation) pendingInfoForQ2.get(1)).getTitle());
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method should_return_true_if_question_has_pending_edits.
@Test
public void should_return_true_if_question_has_pending_edits() throws Exception {
Tag ruby = tag("ruby");
Tag java = tag("java");
Question q = question.withTag(ruby).build();
assertFalse(q.hasPendingEdits());
QuestionInformation approved = new QuestionInformationBuilder().withTag(java).build();
q.enqueueChange(approved, PENDING);
assertTrue(q.hasPendingEdits());
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method can_not_be_marked_as_solved_by_the_an_answer_that_is_not_mine.
@Test(expected = RuntimeException.class)
public void can_not_be_marked_as_solved_by_the_an_answer_that_is_not_mine() {
Question shouldILiveForever = question.build();
Answer yes = answer("", null, null);
shouldILiveForever.markAsSolvedBy(yes);
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method should_verify_that_a_user_already_answered_question.
@Test
public void should_verify_that_a_user_already_answered_question() throws Exception {
Question q = question.build();
User author = user("author", "author@brutal.com", 1l);
User other = user("other", "other@brutal.com", 2l);
answer("my answer", q, author);
assertTrue(q.alreadyAnsweredBy(author));
assertFalse(q.alreadyAnsweredBy(other));
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionTest method return_false_if_answer_was_last_touched_today.
@Test
public void return_false_if_answer_was_last_touched_today() throws Exception {
final Question myQuestion = question.withTitle("question title").withDescription("description").build();
assertFalse(myQuestion.isInactiveForOneMonth());
}
Aggregations