Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.zeppelin.rest.message;

import java.util.Collections;
import java.util.Map;

/**
Expand All @@ -29,7 +30,12 @@ public ParametersRequest(Map<String, Object> params) {
this.params = params;
}

/**
* Gson bypasses the constructor, so this field is null when the body carries no "params" entry.
*
* @return the parameters, or an empty map when none were supplied
*/
public Map<String, Object> getParams() {
return params;
return params == null ? Collections.emptyMap() : params;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,33 @@ void testRunNoteWithParams() throws IOException, InterruptedException {
}
}

@Test
void testRunNoteWithoutParamsInBody() throws IOException {
LOGGER.info("Running testRunNoteWithoutParamsInBody");
String note1Id = null;
try {
note1Id = notebook.createNote("note1", anonymous);

// Running a note without form parameters is valid. Gson leaves ParametersRequest#params
// null both when the key is absent and when it is an explicit null, so neither body may fail.
for (String body : new String[] {"{}", "{\"params\":null}"}) {
CloseableHttpResponse post =
httpPost("/notebook/job/" + note1Id + "?blocking=true&isolated=true", body);
assertThat(post, isAllowed());
Map<String, Object> resp = gson.fromJson(
EntityUtils.toString(post.getEntity(), StandardCharsets.UTF_8),
new TypeToken<Map<String, Object>>() {}.getType());
assertEquals("OK", resp.get("status"), "Failed for request body: " + body);
post.close();
}
} finally {
// cleanup
if (null != note1Id) {
notebook.removeNote(note1Id, anonymous);
}
}
}

@Test
void testRunAllParagraph_FirstFailed() throws IOException {
LOGGER.info("Running testRunAllParagraph_FirstFailed");
Expand Down
Loading