use of org.mamute.model.Question in project mamute by caelum.
the class WithUserPaginatedDAOTest method should_return_only_questions_with_the_provided_user_ordered_by_date.
@Test
public void should_return_only_questions_with_the_provided_user_ordered_by_date() {
DateTimeUtils.setCurrentMillisFixed(new DateTime().minusMonths(2).getMillis());
Question javaEEQuestion = javaEEQuestion();
DateTimeUtils.setCurrentMillisSystem();
DateTimeUtils.setCurrentMillisFixed(new DateTime().minusMonths(1).getMillis());
Question androidQuestion = androidQuestion();
DateTimeUtils.setCurrentMillisSystem();
Question javaQuestion = javaQuestion();
List<Question> perguntasDoAuthor = questionsWithUser.by(author, ByDate, 1);
assertTrue(perguntasDoAuthor.contains(javaQuestion));
assertTrue(perguntasDoAuthor.contains(javaEEQuestion));
assertTrue(perguntasDoAuthor.contains(androidQuestion));
assertEquals(javaQuestion, perguntasDoAuthor.get(0));
assertEquals(androidQuestion, perguntasDoAuthor.get(1));
assertEquals(javaEEQuestion, perguntasDoAuthor.get(2));
}
use of org.mamute.model.Question in project mamute by caelum.
the class WithUserPaginatedDAOTest method setup.
@Before
public void setup() {
session.save(author);
session.save(upVote);
session.save(upVote2);
session.save(upVote3);
session.save(defaultTag);
InvisibleForUsersRule invisibleFilter = new InvisibleForUsersRule(new LoggedUser(author, null));
questionsWithUser = new WithUserPaginatedDAO<Question>(session, Question.class, UserRole.AUTHOR, invisibleFilter);
answersWithUser = new WithUserPaginatedDAO<Answer>(session, Answer.class, UserRole.AUTHOR, invisibleFilter);
}
use of org.mamute.model.Question in project mamute by caelum.
the class WithUserPaginatedDAOTest method androidQuestion.
private Question androidQuestion() {
Question q = question.withTitle("Some question about android and other stuff?").withDescription("Please help solving my question about android! Thanks, guys!").withAuthor(author).withTag(defaultTag).build();
session.save(q);
return q;
}
use of org.mamute.model.Question in project mamute by caelum.
the class AttachmentRepositoryTest method should_detach_from_question.
@Test
public void should_detach_from_question() {
final User author = user("question owner", "question@owner.local");
session.save(author);
final Attachment attachment = createAttachment("test");
attachmentRepository.save(attachment);
final Tag tag = tag("testtag");
session.save(tag);
final Question question = question(author, tag);
question.getAttachments().add(attachment);
session.save(question);
attachmentRepository.delete(question.getAttachments());
assertEquals(0, question.getAttachments().size());
}
use of org.mamute.model.Question in project mamute by caelum.
the class AttachmentRepositoryTest method should_detach_from_answer.
@Test
public void should_detach_from_answer() {
final User author = user("question owner", "question@owner.local");
session.save(author);
final Attachment attachment = createAttachment("test");
attachmentRepository.save(attachment);
final Tag tag = tag("testtag");
session.save(tag);
final Question question = question(author, tag);
session.save(question);
final Answer answer = answer("answer answer answer answer answer", question, author);
answer.getAttachments().add(attachment);
session.save(answer);
attachmentRepository.delete(answer.getAttachments());
assertEquals(0, answer.getAttachments().size());
}
Aggregations