use of org.mamute.model.User in project mamute by caelum.
the class WatcherDAOTest method should_not_get_innactive_watchers_of_a_question.
@Test
public void should_not_get_innactive_watchers_of_a_question() {
User subscribedWatcher = user("watcher", "watcher@watcher.com");
session.save(subscribedWatcher);
Watcher watch = new Watcher(subscribedWatcher);
watch.inactivate();
watchers.add(question, watch);
assertThat(watchers.of(question), empty());
}
use of org.mamute.model.User in project mamute by caelum.
the class WatcherDAOTest method should_innactivate_watcher.
@Test
public void should_innactivate_watcher() {
User subscribedWatcher = user("watcher", "watcher@watcher.com");
session.save(subscribedWatcher);
Watcher watch = new Watcher(subscribedWatcher);
watch.inactivate();
watchers.add(question, watch);
watchers.ping(question, subscribedWatcher);
assertTrue(watch.isActive());
}
use of org.mamute.model.User 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());
}
use of org.mamute.model.User 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.User in project mamute by caelum.
the class AttachmentRepositoryTest method createAttachment.
private Attachment createAttachment(final String content) {
final User owner = user("attachment owner", "attachment@owner.local");
session.save(owner);
final UploadedFile file = new DefaultUploadedFile(IOUtils.toInputStream(content), "hello.txt", "text/plain", content.length());
final Attachment attachment = new Attachment(file, owner, "127.0.0.1");
return attachment;
}
Aggregations