Search in sources :

Example 1 with QuestionInformationBuilder

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

Example 2 with QuestionInformationBuilder

use of org.mamute.model.QuestionInformationBuilder 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 QuestionInformationBuilder

use of org.mamute.model.QuestionInformationBuilder 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 4 with QuestionInformationBuilder

use of org.mamute.model.QuestionInformationBuilder in project mamute by caelum.

the class InformationDAOTest method newChangesWithStatus.

private void newChangesWithStatus(Question question, int times, UpdateStatus status) {
    for (int i = 0; i < times; i++) {
        QuestionInformation questionInfo = new QuestionInformationBuilder().withTag(java).with(author).build();
        question.enqueueChange(questionInfo, status);
    }
}
Also used : QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) QuestionInformation(org.mamute.model.QuestionInformation)

Example 5 with QuestionInformationBuilder

use of org.mamute.model.QuestionInformationBuilder in project mamute by caelum.

the class QuestionInformationTest method setup.

@Before
public void setup() {
    builder = new QuestionInformationBuilder();
    ruby = new QuestionBuilder().withTitle("how do i program using ruby?").build();
}
Also used : QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) QuestionBuilder(org.mamute.builder.QuestionBuilder) Before(org.junit.Before)

Aggregations

QuestionInformationBuilder (org.mamute.model.QuestionInformationBuilder)7 QuestionInformation (org.mamute.model.QuestionInformation)6 Test (org.junit.Test)5 Question (org.mamute.model.Question)5 User (org.mamute.model.User)3 Tag (org.mamute.model.Tag)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 QuestionBuilder (org.mamute.builder.QuestionBuilder)1 Information (org.mamute.model.Information)1 ModeratableAndPendingHistory (org.mamute.model.ModeratableAndPendingHistory)1