use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class ParserIdentifierTest method toSchemaExportContextFromIdentifierMountPointInvalidIdentifierNegativeTest.
/**
* Negative test trying to get <code>SchemaExportContext</code> behind mount point with invalid identifier. 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 toSchemaExportContextFromIdentifierMountPointInvalidIdentifierNegativeTest() {
RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.toSchemaExportContextFromIdentifier(SCHEMA_CONTEXT, MOUNT_POINT_IDENT + "/" + TEST_MODULE_REVISION + "/" + TEST_MODULE_NAME, this.mountPointService, sourceProvider));
assertEquals("Not expected error type", ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
assertEquals("Not expected error tag", ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class ParserIdentifierTest method makeQNameFromIdentifierInvalidIdentifierNegativeTest.
/**
* Negative test when supplied identifier is in invalid format and then revision is not parsable.
* <code>RestconfDocumentedException</code> is expected and error type, error tag and error status code are
* compared to expected values.
*/
@Test
public void makeQNameFromIdentifierInvalidIdentifierNegativeTest() {
RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.makeQNameFromIdentifier(TEST_MODULE_REVISION + "/" + TEST_MODULE_NAME));
assertEquals("Not expected error type", ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
assertEquals("Not expected error tag", 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 validateAndGetModulNameNotSuppliedTest.
/**
* Negative test of module name validation when there is no module name. Test fails catching
* <code>RestconfDocumentedException</code> and checking for correct error type, error tag and error status code.
*/
@Test
public void validateAndGetModulNameNotSuppliedTest() {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.validateAndGetModulName(Collections.emptyIterator()));
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 validateAndGetRevisionNotParsableTest.
/**
* Negative test of module revision validation when supplied revision is not parsable as revision. Test fails
* catching <code>RestconfDocumentedException</code>.
*/
@Test
public void validateAndGetRevisionNotParsableTest() {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.validateAndGetRevision(Iterators.singletonIterator("not-parsable-as-date")));
assertThat(ex.getMessage(), containsString("Supplied revision is not in expected date format YYYY-mm-dd"));
}
use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.
the class RestconfValidationTest method validateAndGetRevisionNotSuppliedTest.
/**
* Negative test of module revision validation when there is no revision. Test fails catching
* <code>RestconfDocumentedException</code> and checking for correct error type, error tag and error status code.
*/
@Test
public void validateAndGetRevisionNotSuppliedTest() {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.validateAndGetRevision(Collections.emptyIterator()));
assertEquals(ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
assertEquals(ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());
}
Aggregations