Search in sources :

Example 1 with ControllerContext

use of org.opendaylight.netconf.sal.restconf.impl.ControllerContext in project netconf by opendaylight.

the class JSONRestconfServiceImplTest method setup.

@Before
public void setup() throws FileNotFoundException {
    final EffectiveModelContext mountPointSchemaContext = TestUtils.loadSchemaContext("/full-versions/test-module");
    final ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext, mockMountPoint);
    doReturn(java.util.Optional.of(FixedDOMSchemaService.of(() -> mountPointSchemaContext))).when(mockMountPoint).getService(eq(DOMSchemaService.class));
    service = new JSONRestconfServiceImpl(controllerContext, RestconfImpl.newInstance(brokerFacade, controllerContext));
}
Also used : ControllerContext(org.opendaylight.netconf.sal.restconf.impl.ControllerContext) FixedDOMSchemaService(org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) JSONRestconfServiceImpl(org.opendaylight.netconf.sal.restconf.impl.JSONRestconfServiceImpl) Before(org.junit.Before)

Example 2 with ControllerContext

use of org.opendaylight.netconf.sal.restconf.impl.ControllerContext in project netconf by opendaylight.

the class InstanceIdentifierTypeLeafTest method stringToInstanceIdentifierTest.

@Test
public void stringToInstanceIdentifierTest() throws Exception {
    final EffectiveModelContext schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/instanceidentifier"));
    ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
    final InstanceIdentifierContext<?> instanceIdentifier = controllerContext.toInstanceIdentifier("/iid-value-module:cont-iid/iid-list/%2Fiid-value-module%3Acont-iid%2Fiid-value-module%3A" + "values-iid%5Biid-value-module:value-iid='value'%5D");
    final YangInstanceIdentifier yiD = instanceIdentifier.getInstanceIdentifier();
    Assert.assertNotNull(yiD);
    final PathArgument lastPathArgument = yiD.getLastPathArgument();
    Assert.assertTrue(lastPathArgument.getNodeType().getNamespace().toString().equals("iid:value:module"));
    Assert.assertTrue(lastPathArgument.getNodeType().getLocalName().equals("iid-list"));
    final NodeIdentifierWithPredicates list = (NodeIdentifierWithPredicates) lastPathArgument;
    final YangInstanceIdentifier value = (YangInstanceIdentifier) list.getValue(QName.create(lastPathArgument.getNodeType(), "iid-leaf"));
    final PathArgument lastPathArgumentOfValue = value.getLastPathArgument();
    Assert.assertTrue(lastPathArgumentOfValue.getNodeType().getNamespace().toString().equals("iid:value:module"));
    Assert.assertTrue(lastPathArgumentOfValue.getNodeType().getLocalName().equals("values-iid"));
    final NodeIdentifierWithPredicates valueList = (NodeIdentifierWithPredicates) lastPathArgumentOfValue;
    final String valueIid = (String) valueList.getValue(QName.create(lastPathArgumentOfValue.getNodeType(), "value-iid"));
    Assert.assertEquals("value", valueIid);
}
Also used : ControllerContext(org.opendaylight.netconf.sal.restconf.impl.ControllerContext) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 3 with ControllerContext

use of org.opendaylight.netconf.sal.restconf.impl.ControllerContext in project netconf by opendaylight.

the class RestPutOperationTest method configure.

@Override
protected Application configure() {
    /* enable/disable Jersey logs to console */
    // enable(TestProperties.LOG_TRAFFIC);
    // enable(TestProperties.DUMP_ENTITY);
    // enable(TestProperties.RECORD_LOG_LEVEL);
    // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
    mountInstance = mock(DOMMountPoint.class);
    final ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContextYangsIetf, mountInstance);
    brokerFacade = mock(BrokerFacade.class);
    restconfImpl = RestconfImpl.newInstance(brokerFacade, controllerContext);
    ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig = resourceConfig.registerInstances(restconfImpl, new XmlNormalizedNodeBodyReader(controllerContext), new NormalizedNodeXmlBodyWriter(), new JsonNormalizedNodeBodyReader(controllerContext), new NormalizedNodeJsonBodyWriter(), new RestconfDocumentedExceptionMapper(controllerContext));
    return resourceConfig;
}
Also used : NormalizedNodeXmlBodyWriter(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter) ControllerContext(org.opendaylight.netconf.sal.restconf.impl.ControllerContext) NormalizedNodeJsonBodyWriter(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) XmlNormalizedNodeBodyReader(org.opendaylight.netconf.sal.rest.impl.XmlNormalizedNodeBodyReader) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) RestconfDocumentedExceptionMapper(org.opendaylight.netconf.sal.rest.impl.RestconfDocumentedExceptionMapper) BrokerFacade(org.opendaylight.netconf.sal.restconf.impl.BrokerFacade) JsonNormalizedNodeBodyReader(org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader)

