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

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

commit d01747f3d5929b015f257aa603a6296bbb1902f1
Author: Quan Tran <[email protected]>
AuthorDate: Thu Apr 9 16:02:35 2026 +0700

    JAMES-4182 Add more tests to MetadataAwareBlobStoreDAOContract
---
 .../api/MetadataAwareBlobStoreDAOContract.java     | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git 
a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetadataAwareBlobStoreDAOContract.java
 
b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetadataAwareBlobStoreDAOContract.java
index b3e9c5667c..81d76c6bd6 100644
--- 
a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetadataAwareBlobStoreDAOContract.java
+++ 
b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetadataAwareBlobStoreDAOContract.java
@@ -73,4 +73,65 @@ public interface MetadataAwareBlobStoreDAOContract {
         assertThat(Mono.from(testee.readBytes(TEST_BUCKET_NAME, 
TEST_BLOB_ID)).block().metadata().underlyingMap())
             .containsAllEntriesOf(byteSourceBlob.metadata().underlyingMap());
     }
+
+    @Test
+    default void storeMultipleMetadataEntriesShouldSucceed() {
+        BlobStoreDAO testee = testee();
+
+        BlobStoreDAO.ByteSourceBlob byteSourceBlob = 
BlobStoreDAO.BytesBlob.of("payload".getBytes(),
+                BlobStoreDAO.BlobMetadata.empty()
+                    .withMetadata(new BlobStoreDAO.BlobMetadataName("name1"), 
new BlobStoreDAO.BlobMetadataValue("value1"))
+                    .withMetadata(new BlobStoreDAO.BlobMetadataName("name2"), 
new BlobStoreDAO.BlobMetadataValue("value2")))
+            .asByteSource();
+
+        Mono.from(testee.save(TEST_BUCKET_NAME, TEST_BLOB_ID, 
byteSourceBlob)).block();
+
+        assertThat(Mono.from(testee.readBytes(TEST_BUCKET_NAME, 
TEST_BLOB_ID)).block().metadata().underlyingMap())
+            .containsAllEntriesOf(byteSourceBlob.metadata().underlyingMap());
+    }
+
+    @Test
+    default void retrieveContentTransferEncodingShouldSucceed() {
+        BlobStoreDAO testee = testee();
+
+        BlobStoreDAO.BytesBlob bytesBlob = 
BlobStoreDAO.BytesBlob.of("payload".getBytes(),
+            BlobStoreDAO.BlobMetadata.empty()
+                
.withContentTransferEncoding(BlobStoreDAO.ContentTransferEncoding.ZSTD));
+
+        Mono.from(testee.save(TEST_BUCKET_NAME, TEST_BLOB_ID, 
bytesBlob)).block();
+
+        assertThat(Mono.from(testee.readBytes(TEST_BUCKET_NAME, 
TEST_BLOB_ID)).block().metadata().contentTransferEncoding())
+            .contains(BlobStoreDAO.ContentTransferEncoding.ZSTD);
+    }
+
+    @Test
+    default void saveShouldPreserveEmptyMetadata() {
+        BlobStoreDAO testee = testee();
+
+        BlobStoreDAO.BytesBlob bytesBlob = 
BlobStoreDAO.BytesBlob.of("payload".getBytes(), 
BlobStoreDAO.BlobMetadata.empty());
+
+        Mono.from(testee.save(TEST_BUCKET_NAME, TEST_BLOB_ID, 
bytesBlob)).block();
+
+        assertThat(Mono.from(testee.readBytes(TEST_BUCKET_NAME, 
TEST_BLOB_ID)).block().metadata())
+            .isEqualTo(BlobStoreDAO.BlobMetadata.empty());
+    }
+
+    @Test
+    default void saveShouldOverwriteExistingBlobMetadata() {
+        BlobStoreDAO testee = testee();
+
+        BlobStoreDAO.BytesBlob initialBlob = 
BlobStoreDAO.BytesBlob.of("payload".getBytes(),
+            BlobStoreDAO.BlobMetadata.empty()
+                .withMetadata(new BlobStoreDAO.BlobMetadataName("first"), new 
BlobStoreDAO.BlobMetadataValue("value1")));
+        BlobStoreDAO.BytesBlob updatedBlob = 
BlobStoreDAO.BytesBlob.of("payload".getBytes(),
+            BlobStoreDAO.BlobMetadata.empty()
+                .withMetadata(new BlobStoreDAO.BlobMetadataName("second"), new 
BlobStoreDAO.BlobMetadataValue("value2")));
+
+        Mono.from(testee.save(TEST_BUCKET_NAME, TEST_BLOB_ID, 
initialBlob)).block();
+        Mono.from(testee.save(TEST_BUCKET_NAME, TEST_BLOB_ID, 
updatedBlob)).block();
+
+        assertThat(Mono.from(testee.readBytes(TEST_BUCKET_NAME, 
TEST_BLOB_ID)).block().metadata().underlyingMap())
+            .containsAllEntriesOf(updatedBlob.metadata().underlyingMap())
+            .doesNotContainKey(new BlobStoreDAO.BlobMetadataName("first"));
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to