oscerd commented on code in PR #29155:
URL: https://github.com/apache/camel/pull/29155#discussion_r4467316568
##########
components/camel-azure/camel-azure-storage-datalake/src/test/java/org/apache/camel/component/azure/storage/datalake/operations/DataLakeFileOperationTest.java:
##########
@@ -94,6 +97,49 @@ void testGetFile() throws IOException {
assertNotNull(secondResponse.getHeaders());
}
+ @Test
+ void testFlushUsesAbsoluteHeaderPosition() {
+ when(client.flushWithResponse(anyLong(), any(), any(), any(), any(),
any()))
+ .thenReturn(new ResponseBase<>(
+ null, 200, new HttpHeaders(),
+ new PathInfo("testTag", OffsetDateTime.now()), null));
+ final Exchange exchange = new DefaultExchange(context);
+ configuration.setPosition(110L);
+ exchange.getIn().setHeader(DataLakeConstants.POSITION, 120L);
+
+ new DataLakeFileOperations(configuration,
client).flushToFile(exchange);
+
+ verify(client).flushWithResponse(eq(120L), any(), any(), any(), any(),
any());
+ verify(client, never()).getFileSize();
+ }
+
+ @Test
+ void testFlushUsesAbsoluteConfiguredPosition() {
+ configuration.setPosition(120L);
+ when(client.flushWithResponse(anyLong(), any(), any(), any(), any(),
any()))
+ .thenReturn(new ResponseBase<>(
+ null, 200, new HttpHeaders(),
+ new PathInfo("testTag", OffsetDateTime.now()), null));
+
+ new DataLakeFileOperations(configuration, client).flushToFile(new
DefaultExchange(context));
+
+ verify(client).flushWithResponse(eq(120L), any(), any(), any(), any(),
any());
+ verify(client, never()).getFileSize();
+ }
+
+ @Test
+ void testFlushUsesCurrentLengthWhenPositionIsAbsent() {
+ when(client.getFileSize()).thenReturn(100L);
+ when(client.flushWithResponse(anyLong(), any(), any(), any(), any(),
any()))
+ .thenReturn(new ResponseBase<>(
+ null, 200, new HttpHeaders(),
+ new PathInfo("testTag", OffsetDateTime.now()), null));
+
+ new DataLakeFileOperations(configuration, client).flushToFile(new
DefaultExchange(context));
+
+ verify(client).flushWithResponse(eq(100L), any(), any(), any(), any(),
any());
Review Comment:
You are right that this case passes before and after the fix: it is
intentional compatibility coverage for the null-position fallback introduced by
[f6ae9ecad39b](https://github.com/apache/camel/commit/f6ae9ecad39b89936611e3ab56d307d4f4d34924)
(CAMEL-24159). This PR changes explicit positions while preserving that
fallback. The header-position and configured-position tests cover the changed
behavior and fail against the old implementation.
Adding `verify(client).getFileSize()` or changing the stubbed length to
`75L` would also pass against the old implementation. The existing assertion
already checks the observable result: the stubbed current length reaches
`flushWithResponse`. I am keeping this case as compatibility coverage alongside
the two regression tests.
_Generated by Codex via OSS Helper on behalf of @oscerd._
--
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]