amrishlal commented on a change in pull request #6878:
URL: https://github.com/apache/incubator-pinot/pull/6878#discussion_r628358014



##########
File path: 
pinot-common/src/test/java/org/apache/pinot/common/utils/PinotDataTypeTest.java
##########
@@ -102,43 +127,64 @@ public void testObject() {
     assertTrue(OBJECT.toBoolean(new NumberObject("123")));
     assertEquals(OBJECT.toTimestamp(new NumberObject("123")).getTime(), 123L);
     assertEquals(OBJECT.toString(new NumberObject("123")), "123");
+    assertEquals(OBJECT.toJson(getGenericTestObject()), 
"{\"bytes\":\"AAE=\",\"map\":{\"key1\":\"value\",\"key2\":null,\"array\":[-5.4,4,\"2\"]},\"timestamp\":1620324238610}");
     assertEquals(OBJECT_ARRAY.getSingleValueType(), OBJECT);
   }
 
+  private static Object getGenericTestObject() {
+    Map<String, Object> map1 = new HashMap<>();
+    map1.put("array", Arrays.asList(-5.4,4, "2"));
+    map1.put("key1", "value");
+    map1.put("key2", null);
+
+    Map<String, Object> map2 = new HashMap<>();
+    map2.put("map", map1);
+    map2.put("bytes", new byte[]{0,1});
+    map2.put("timestamp", Timestamp.valueOf("2021-05-06 11:03:58.61"));
+
+    return map2;
+  }
+
   @Test
   public void testInvalidConversion() {
     for (PinotDataType sourceType : values()) {
       if (sourceType.isSingleValue() && sourceType != STRING && sourceType != 
BYTES) {
-        assertInvalidConversion(sourceType, BYTES);
+        assertInvalidConversion(null, sourceType, BYTES, 
UnsupportedOperationException.class);

Review comment:
       These are original failure case test cases and I agree that they don't 
seem to be doing much, but here I am just refactoring the code to allow for 
testing conversion of invalid strings to JSON.
   
   `assertInvalidConversion("xyz", STRING, JSON, RuntimeException.class);`




-- 
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to