Search in sources :

Example 36 with RestconfDocumentedException

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

the class TestXmlPatchBodyReaderMountPoint method moduleDataValueMissingNegativeTest.

/**
 * Test trying to use Patch create operation which requires value without value. Error code 400 should be returned.
 */
@Test
public void moduleDataValueMissingNegativeTest() throws Exception {
    final String uri = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont/my-list1/leaf1";
    mockBodyReader(uri, xmlToPatchBodyReader, false);
    final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataValueMissing.xml");
    final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
    assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 37 with RestconfDocumentedException

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

Example 38 with RestconfDocumentedException

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

the class TestJsonPatchBodyReader method modulePatchValueNotSupportedNegativeTest.

/**
 * Test trying to use value with Patch delete operation which does not support value. Test should fail with
 * {@link RestconfDocumentedException} with error code 400.
 */
@Test
public void modulePatchValueNotSupportedNegativeTest() throws Exception {
    final String uri = "instance-identifier-patch-module:patch-cont/my-list1/leaf1";
    mockBodyReader(uri, jsonToPatchBodyReader, false);
    final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueNotSupported.json");
    final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
    assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 39 with RestconfDocumentedException

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

the class TestJsonPatchBodyReaderMountPoint method modulePatchValueMissingNegativeTest.

/**
 * Test trying to use Patch create operation which requires value without value. Test should fail with
 * {@link RestconfDocumentedException} with error code 400.
 */
@Test
public void modulePatchValueMissingNegativeTest() throws Exception {
    final String uri = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont/my-list1/leaf1";
    mockBodyReader(uri, jsonToPatchBodyReader, false);
    final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueMissing.json");
    final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
    assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 40 with RestconfDocumentedException

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

the class TestJsonPatchBodyReaderMountPoint method modulePatchValueNotSupportedNegativeTest.

/**
 * Test trying to use value with Patch delete operation which does not support value. Test should fail with
 * {@link RestconfDocumentedException} with error code 400.
 */
@Test
public void modulePatchValueNotSupportedNegativeTest() throws Exception {
    final String uri = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont/my-list1/leaf1";
    mockBodyReader(uri, jsonToPatchBodyReader, false);
    final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueNotSupported.json");
    final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
    assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) InputStream(java.io.InputStream) 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