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.XmlBodyReaderTest;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
mockBodyReader(uri, xmlToPatchBodyReader, false);
- final PatchContext returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
- XmlBodyReaderTest.class.getResourceAsStream("/instanceidentifier/xml/xmlPATCHdata.xml"));
+ final InputStream inputStream = XmlBodyReaderTest.class.getResourceAsStream(
+ "/instanceidentifier/xml/xmlPATCHdata.xml");
+ final PatchContext returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
checkPatchContextMountPoint(returnValue);
}
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
() -> xmlToPatchBodyReader.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 = XmlBodyReaderTest.class.getResourceAsStream(
"/instanceidentifier/xml/xmlPATCHdataValueNotSupported.xml");
- final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
+ RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
() -> xmlToPatchBodyReader.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());
}
-
/**
* Test of Yang Patch with absolute target path.
*/
final String uri = MOUNT_POINT;
mockBodyReader(uri, xmlToPatchBodyReader, false);
- final PatchContext returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
- XmlBodyReaderTest.class.getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml"));
- checkPatchContextMountPoint(returnValue);
+ checkPatchContextMountPoint(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ XmlBodyReaderTest.class.getResourceAsStream(
+ "/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml")));
}
/**
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont";
mockBodyReader(uri, xmlToPatchBodyReader, false);
- final PatchContext returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
- XmlBodyReaderTest.class.getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml"));
- checkPatchContextMountPoint(returnValue);
+ checkPatchContextMountPoint(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ XmlBodyReaderTest.class.getResourceAsStream(
+ "/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml")));
}
/**
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
mockBodyReader(uri, xmlToPatchBodyReader, false);
- final PatchContext returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ checkPatchContextMountPoint(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
XmlBodyReaderTest.class.getResourceAsStream(
- "/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml"));
- checkPatchContextMountPoint(returnValue);
+ "/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml")));
}
/**
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont";
mockBodyReader(uri, xmlToPatchBodyReader, false);
- final PatchContext returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+ checkPatchContextMountPoint(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
XmlBodyReaderTest.class.getResourceAsStream(
- "/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml"));
- checkPatchContextMountPoint(returnValue);
+ "/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml")));
}
}