kishoreg commented on a change in pull request #4639: Support HTTP POST/PUT 
JSON schema
URL: https://github.com/apache/incubator-pinot/pull/4639#discussion_r327936087
 
 

 ##########
 File path: 
pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotSchemaRestletResourceTest.java
 ##########
 @@ -53,6 +55,36 @@ public void testBadContentType() {
     Assert.fail("Should have caught an exception");
   }
 
+  @Test
+  public void testPostJson() {
+    String schemaString = "{\n" + "  \"schemaName\" : \"transcript\",\n" + "  
\"dimensionFieldSpecs\" : [ {\n"
+        + "    \"name\" : \"studentID\",\n" + "    \"dataType\" : 
\"STRING\"\n" + "  }, {\n"
+        + "    \"name\" : \"firstName\",\n" + "    \"dataType\" : 
\"STRING\"\n" + "  }, {\n"
+        + "    \"name\" : \"lastName\",\n" + "    \"dataType\" : \"STRING\"\n" 
+ "  }, {\n"
+        + "    \"name\" : \"gender\",\n" + "    \"dataType\" : \"STRING\"\n" + 
"  }, {\n"
+        + "    \"name\" : \"subject\",\n" + "    \"dataType\" : \"STRING\"\n" 
+ "  } ],\n"
+        + "  \"metricFieldSpecs\" : [ {\n" + "    \"name\" : \"score\",\n" + " 
   \"dataType\" : \"FLOAT\"\n"
+        + "  } ]}";
+    try {
+      Map<String, String> header = new HashMap<>();
+      sendPostRequest(_controllerRequestURLBuilder.forSchemaCreate(), 
schemaString, header);
+    } catch (IOException e) {
+      e.printStackTrace();
+      Assert.assertTrue(e.getMessage().startsWith("Server returned HTTP 
response code: 415"), e.getMessage());
+    }
+
+    try {
+      Map<String, String> header = new HashMap<>();
+      header.put("Content-Type", "application/json");
+      final String response = 
sendPostRequest(_controllerRequestURLBuilder.forSchemaCreate(), schemaString, 
header);
+      Assert.assertEquals(response, "{\"status\":\"transcript successfully 
added\"}");
+    } catch (IOException e) {
+      e.printStackTrace();
 
 Review comment:
   Logger

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to