You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2017/11/15 11:15:55 UTC
[14/19] james-project git commit: JAMES-2214 Attachment checking
should be extracted from SetMessagesCreationProcessor
JAMES-2214 Attachment checking should be extracted from SetMessagesCreationProcessor
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/20a6c64e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/20a6c64e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/20a6c64e
Branch: refs/heads/master
Commit: 20a6c64ee291fb22f8418ac81d0ca98dd82d809f
Parents: 9f1d767
Author: benwa <bt...@linagora.com>
Authored: Tue Nov 14 10:51:41 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Wed Nov 15 18:05:45 2017 +0700
----------------------------------------------------------------------
.../jmap/methods/AttachmentCheckerTest.java | 61 ++++++++++++++++++++
1 file changed, 61 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/20a6c64e/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/AttachmentCheckerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/AttachmentCheckerTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/AttachmentCheckerTest.java
index c9df8e9..f34eff0 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/AttachmentCheckerTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/AttachmentCheckerTest.java
@@ -79,6 +79,22 @@ public class AttachmentCheckerTest {
}
@Test
+ public void assertAttachmentsExistShouldNotThrowWhenAttachmentExists() throws Exception {
+ BlobId blobId = BlobId.of("unknownBlobId");
+ AttachmentId attachmentId = AttachmentId.from(blobId.getRawValue());
+ when(attachmentManager.exists(attachmentId, session)).thenReturn(true);
+
+ sut.assertAttachmentsExist(
+ new ValueWithId.CreationMessageEntry(
+ creationMessageId,
+ creationMessageBuilder.attachments(
+ Attachment.builder().size(12L).type("image/jpeg").blobId(blobId).build())
+ .build()
+ ),
+ session);
+ }
+
+ @Test
public void assertAttachmentsExistShouldThrowWhenUnknownBlobIds() throws MailboxException {
BlobId unknownBlobId1 = BlobId.of("unknownBlobId1");
BlobId unknownBlobId2 = BlobId.of("unknownBlobId2");
@@ -101,4 +117,49 @@ public class AttachmentCheckerTest {
.matches(e -> ((AttachmentsNotFoundException)e).getAttachmentIds().containsAll(ImmutableSet.of(unknownBlobId1, unknownBlobId2)));
}
+ @Test
+ public void assertAttachmentsExistShouldNotThrowWhenKnownBlobIds() throws Exception {
+ BlobId blobId1 = BlobId.of("unknownBlobId1");
+ BlobId blobId2 = BlobId.of("unknownBlobId2");
+ AttachmentId attachmentId1 = AttachmentId.from(blobId1.getRawValue());
+ AttachmentId attachmentId2 = AttachmentId.from(blobId2.getRawValue());
+
+ when(attachmentManager.exists(attachmentId1, session)).thenReturn(true);
+ when(attachmentManager.exists(attachmentId2, session)).thenReturn(true);
+
+ sut.assertAttachmentsExist(
+ new ValueWithId.CreationMessageEntry(
+ creationMessageId,
+ creationMessageBuilder.attachments(
+ Attachment.builder().size(12L).type("image/jpeg").blobId(blobId1).build(),
+ Attachment.builder().size(23L).type("image/git").blobId(blobId2).build())
+ .build()
+ ),
+ session);
+ }
+
+ @Test
+ public void assertAttachmentsExistShouldThrowWhenAtLeastOneUnknownBlobId() throws MailboxException {
+ BlobId blobId1 = BlobId.of("unknownBlobId1");
+ BlobId unknownBlobId2 = BlobId.of("unknownBlobId2");
+ AttachmentId attachmentId1 = AttachmentId.from(blobId1.getRawValue());
+ AttachmentId unknownAttachmentId2 = AttachmentId.from(unknownBlobId2.getRawValue());
+
+ when(attachmentManager.exists(attachmentId1, session)).thenReturn(true);
+ when(attachmentManager.exists(unknownAttachmentId2, session)).thenReturn(false);
+
+ assertThatThrownBy(() -> sut.assertAttachmentsExist(
+ new ValueWithId.CreationMessageEntry(
+ creationMessageId,
+ creationMessageBuilder.attachments(
+ Attachment.builder().size(12L).type("image/jpeg").blobId(blobId1).build(),
+ Attachment.builder().size(23L).type("image/git").blobId(unknownBlobId2).build())
+ .build()
+ ),
+ session))
+ .isInstanceOf(AttachmentsNotFoundException.class)
+ .matches(e -> ((AttachmentsNotFoundException)e).getAttachmentIds()
+ .containsAll(ImmutableSet.of(unknownBlobId2)));
+ }
+
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org