edit.setData(readEditData(in, edit.getTargetSchemaNode(), codecs));
}
}
- default -> {
- // FIXME: this does not look right, as it can wreck our logic
- }
+ default -> throw new RequestException(ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT,
+ "Provided unknown element '" + editDefinition + "'");
}
}
}""", body::formatToJSON, true);
}
+ @Test
+ void testPatchWrongEditSchemaNode() {
+ final var body = assert400PatchError(ar -> restconf.dataYangJsonPATCH(stringInputStream("""
+ {
+ "ietf-yang-patch:yang-patch" : {
+ "patch-id" : "test patch id",
+ "edit" : [
+ {
+ "wrong" : "create data",
+ "operation" : "create",
+ "target" : "/example-jukebox:jukebox",
+ "value" : {
+ "jukebox" : {
+ "player" : {
+ "gap" : "0.2"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }"""), uriInfo, sc, ar));
+
+ assertFormat("""
+ {
+ "errors": {
+ "error": [
+ {
+ "error-tag": "unknown-element",
+ "error-message": "Provided unknown element 'wrong'",
+ "error-type": "application"
+ }
+ ]
+ }
+ }""", body::formatToJSON, true);
+ }
+
private static YangErrorsBody assert400PatchError(final Consumer<AsyncResponse> invocation) {
return assertInstanceOf(YangErrorsBody.class, assertFormattableBody(400, invocation));
}