gaoran10 commented on a change in pull request #10604:
URL: https://github.com/apache/pulsar/pull/10604#discussion_r635701239



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/schema/SchemaTest.java
##########
@@ -858,36 +862,62 @@ private void checkSchemaForAutoSchema(int index, 
Message<GenericRecord> message)
             Assert.fail("Failed to get reader schema for auto consume multiple 
schema topic.");
         }
         Object nativeObject = message.getValue().getNativeObject();
+        String baseTopic = message.getProperty("baseTopic");
         JsonNode jsonNode;
-        switch (index) {
-            case 0:
+        KeyValue kv;
+        switch (baseTopic) {
+            case "bytes_schema":
                 Assert.assertEquals(new String((byte[]) nativeObject), "bytes 
value");
                 break;
-            case 1:
+            case "string_schema":
                 Assert.assertEquals((String) nativeObject, "string value");
                 break;
-            case 2:
+            case "bool_schema":
                 Assert.assertEquals(nativeObject, Boolean.TRUE);
                 break;
-            case 3:
+            case "json_one_schema":
                 jsonNode = (JsonNode) nativeObject;
                 Assert.assertEquals(jsonNode.get("id").intValue(), 1);
                 break;
-            case 4:
+            case "json_three_schema":
                 jsonNode = (JsonNode) nativeObject;
                 Assert.assertEquals(jsonNode.get("id").intValue(), 3);
                 Assert.assertEquals(jsonNode.get("name").textValue(), "ran");
                 break;
-            case 5:
+            case "json_four_schema":
                 jsonNode = (JsonNode) nativeObject;
                 Assert.assertEquals(jsonNode.get("id").intValue(), 4);
                 Assert.assertEquals(jsonNode.get("name").textValue(), "tang");
                 Assert.assertEquals(jsonNode.get("age").intValue(), 18);
                 break;
-            case 6:
+            case "avro_one_schema":
                 org.apache.avro.generic.GenericRecord genericRecord =
                         (org.apache.avro.generic.GenericRecord) nativeObject;
-                Assert.assertEquals(genericRecord.get("id"), 1);
+                Assert.assertEquals(genericRecord.get("id"), 10);
+                break;
+            case "k_one_v_three_schema_separate":
+                kv = (KeyValue<?, ?>) nativeObject;
+                jsonNode = ((GenericJsonRecord) kv.getKey()).getJsonNode();
+                Assert.assertEquals(jsonNode.get("id").intValue(), 1);
+                jsonNode = ((GenericJsonRecord) kv.getValue()).getJsonNode();

Review comment:
       It seems that using the getNativeObject still needs to constraint 
convert to JsonNode.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to