Example 4 with ControllerContext

use of org.opendaylight.netconf.sal.restconf.impl.ControllerContext in project netconf by opendaylight.

the class RestconfDocumentedExceptionMapperTest method configure.

@Override
protected Application configure() {
    ResourceConfig resourceConfig = new ResourceConfig();
    ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
    resourceConfig = resourceConfig.registerInstances(mockRestConf, new XmlNormalizedNodeBodyReader(controllerContext), new JsonNormalizedNodeBodyReader(controllerContext), new NormalizedNodeJsonBodyWriter(), new NormalizedNodeXmlBodyWriter(), new RestconfDocumentedExceptionMapper(controllerContext));
    return resourceConfig;
}
Also used : NormalizedNodeXmlBodyWriter(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter) ControllerContext(org.opendaylight.netconf.sal.restconf.impl.ControllerContext) NormalizedNodeJsonBodyWriter(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter) XmlNormalizedNodeBodyReader(org.opendaylight.netconf.sal.rest.impl.XmlNormalizedNodeBodyReader) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) RestconfDocumentedExceptionMapper(org.opendaylight.netconf.sal.rest.impl.RestconfDocumentedExceptionMapper) JsonNormalizedNodeBodyReader(org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader)

Example 5 with ControllerContext

use of org.opendaylight.netconf.sal.restconf.impl.ControllerContext in project netconf by opendaylight.

the class RestStreamTest method configure.

@Override
protected Application configure() {
    /* enable/disable Jersey logs to console */
    // enable(TestProperties.LOG_TRAFFIC);
    // enable(TestProperties.DUMP_ENTITY);
    // enable(TestProperties.RECORD_LOG_LEVEL);
    // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
    final ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContextYangsIetf);
    brokerFacade = mock(BrokerFacade.class);
    restconfImpl = RestconfImpl.newInstance(brokerFacade, controllerContext);
    ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig = resourceConfig.registerInstances(restconfImpl, new NormalizedNodeJsonBodyWriter(), new NormalizedNodeXmlBodyWriter(), new XmlNormalizedNodeBodyReader(controllerContext), new JsonNormalizedNodeBodyReader(controllerContext), new RestconfDocumentedExceptionMapper(controllerContext));
    return resourceConfig;
}
Also used : NormalizedNodeXmlBodyWriter(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter) ControllerContext(org.opendaylight.netconf.sal.restconf.impl.ControllerContext) NormalizedNodeJsonBodyWriter(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter) XmlNormalizedNodeBodyReader(org.opendaylight.netconf.sal.rest.impl.XmlNormalizedNodeBodyReader) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) RestconfDocumentedExceptionMapper(org.opendaylight.netconf.sal.rest.impl.RestconfDocumentedExceptionMapper) BrokerFacade(org.opendaylight.netconf.sal.restconf.impl.BrokerFacade) JsonNormalizedNodeBodyReader(org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader)

Aggregations

ControllerContext (org.opendaylight.netconf.sal.restconf.impl.ControllerContext)6 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)3 JsonNormalizedNodeBodyReader (org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader)3 NormalizedNodeJsonBodyWriter (org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter)3 NormalizedNodeXmlBodyWriter (org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter)3 RestconfDocumentedExceptionMapper (org.opendaylight.netconf.sal.rest.impl.RestconfDocumentedExceptionMapper)3 XmlNormalizedNodeBodyReader (org.opendaylight.netconf.sal.rest.impl.XmlNormalizedNodeBodyReader)3 BrokerFacade (org.opendaylight.netconf.sal.restconf.impl.BrokerFacade)3 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)3 Before (org.junit.Before)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2 FluentFuture (com.google.common.util.concurrent.FluentFuture)1 Test (org.junit.Test)1 DOMMountPoint (org.opendaylight.mdsal.dom.api.DOMMountPoint)1 DOMSchemaService (org.opendaylight.mdsal.dom.api.DOMSchemaService)1 FixedDOMSchemaService (org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService)1 JSONRestconfServiceImpl (org.opendaylight.netconf.sal.restconf.impl.JSONRestconfServiceImpl)1 PutResult (org.opendaylight.netconf.sal.restconf.impl.PutResult)1 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1