Posted feedback without "result" cause NPE in DDI API (#399)

* Fix for the bug by using @Valid on member variables

- add junit test
- done some refactoring

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Refactoring of junit tests

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
Jonathan Knoblauch
2017-01-11 11:23:48 +01:00
committed by Kai Zimmermann
parent 5707e5908a
commit 824ef2982f
6 changed files with 146 additions and 66 deletions

View File

@@ -194,7 +194,48 @@ public abstract class JsonBuilder {
new JSONObject().put("cnt", 2).put("of", 5)))
.put("details", messages))
.toString();
}
/**
* Build an invalid request body with missing result for feedback message.
*
* @param id
* id of the action
* @param execution
* the execution
* @param message
* the message
* @return a invalid request body
* @throws JSONException
*/
public static String missingResultInFeedback(final String id, final String execution, final String message)
throws JSONException {
final List<String> messages = new ArrayList<>();
messages.add(message);
return new JSONObject().put("id", id).put("time", "20140511T121314")
.put("status", new JSONObject().put("execution", execution).put("details", messages)).toString();
}
/**
* Build an invalid request body with missing finished result for feedback
* message.
*
* @param id
* id of the action
* @param execution
* the execution
* @param message
* the message
* @return a invalid request body
* @throws JSONException
*/
public static String missingFinishedResultInFeedback(final String id, final String execution, final String message)
throws JSONException {
final List<String> messages = new ArrayList<>();
messages.add(message);
return new JSONObject().put("id", id).put("time", "20140511T121314").put("status",
new JSONObject().put("execution", execution).put("result", new JSONObject()).put("details", messages))
.toString();
}
/**