Handled NPE when the json is empty for interpreter setting POST request

and corrected the json in the REST API doc.
This commit is contained in:
Kavin Kumar 2016-08-19 12:44:11 +05:30 committed by Kavin
parent 7f733ffb2e
commit 3397fb0b47
3 changed files with 24 additions and 4 deletions

View file

@ -219,7 +219,9 @@ The role of registered interpreters, settings and interpreters group are describ
"dependencies": [
{
"groupArtifactVersion": "groupId:artifactId:version",
"exclusions": "groupId:artifactId"
"exclusions": [
"groupId:artifactId"
]
}
]
}
@ -249,7 +251,9 @@ The role of registered interpreters, settings and interpreters group are describ
"dependencies": [
{
"groupArtifactVersion": "groupId:artifactId:version",
"exclusions": "groupId:artifactId"
"exclusions": [
"groupId:artifactId"
]
}
]
}
@ -298,7 +302,9 @@ The role of registered interpreters, settings and interpreters group are describ
"dependencies": [
{
"groupArtifactVersion": "groupId:artifactId:version",
"exclusions": "groupId:artifactId"
"exclusions": [
"groupId:artifactId"
]
}
]
}
@ -328,7 +334,9 @@ The role of registered interpreters, settings and interpreters group are describ
"dependencies": [
{
"groupArtifactVersion": "groupId:artifactId:version",
"exclusions": "groupId:artifactId"
"exclusions": [
"groupId:artifactId"
]
}
]
}

View file

@ -90,6 +90,9 @@ public class InterpreterRestApi {
try {
NewInterpreterSettingRequest request =
gson.fromJson(message, NewInterpreterSettingRequest.class);
if (request == null) {
return new JsonResponse<>(Status.BAD_REQUEST).build();
}
Properties p = new Properties();
p.putAll(request.getProperties());
InterpreterSetting interpreterSetting = interpreterFactory

View file

@ -119,6 +119,15 @@ public class InterpreterRestApiTest extends AbstractTestRestApi {
delete.releaseConnection();
}
@Test
public void testSettingsCreateWithEmptyJson() throws IOException {
// Call Create Setting REST API
PostMethod post = httpPost("/interpreter/setting/", "");
LOG.info("testSettingCRUD create response\n" + post.getResponseBodyAsString());
assertThat("test create method:", post, isBadRequest());
post.releaseConnection();
}
@Test
public void testInterpreterAutoBinding() throws IOException {
// create note