This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 2fc93a7722a53e31956c0a32c050e1ee73c87d13
Author: Benoit Tellier <btell...@linagora.com>
AuthorDate: Fri Jan 17 16:41:30 2020 +0700

    JAMES-2997 Renable AttachmentTest
---
 .../apache/james/mailbox/model/AttachmentTest.java | 74 +++-------------------
 1 file changed, 8 insertions(+), 66 deletions(-)

diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java 
b/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java
index 7d85b29..e99cd7e 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java
@@ -20,59 +20,11 @@
 
 package org.apache.james.mailbox.model;
 
-import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.commons.io.IOUtils;
 import org.junit.jupiter.api.Test;
 
 class AttachmentTest {
-
-    private static Charset CHARSET = StandardCharsets.UTF_8;
-/*
-    @Test
-    void streamShouldBeConsumedOneTime() throws Exception {
-        String input = "mystream";
-        Attachment attachment = Attachment.builder()
-                .bytes(input.getBytes(CHARSET))
-                .type("content")
-                .build();
-
-        InputStream stream = attachment.getStream();
-        assertThat(stream).isNotNull();
-        assertThat(IOUtils.toString(stream, CHARSET)).isEqualTo(input);
-    }
-
-    @Test
-    void getByteShouldReturnByteArrayRepresentingTheAttachment() {
-        String input = "mystream";
-        Attachment attachment = Attachment.builder()
-            .bytes(input.getBytes(CHARSET))
-            .type("content")
-            .build();
-
-        byte[] bytes = attachment.getBytes();
-        assertThat(new String(bytes, CHARSET)).isEqualTo(input);
-    }
-
-    @Test
-    void streamShouldBeConsumedMoreThanOneTime() throws Exception {
-        String input = "mystream";
-        Attachment attachment = Attachment.builder()
-                .bytes(input.getBytes(CHARSET))
-                .type("content")
-                .build();
-
-        attachment.getStream();
-        InputStream stream = attachment.getStream();
-        assertThat(stream).isNotNull();
-        assertThat(IOUtils.toString(stream, CHARSET)).isEqualTo(input);
-    }
-
     @Test
     void builderShouldThrowWhenAttachmentIdIsNull() {
         assertThatThrownBy(() -> Attachment.builder()
@@ -81,13 +33,6 @@ class AttachmentTest {
     }
 
     @Test
-    void builderShouldThrowWhenBytesIsNull() {
-        assertThatThrownBy(() -> Attachment.builder()
-                .bytes(null))
-            .isInstanceOf(IllegalArgumentException.class);
-    }
-
-    @Test
     void builderShouldThrowWhenTypeIsNull() {
         assertThatThrownBy(() -> Attachment.builder()
                 .type(null))
@@ -109,9 +54,10 @@ class AttachmentTest {
     }
 
     @Test
-    void buildShouldThrowWhenBytesIsNotProvided() {
+    void buildShouldThrowWhenSizeIsNotProvided() {
         assertThatThrownBy(() -> Attachment.builder()
                 .attachmentId(AttachmentId.random())
+                .type("TYPE")
                 .build())
             .isInstanceOf(IllegalStateException.class);
     }
@@ -120,20 +66,16 @@ class AttachmentTest {
     void buildShouldThrowWhenTypeIsNotProvided() {
         assertThatThrownBy(() -> Attachment.builder()
                 .attachmentId(AttachmentId.random())
-                .bytes("mystream".getBytes(CHARSET))
+                .size(36)
                 .build())
             .isInstanceOf(IllegalStateException.class);
     }
 
     @Test
-    void buildShouldSetTheSize() {
-        String input = "mystream";
-        Attachment attachment = Attachment.builder()
-                .bytes(input.getBytes(CHARSET))
-                .type("content")
-                .build();
-
-        
assertThat(attachment.getSize()).isEqualTo(input.getBytes(CHARSET).length);
+    void sizeShouldThrowOnNegativeValue() {
+        assertThatThrownBy(() -> Attachment.builder()
+                .attachmentId(AttachmentId.random())
+                .size(-3))
+            .isInstanceOf(IllegalArgumentException.class);
     }
-*/
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to