mjsax commented on code in PR #21666:
URL: https://github.com/apache/kafka/pull/21666#discussion_r2907027102


##########
streams/src/test/java/org/apache/kafka/streams/state/HeadersBytesStoreTest.java:
##########
@@ -64,4 +64,69 @@ public void shouldConvertEmptyValueToHeaderFormat() {
         assertEquals(0, headersSize, "Empty headers should have headersSize = 
0");
         assertEquals(0, buffer.remaining(), "No payload bytes for empty 
value");
     }
+
+    @Test
+    public void shouldReturnNullWhenConvertingNullPlainValue() {
+        final byte[] result = 
HeadersBytesStore.convertFromPlainToHeaderFormat(null);
+        assertNull(result);
+    }
+
+    @Test
+    public void shouldConvertPlainValueToHeaderFormatWithTimestamp() {
+        final byte[] plainValue = "test-value".getBytes();
+
+        final byte[] converted = 
HeadersBytesStore.convertFromPlainToHeaderFormat(plainValue);
+
+        assertNotNull(converted);
+        // Expected format: [0x00 (1 byte)][timestamp=-1 (8 bytes)][value]
+        assertEquals(1 + 8 + plainValue.length, converted.length);
+
+        // Verify empty headers marker
+        assertEquals(0x00, converted[0], "First byte for empty header should 
be 0x00");
+
+        // Verify timestamp = -1 (all 0xFF bytes)
+        for (int i = 1; i <= 8; i++) {
+            assertEquals((byte) 0xFF, converted[i], "Timestamp byte " + (i - 
1) + " should be 0xFF for -1");
+        }
+
+        // Verify payload
+        final byte[] actualPayload = Arrays.copyOfRange(converted, 9, 
converted.length);
+        assertArrayEquals(plainValue, actualPayload);
+    }
+
+    @Test
+    public void shouldConvertEmptyPlainValueToHeaderFormat() {
+        final byte[] emptyValue = new byte[0];
+
+        final byte[] converted = 
HeadersBytesStore.convertFromPlainToHeaderFormat(emptyValue);
+
+        assertNotNull(converted);
+        // Expected format: [0x00 (1 byte)][timestamp=-1 (8 bytes)]
+        assertEquals(9, converted.length, "Converted empty value should have 
headers + timestamp");
+
+        final ByteBuffer buffer = ByteBuffer.wrap(converted);
+        final int headersSize = ByteUtils.readVarint(buffer);
+        assertEquals(0, headersSize, "Empty headers should have headersSize = 
0");
+
+        // Verify timestamp = -1
+        final long timestamp = buffer.getLong();
+        assertEquals(-1L, timestamp, "Timestamp should be -1 for plain value 
upgrade");
+    }
+
+    @Test
+    public void shouldConvertPlainValueWithCorrectByteOrder() {

Review Comment:
   Personally not convinced. But ok :) 



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