Search in sources :

Example 91 with RestconfDocumentedException

use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.

the class ParserIdentifierTest method makeQNameFromIdentifierMountPointTooShortIdentifierNegativeTest.

/**
 * Negative test when supplied identifier for module behind mount point is too short (contains only module name).
 * <code>RestconfDocumentedException</code> is expected and error type, error tag and error status code
 * are compared to expected values.
 */
@Test
public void makeQNameFromIdentifierMountPointTooShortIdentifierNegativeTest() {
    RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.makeQNameFromIdentifier(MOUNT_POINT_IDENT + "/" + 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 92 with RestconfDocumentedException

use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.

the class ParserIdentifierTest method toSchemaExportContextFromIdentifierInvalidIdentifierNegativeTest.

/**
 * Negative test trying to get <code>SchemaExportContext</code> 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 toSchemaExportContextFromIdentifierInvalidIdentifierNegativeTest() {
    RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.toSchemaExportContextFromIdentifier(SCHEMA_CONTEXT, TEST_MODULE_REVISION + "/" + TEST_MODULE_NAME, null, 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 93 with RestconfDocumentedException

use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.

the class ParserIdentifierTest method makeQNameFromIdentifierMountPointInvalidIdentifierNegativeTest.

/**
 * Negative test when supplied identifier for module behind mount point 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 makeQNameFromIdentifierMountPointInvalidIdentifierNegativeTest() {
    RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.makeQNameFromIdentifier(MOUNT_POINT_IDENT + "/" + 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 94 with RestconfDocumentedException

use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.

the class ParserIdentifierTest method makeQNameFromIdentifierDoubleSlashNegativeTest.

/**
 * Negative test with identifier containing double slash. Between // there is one empty string which will be
 * incorrectly considered to be module revision. Test is expected to fail with
 * <code>RestconfDocumentedException</code> and error type, error tag and error status code are compared to
 * expected values.
 */
@Test
public void makeQNameFromIdentifierDoubleSlashNegativeTest() {
    RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.makeQNameFromIdentifier(TEST_MODULE_NAME + "//" + TEST_MODULE_REVISION));
    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 95 with RestconfDocumentedException

use of org.opendaylight.restconf.common.errors.RestconfDocumentedException in project netconf by opendaylight.

the class RestconfValidationTest method validateAndGetModuleNameNotParsableFirstTest.

/**
 * Negative test of module name validation when supplied name is not parsable as module name on the first
 * character. Test fails catching <code>RestconfDocumentedException</code> and checking for correct error type,
 * error tag and error status code.
 */
@Test
public void validateAndGetModuleNameNotParsableFirstTest() {
    final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> ParserIdentifier.validateAndGetModulName(Iterators.singletonIterator("01-not-parsable-as-name-on-firts-char")));
    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