use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class TestXmlPatchBodyReaderMountPoint method moduleDataValueMissingNegativeTest.
/**
* Test trying to use Patch create operation which requires value without value. Error code 400 should be returned.
*/
@Test
public void moduleDataValueMissingNegativeTest() throws Exception {
final String uri = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont/my-list1/leaf1";
mockBodyReader(uri, xmlToPatchBodyReader, false);
final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataValueMissing.xml");
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class BrokerFacadeTest method testCommitConfigurationDataDeleteNoData.
/**
* Negative test of delete operation when data to delete does not exist. Error DATA_MISSING should be returned.
*/
@Test
public void testCommitConfigurationDataDeleteNoData() throws Exception {
// assume that data to delete does not exist
prepareDataForDelete(false);
// try to delete and expect DATA_MISSING error
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> brokerFacade.commitConfigurationDataDelete(this.instanceID));
final List<RestconfError> errors = ex.getErrors();
assertEquals(1, errors.size());
assertEquals(ErrorType.PROTOCOL, errors.get(0).getErrorType());
assertEquals(ErrorTag.DATA_MISSING, errors.get(0).getErrorTag());
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class TestJsonPatchBodyReader method modulePatchValueNotSupportedNegativeTest.
/**
* Test trying to use value with Patch delete operation which does not support value. Test should fail with
* {@link RestconfDocumentedException} with error code 400.
*/
@Test
public void modulePatchValueNotSupportedNegativeTest() throws Exception {
final String uri = "instance-identifier-patch-module:patch-cont/my-list1/leaf1";
mockBodyReader(uri, jsonToPatchBodyReader, false);
final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueNotSupported.json");
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class TestJsonPatchBodyReaderMountPoint method modulePatchValueMissingNegativeTest.
/**
* Test trying to use Patch create operation which requires value without value. Test should fail with
* {@link RestconfDocumentedException} with error code 400.
*/
@Test
public void modulePatchValueMissingNegativeTest() throws Exception {
final String uri = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont/my-list1/leaf1";
mockBodyReader(uri, jsonToPatchBodyReader, false);
final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueMissing.json");
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class TestJsonPatchBodyReaderMountPoint method modulePatchValueNotSupportedNegativeTest.
/**
* Test trying to use value with Patch delete operation which does not support value. Test should fail with
* {@link RestconfDocumentedException} with error code 400.
*/
@Test
public void modulePatchValueNotSupportedNegativeTest() throws Exception {
final String uri = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont/my-list1/leaf1";
mockBodyReader(uri, jsonToPatchBodyReader, false);
final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueNotSupported.json");
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
Aggregations