import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
mockBodyReader(uri, jsonToPatchBodyReader, false);
- final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
- JsonBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdata.json"));
- checkPatchContextMountPoint(returnValue);
+ checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ JsonBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdata.json")));
}
/**
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
mockBodyReader(uri, jsonToPatchBodyReader, false);
- final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
- JsonBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json"));
- checkPatchContextMountPoint(returnValue);
+ checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ JsonBodyReaderTest.class.getResourceAsStream(
+ "/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json")));
}
/**
final InputStream inputStream = JsonBodyReaderTest.class.getResourceAsStream(
"/instanceidentifier/json/jsonPATCHdataValueMissing.json");
+
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
() -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
- assertEquals("Error code 400 expected", 400, ex.getErrors().get(0).getErrorTag().getStatusCode());
+ assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
/**
final InputStream inputStream = JsonBodyReaderTest.class.getResourceAsStream(
"/instanceidentifier/json/jsonPATCHdataValueNotSupported.json");
+
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
() -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
- assertEquals("Error code 400 expected", 400, ex.getErrors().get(0).getErrorTag().getStatusCode());
+ assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
/**
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont";
mockBodyReader(uri, jsonToPatchBodyReader, false);
- final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
JsonBodyReaderTest.class.getResourceAsStream(
- "/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json"));
- checkPatchContextMountPoint(returnValue);
+ "/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json")));
}
/**
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
mockBodyReader(uri, jsonToPatchBodyReader, false);
- final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
JsonBodyReaderTest.class.getResourceAsStream(
- "/instanceidentifier/json/jsonPATCHMergeOperationOnList.json"));
- checkPatchContextMountPoint(returnValue);
+ "/instanceidentifier/json/jsonPATCHMergeOperationOnList.json")));
}
/**
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont";
mockBodyReader(uri, jsonToPatchBodyReader, false);
- final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
JsonBodyReaderTest.class.getResourceAsStream(
- "/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json"));
- checkPatchContextMountPoint(returnValue);
+ "/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json")));
}
/**
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
mockBodyReader(uri, jsonToPatchBodyReader, false);
- final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
- JsonBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHSimpleLeafValue.json"));
- checkPatchContext(returnValue);
+ checkPatchContext(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ JsonBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHSimpleLeafValue.json")));
}
}