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());
}
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());
}
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());
}
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);
}
}
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();
}
Aggregations