use of org.opendaylight.restconf.common.errors.RestconfError 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.RestconfError in project netconf by opendaylight.
the class AbstractBodyReaderTest method assertRangeViolation.
protected static void assertRangeViolation(final ThrowingRunnable runnable) {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, runnable);
assertEquals(Status.BAD_REQUEST, ex.getResponse().getStatusInfo());
final List<RestconfError> errors = ex.getErrors();
assertEquals(1, errors.size());
final RestconfError error = errors.get(0);
assertEquals(ErrorType.APPLICATION, error.getErrorType());
assertEquals(ErrorTag.INVALID_VALUE, error.getErrorTag());
assertEquals("bar error app tag", error.getErrorAppTag());
assertEquals("bar error message", error.getErrorMessage());
}
use of org.opendaylight.restconf.common.errors.RestconfError in project netconf by opendaylight.
the class XmlBodyReaderMountPointTest method wrongRootElementTest.
/**
* Test PUT operation when message root element is not the same as the last element in request URI.
* PUT operation message should always start with schema node from URI otherwise exception should be
* thrown.
*/
@Test
public void wrongRootElementTest() throws Exception {
mockBodyReader("instance-identifier-module:cont/yang-ext:mount", xmlBodyReader, false);
final InputStream inputStream = XmlBodyReaderTest.class.getResourceAsStream("/instanceidentifier/xml/bug7933.xml");
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> xmlBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
final RestconfError restconfError = ex.getErrors().get(0);
assertEquals(ErrorType.PROTOCOL, restconfError.getErrorType());
assertEquals(ErrorTag.MALFORMED_MESSAGE, restconfError.getErrorTag());
}
use of org.opendaylight.restconf.common.errors.RestconfError in project netconf by opendaylight.
the class XmlBodyReaderTest method wrongRootElementTest.
/**
* Test PUT operation when message root element is not the same as the last element in request URI.
* PUT operation message should always start with schema node from URI otherwise exception should be
* thrown.
*/
@Test
public void wrongRootElementTest() throws Exception {
mockBodyReader("instance-identifier-module:cont", xmlBodyReader, false);
final InputStream inputStream = XmlBodyReaderTest.class.getResourceAsStream("/instanceidentifier/xml/bug7933.xml");
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> xmlBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
final RestconfError restconfError = ex.getErrors().get(0);
assertEquals(ErrorType.PROTOCOL, restconfError.getErrorType());
assertEquals(ErrorTag.MALFORMED_MESSAGE, restconfError.getErrorTag());
}
use of org.opendaylight.restconf.common.errors.RestconfError in project netconf by opendaylight.
the class ParserIdentifierTest method toInstanceIdentifierMissingMountPointNegativeTest.
/**
* Negative test when <code>DOMMountPoint</code> cannot be found. Test is expected to fail with
* <code>RestconfDocumentedException</code> error type, error tag and error status code are
* compared to expected values.
*/
@Test
public void toInstanceIdentifierMissingMountPointNegativeTest() {
RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.toInstanceIdentifier("/yang-ext:mount", SCHEMA_CONTEXT, Optional.of(this.mountPointService)));
final List<RestconfError> errors = ex.getErrors();
assertEquals(1, errors.size());
assertEquals("Not expected error type", ErrorType.PROTOCOL, errors.get(0).getErrorType());
assertEquals("Not expected error tag", ErrorTags.RESOURCE_DENIED_TRANSPORT, errors.get(0).getErrorTag());
}
Aggregations