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