use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class RestconfValidationTest method validateAndGetModuleNameEmptyTest.
/**
* Negative test of module name validation when supplied name is empty. Test fails catching
* <code>RestconfDocumentedException</code> and checking for correct error type, error tag and error status code.
*/
@Test
public void validateAndGetModuleNameEmptyTest() {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.validateAndGetModulName(Iterators.singletonIterator("")));
assertEquals(ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
assertEquals(ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class RestconfValidationTest method validateAndGetModuleNameNotParsableNextTest.
/**
* Negative test of module name validation when supplied name is not parsable as module name on any of the
* characters after the first character. Test fails catching <code>RestconfDocumentedException</code> and checking
* for correct error type, error tag and error status code.
*/
@Test
public void validateAndGetModuleNameNotParsableNextTest() {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.validateAndGetModulName(Iterators.singletonIterator("not-parsable-as-name-after-first-char*")));
assertEquals(ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
assertEquals(ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class InvokeRpcMethodTest method testInvokeRpcWithNoPayloadRpc_FailNoErrors.
@Test
public void testInvokeRpcWithNoPayloadRpc_FailNoErrors() {
final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast");
doReturn(immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException("testExeption"))).when(brokerFacade).invokeRpc(eq(qname), any());
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> this.restconfImpl.invokeRpc("toaster:cancel-toast", null, uriInfo));
verifyRestconfDocumentedException(ex, 0, ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED, Optional.empty(), Optional.empty());
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class InvokeRpcMethodTest method testThrowExceptionWhenSlashInModuleName.
@Test
public void testThrowExceptionWhenSlashInModuleName() {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> this.restconfImpl.invokeRpc("toaster/slash", null, uriInfo));
verifyRestconfDocumentedException(ex, 0, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, Optional.empty(), Optional.empty());
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class QueryParamsTest method optionalParamMultipleTest.
/**
* Test when parameter is present more than once.
*/
@Test
public void optionalParamMultipleTest() {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> QueryParams.optionalParam(ContentParam.uriName, List.of("config", "nonconfig", "all")));
final List<RestconfError> errors = ex.getErrors();
assertEquals(1, errors.size());
final RestconfError error = errors.get(0);
assertEquals("Error type is not correct", ErrorType.PROTOCOL, error.getErrorType());
assertEquals("Error tag is not correct", ErrorTag.INVALID_VALUE, error.getErrorTag());
}
Aggregations