Search in sources :

Example 6 with QuestionInformation

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

the class UpdaterTest method should_be_pending_if_is_not_author.

@Test
public void should_be_pending_if_is_not_author() {
    User user = user("chico", "chico@gmail.com", nextId());
    QuestionInformation newInformation = new QuestionInformation("title", notMarked("description"), new LoggedUser(user, null));
    UpdateStatus update = updater.update(myQuestion, newInformation);
    assertEquals(UpdateStatus.PENDING, update);
    assertTrue(myQuestion.getHistory().contains(newInformation));
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) UpdateStatus(org.mamute.model.UpdateStatus) LoggedUser(org.mamute.model.LoggedUser) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 7 with QuestionInformation

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

the class QuestionBuilder method build.

public Question build() {
    QuestionInformation questionInformation = informationBuilder.withTitle(title).withDescription(description).with(author).withTags(tags).withComment(comment).build();
    Question q = new Question(questionInformation, author);
    setId(q, id);
    clear();
    return q;
}
Also used : Question(org.mamute.model.Question) QuestionInformation(org.mamute.model.QuestionInformation)

Example 8 with QuestionInformation

use of org.mamute.model.QuestionInformation 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 9 with QuestionInformation

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

the class QuestionInformationTest method should_verify_if_is_not_before_current_information.

@Test
public void should_verify_if_is_not_before_current_information() throws InterruptedException {
    QuestionInformation infoByModerator = builder.build();
    ruby.approve(infoByModerator);
    Thread.sleep(100);
    QuestionInformation version = builder.build();
    ruby.enqueueChange(version, PENDING);
    assertFalse(version.isBeforeCurrent());
}
Also used : QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 10 with QuestionInformation

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

the class QuestionTest method should_update_information_and_tag_usage_count.

@Test
public void should_update_information_and_tag_usage_count() throws Exception {
    Tag ruby = tag("ruby");
    Tag java = tag("java");
    Question q = question.withTag(ruby).build();
    QuestionInformation approved = new QuestionInformationBuilder().withTag(java).build();
    q.updateApproved(approved);
    assertEquals(0l, ruby.getUsageCount().longValue());
    assertEquals(1l, java.getUsageCount().longValue());
}
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)

Aggregations

QuestionInformation (org.mamute.model.QuestionInformation)13 Test (org.junit.Test)11 Question (org.mamute.model.Question)6 QuestionInformationBuilder (org.mamute.model.QuestionInformationBuilder)6 User (org.mamute.model.User)5 LoggedUser (org.mamute.model.LoggedUser)3 UpdateStatus (org.mamute.model.UpdateStatus)3 DateTime (org.joda.time.DateTime)2 Tag (org.mamute.model.Tag)2 ArrayList (java.util.ArrayList)1 Information (org.mamute.model.Information)1 ModeratableAndPendingHistory (org.mamute.model.ModeratableAndPendingHistory)1