Search in sources :

Example 6 with QuestionInformationBuilder

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

Example 7 with QuestionInformationBuilder

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

the class QuestionTest method should_be_touched_by_original_author_after_edit.

@Test
public void should_be_touched_by_original_author_after_edit() throws Exception {
    User artur = user("artur", "artur@x.com");
    artur.setId(1l);
    Question comoFaz = question.withTitle("titulo").withDescription("descricao").withAuthor(artur).build();
    User leo = user("leo", "leo@x.com");
    leo.setId(2l);
    QuestionInformation info = new QuestionInformationBuilder().with(leo).build();
    comoFaz.updateWith(info, updater);
    assertEquals(comoFaz.getLastTouchedBy().getId(), artur.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)

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