ramu11 commented on code in PR #30481:
URL: https://github.com/apache/camel/pull/30481#discussion_r4640793026


##########
components/camel-azure/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/integration/BlobConsumerIT.java:
##########
@@ -201,15 +227,117 @@ void testPrefixBasedPolling() throws 
InterruptedException {
         templateStart.send("direct:createBlob", exchange -> {
             exchange.getIn().setBody("Blob 2");
             exchange.getIn().setHeader(BlobConstants.BLOB_CONTAINER_NAME, 
prefixContainerName);
+            exchange.getIn().setHeader(BlobConstants.BLOB_NAME, prefix + 
"/test_blob_2");
+        });
+
+        // This blob must not be returned by the server-side prefix filter.
+        templateStart.send("direct:createBlob", exchange -> {
+            exchange.getIn().setBody("Not prefixed");
+            exchange.getIn().setHeader(BlobConstants.BLOB_CONTAINER_NAME, 
prefixContainerName);
             exchange.getIn().setHeader(BlobConstants.BLOB_NAME, 
"non_prefixed_blob");
         });
 
         mockEndpoint.assertIsSatisfied();
 
-        String text = 
mockEndpoint.getExchanges().get(0).getIn().getBody(String.class);
+        assertEquals(2, mockEndpoint.getExchanges().size());
+        for (Exchange exchange : mockEndpoint.getExchanges()) {
+            String name = exchange.getIn().getHeader(BlobConstants.BLOB_NAME, 
String.class);
+            assertTrue(name.startsWith(prefix + "/"));
+            assertEquals(1, 
exchange.getProperty(ExchangePropertyKey.BATCH_SIZE));
+            assertEquals(0, 
exchange.getProperty(ExchangePropertyKey.BATCH_INDEX));
+            assertEquals(Boolean.TRUE, 
exchange.getProperty(ExchangePropertyKey.BATCH_COMPLETE));
+        }
+    }
+
+    @Test
+    void testMaxMessagesPerPollAndBatchProperties() throws Exception {
+        final MockEndpoint mockEndpoint = 
getMockEndpoint("mock:resultLimited");
+        mockEndpoint.expectedMessageCount(5);
+        mockEndpoint.setResultWaitTime(30000);
+
+        // The consumer route has an initial delay, so all five blobs are 
present
+        // before its first poll begins.
+        for (int i = 0; i < 5; i++) {
+            final int index = i;
+            templateStart.send("direct:createBlob", exchange -> {
+                exchange.getIn().setBody("Limited Batch Blob " + index);
+                exchange.getIn().setHeader(BlobConstants.BLOB_CONTAINER_NAME, 
limitedContainerName);
+                exchange.getIn().setHeader(BlobConstants.BLOB_NAME, 
"limited_blob_" + index);
+            });
+        }
 
-        assertEquals("Blob 1", text);
-        assertEquals(1, mockEndpoint.getExchanges().size());
+        mockEndpoint.assertIsSatisfied();
+
+        java.util.List<Integer> completedBatchSizes = 
mockEndpoint.getExchanges().stream()
+                .filter(exchange -> Boolean.TRUE.equals(
+                        
exchange.getProperty(ExchangePropertyKey.BATCH_COMPLETE)))
+                .map(exchange -> (Integer) 
exchange.getProperty(ExchangePropertyKey.BATCH_SIZE))
+                .toList();
+
+        assertEquals(java.util.List.of(2, 2, 1), completedBatchSizes,
+                "five blobs with a limit of two must be routed as batches of 
2, 2 and 1");
+
+        long uniqueBlobNames = mockEndpoint.getExchanges().stream()
+                .map(exchange -> 
exchange.getIn().getHeader(BlobConstants.BLOB_NAME, String.class))
+                .filter(java.util.Objects::nonNull)

Review Comment:
   Addressed in commit 6bd2f6a6386a. Added imports for java.util.List and 
java.util.Objects and replaced the fully qualified references.



-- 
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]

Reply via email to