@@ -0,0 +1,2537 @@
+package models;%0A%0Aimport static org.fest.assertions.Assertions.assertThat;%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.security.NoSuchAlgorithmException;%0Aimport java.util.List;%0A%0Aimport models.enumeration.Resource;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Apublic class AttachmentTest extends ModelTest%3CAttachment%3E %7B%0A%0A    @Before%0A    public void before() %7B%0A        Attachment.setUploadDirectory(%22resources/test/uploads%22);%0A    %7D%0A%0A    @Test%0A    public void testSaveInUserTemporaryArea() throws IOException, NoSuchAlgorithmException %7B%0A        // Given%0A        File file = createFileWithContents(%22foo.txt%22, %22Hello%22.getBytes());%0A%0A        // When%0A        Attachment attach = new Attachment();%0A        attach.storeInUserTemporaryArea(0L, file, %22bar.txt%22);%0A%0A        FileInputStream is = new FileInputStream(attach.getFile());%0A        byte%5B%5D b = new byte%5B1024%5D;%0A        int length = is.read(b);%0A        is.close();%0A%0A        // Then%0A        assertThat(attach.name).isEqualTo(%22bar.txt%22);%0A        assertThat(attach.mimeType).isEqualTo(%22text/plain%22);%0A        assertThat(new String(b, 0, length)).isEqualTo(new String(%22Hello%22));%0A    %7D%0A%0A    public void testAttachFiles() throws IOException, NoSuchAlgorithmException %7B%0A        // Given%0A        File foo = createFileWithContents(%22foo.txt%22, %22Hello%22.getBytes());%0A        File bar = createFileWithContents(%22bar.html%22, %22%3Cp%3EBye%3C/p%3E%22.getBytes());%0A%0A        // When%0A        new Attachment().storeInUserTemporaryArea(0L, foo, %22foo.txt%22);%0A        new Attachment().storeInUserTemporaryArea(0L, bar, %22bar.html%22);%0A        Attachment.attachFiles(0L, 0L, Resource.ISSUE_POST, 1L);%0A        List%3CAttachment%3E attachedFiles = Attachment.findByContainer(Resource.ISSUE_POST, 1L);%0A%0A        // Then%0A        assertThat(attachedFiles.size()).isEqualTo(2);%0A        assertThat(attachedFiles.get(0).name).isEqualTo(%22foo.txt%22);%0A        assertThat(attachedFiles.get(0).mimeType).isEqualTo(%22text/plain%22);%0A        assertThat(attachedFiles.get(1).name).isEqualTo(%22bar.html%22);%0A        assertThat(attachedFiles.get(1).mimeType).isEqualTo(%22text/html%22);%0A    %7D%0A%0A    public File createFileWithContents(String name, byte%5B%5D contents) throws IOException, FileNotFoundException %7B%0A        File tempFile = java.io.File.createTempFile(name, null);%0A        tempFile.deleteOnExit();%0A        FileOutputStream os = new FileOutputStream(tempFile);%0A        os.write(contents);%0A        os.close();%0A        return tempFile;%0A    %7D%0A%7D

Add missed test should be in 9aed8db.