Search in sources :

Example 1 with Question

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());
}
Also used : User(org.mamute.model.User) ModeratableAndPendingHistory(org.mamute.model.ModeratableAndPendingHistory) QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) ArrayList(java.util.ArrayList) Question(org.mamute.model.Question) Information(org.mamute.model.Information) QuestionInformation(org.mamute.model.QuestionInformation) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 2 with Question

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());
}
Also used : QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) Question(org.mamute.model.Question) Tag(org.mamute.model.Tag) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 3 with Question

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);
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 4 with Question

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));
}
Also used : User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 5 with Question

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());
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

Aggregations

Question (org.mamute.model.Question)96 Test (org.junit.Test)74 User (org.mamute.model.User)28 Answer (org.mamute.model.Answer)24 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)15 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)15 Tag (org.mamute.model.Tag)9 ArrayList (java.util.ArrayList)8 QuestionBuilder (org.mamute.builder.QuestionBuilder)7 QuestionInformation (org.mamute.model.QuestionInformation)7 DateTime (org.joda.time.DateTime)6 LoggedUser (org.mamute.model.LoggedUser)5 QuestionInformationBuilder (org.mamute.model.QuestionInformationBuilder)5 Elements (org.jsoup.select.Elements)4 AnswerAndVotes (org.mamute.model.AnswerAndVotes)4 Comment (org.mamute.model.Comment)4 Get (br.com.caelum.vraptor.Get)3 Before (org.junit.Before)3 DaoManager (org.mamute.integration.util.DaoManager)3 AnswerInformation (org.mamute.model.AnswerInformation)3