jamesnetherton commented on code in PR #8828:
URL: https://github.com/apache/camel-quarkus/pull/8828#discussion_r3528325337
##########
integration-test-groups/azure/azure-storage-blob/src/test/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobTest.java:
##########
@@ -607,4 +611,237 @@ public void dynamicExceptionInstantiation() {
.statusCode(200)
.body(is("true"));
}
+
+ @Test
+ public void blobSnapshot() {
+ try {
+ String originalContent = "Original Content";
+ String updatedContent = "Updated Content";
+
+ // Create blob
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(originalContent)
+ .post("/azure-storage-blob/blob/create")
+ .then()
+ .statusCode(201);
+
+ // Create snapshot
+ String snapshotId =
RestAssured.post("/azure-storage-blob/blob/snapshot/create")
+ .then()
+ .statusCode(201)
+ .extract()
+ .body()
+ .asString();
+
+ assertNotNull(snapshotId);
+
+ // Update blob content
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(updatedContent)
+ .patch("/azure-storage-blob/blob/update")
+ .then()
+ .statusCode(200);
+
+ // Read current blob (should return updated content)
+ RestAssured.get("/azure-storage-blob/blob/read")
+ .then()
+ .statusCode(200)
+ .body(is(updatedContent));
+
+ // Read snapshot (should return original content)
+ RestAssured.given()
+ .queryParam("snapshotId", snapshotId)
+ .get("/azure-storage-blob/blob/snapshot/read")
+ .then()
+ .statusCode(200)
+ .body(is(originalContent));
+ } finally {
+ // Delete blob and all snapshots
+ RestAssured.given()
+ .queryParam("deleteSnapshots", "include")
+ .delete("/azure-storage-blob/blob/delete")
+ .then()
+ .statusCode(anyOf(is(204), is(404)));
+ }
+ }
+
+ @Test
+ public void blobTags() {
+ try {
+ // Create blob
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body("Test content for tags")
+ .post("/azure-storage-blob/blob/create")
+ .then()
+ .statusCode(201);
+
+ // Set blob tags
+ Map<String, String> tags = new HashMap<>();
+ tags.put("environment", "test");
+ tags.put("project", "camel-quarkus");
+ tags.put("version", "1.0");
+
+ RestAssured.given()
+ .contentType(ContentType.JSON)
+ .body(tags)
+ .post("/azure-storage-blob/blob/tags/set")
+ .then()
+ .statusCode(200);
+
+ // Get blob tags
+ Map<String, String> retrievedTags =
RestAssured.get("/azure-storage-blob/blob/tags/get")
+ .then()
+ .statusCode(200)
+ .extract()
+ .as(new TypeRef<Map<String, String>>() {
+ });
+
+ // Verify tags
+ assertEquals("test", retrievedTags.get("environment"));
+ assertEquals("camel-quarkus", retrievedTags.get("project"));
+ assertEquals("1.0", retrievedTags.get("version"));
+ } finally {
+ // Delete blob
+ RestAssured.delete("/azure-storage-blob/blob/delete")
+ .then()
+ .statusCode(anyOf(is(204), is(404)));
+ }
+ }
+
+ @Test
+ public void findBlobsByTags() {
+ String blobName1 = AzureStorageBlobRoutes.BLOB_NAME;
+
+ try {
+ // Create first blob with tags
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body("Content for blob 1")
+ .post("/azure-storage-blob/blob/create")
+ .then()
+ .statusCode(201);
+
+ Map<String, String> tags1 = new HashMap<>();
+ tags1.put("environment", "production");
+ tags1.put("team", "backend");
+
+ RestAssured.given()
+ .contentType(ContentType.JSON)
+ .body(tags1)
+ .post("/azure-storage-blob/blob/tags/set")
+ .then()
+ .statusCode(200);
+
+ // On the real Azure service, blob index tag search is eventually
consistent;
+ // poll until the result is available. Azurite returns results
immediately.
+ String filter = "\"environment\" = 'production' AND \"team\" =
'backend'";
+ Awaitility.await().pollInterval(5, TimeUnit.SECONDS).timeout(2,
TimeUnit.MINUTES).until(() -> {
+ List<Map<String, String>> blobs = RestAssured.given()
+ .queryParam("filter", filter)
+ .get("/azure-storage-blob/blob/tags/find")
+ .then()
+ .statusCode(200)
+ .extract()
+ .jsonPath()
+ .getList("blobs");
+ return blobs != null && blobs.size() == 1;
+ });
+
+ // Verify the blob details once found
+ List<Map<String, String>> blobs = RestAssured.given()
+ .queryParam("filter", filter)
+ .get("/azure-storage-blob/blob/tags/find")
+ .then()
+ .statusCode(200)
+ .extract()
+ .jsonPath()
+ .getList("blobs");
+ assertEquals(blobName1, blobs.get(0).get("name"));
Review Comment:
Nitpick - I assume we could just verify the name together the other checks
inside of the Awaitility loop? It'd save doing an additional API call.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]