Search in sources :

Example 51 with RestconfDocumentedException

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());
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) Test(org.junit.Test)

Example 52 with RestconfDocumentedException

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());
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) Test(org.junit.Test)

Example 53 with RestconfDocumentedException

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());
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) Test(org.junit.Test)

Example 54 with RestconfDocumentedException

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"));
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) Test(org.junit.Test)

Example 55 with RestconfDocumentedException

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());
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) Test(org.junit.Test)

Aggregations

RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)136 Test (org.junit.Test)65 InputStream (java.io.InputStream)30 DOMMountPoint (org.opendaylight.mdsal.dom.api.DOMMountPoint)20 RestconfError (org.opendaylight.restconf.common.errors.RestconfError)20 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)19 QName (org.opendaylight.yangtools.yang.common.QName)17 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)17 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)16 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)14 List (java.util.List)13 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)13 ArrayList (java.util.ArrayList)12 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)11 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)9 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)9 IOException (java.io.IOException)8 ExecutionException (java.util.concurrent.ExecutionException)8 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)8 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)8