use of org.mamute.model.User 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.User in project mamute by caelum.
the class QuestionTest method should_not_be_touched_when_marked_as_solved.
@Test
public void should_not_be_touched_when_marked_as_solved() {
Question shouldILiveForever = question.build();
User touchedBy = shouldILiveForever.getLastTouchedBy();
User leo = user("", "");
Answer yes = answer("my answer", shouldILiveForever, leo);
assertEquals(User.GHOST, shouldILiveForever.getLastTouchedBy());
shouldILiveForever.markAsSolvedBy(yes);
assertEquals(touchedBy, shouldILiveForever.getLastTouchedBy());
}
use of org.mamute.model.User in project mamute by caelum.
the class QuestionTest method should_return_false_if_is_author_and_there_is_solution.
@Test
public void should_return_false_if_is_author_and_there_is_solution() throws Exception {
User author = user("Fernanda", "bla@bla.com", 1l);
Question question = question(author);
Answer answer = answer("", question, author);
question.markAsSolvedBy(answer);
assertFalse(question.canMarkAsSolution(author));
}
use of org.mamute.model.User 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));
}
use of org.mamute.model.User 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());
}
Aggregations