chia7712 commented on code in PR #24129:
URL: https://github.com/apache/kafka/pull/24129#discussion_r4506294514


##########
tools/src/test/java/org/apache/kafka/tools/consumer/MirrorStateMessageFormatterTest.java:
##########
@@ -228,6 +242,29 @@ public void testMalformedRecord(byte[] key, byte[] value) {
         assertFormattingFails(key, value);
     }
 
+    @Test
+    public void testRoundTrip() throws Exception {

Review Comment:
   How about leveraging `MirrorPartitionStateValueJsonConverter.read`?
   
   ```java
   JsonNode data = new 
ObjectMapper().readTree(output.toByteArray()).path("value").path("data");
   assertEquals(STATE_VALUE, MirrorPartitionStateValueJsonConverter.read(data, 
(short) 0));
   ```



##########
tools/src/main/java/org/apache/kafka/tools/consumer/MirrorStateMessageFormatter.java:
##########
@@ -47,8 +47,8 @@ protected JsonNode keyAsJson(ApiMessage message) {
     protected JsonNode valueAsJson(ApiMessage message, short version) {
         JsonNode json = 
CoordinatorRecordJsonConverters.writeRecordValueAsJson(message, version);
         if (message instanceof MirrorPartitionStateValue state) {
-            ((ObjectNode) json).put("state", 
MirrorPartitionState.nameOf(state.state()));
-            ((ObjectNode) json).put("previousState", 
MirrorPartitionState.nameOf(state.previousState()));
+            ((ObjectNode) json).put("stateName", 
MirrorPartitionState.nameOf(state.state()));

Review Comment:
   I opened https://issues.apache.org/jira/browse/KAFKA-21441 to fix other 
formatter



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