Search in sources :

Example 1 with SchemaContextHandler

use of org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler in project netconf by opendaylight.

the class RestconfImplTest method restImplTest.

@Test
public void restImplTest() throws Exception {
    final SchemaContextHandler schemaContextHandler = TestUtils.newSchemaContextHandler(YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/impl")));
    final RestconfImpl restconfImpl = new RestconfImpl(schemaContextHandler);
    final NormalizedNodePayload libraryVersion = restconfImpl.getLibraryVersion();
    final LeafNode<?> value = (LeafNode<?>) libraryVersion.getData();
    assertEquals(IetfYangLibrary.REVISION.toString(), value.body());
}
Also used : SchemaContextHandler(org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler) LeafNode(org.opendaylight.yangtools.yang.data.api.schema.LeafNode) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) Test(org.junit.Test)

Example 2 with SchemaContextHandler

use of org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler in project netconf by opendaylight.

the class RestconfInvokeOperationsServiceImplTest method setup.

@Before
public void setup() throws Exception {
    final EffectiveModelContext contextRef = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
    final DOMDataBroker dataBroker = mock(DOMDataBroker.class);
    final DOMDataTreeWriteTransaction wTx = mock(DOMDataTreeWriteTransaction.class);
    doReturn(wTx).when(dataBroker).newWriteOnlyTransaction();
    doReturn(CommitInfo.emptyFluentFuture()).when(wTx).commit();
    final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(dataBroker, mock(DOMSchemaService.class));
    schemaContextHandler.onModelContextUpdated(contextRef);
    invokeOperationsService = new RestconfInvokeOperationsServiceImpl(rpcService, schemaContextHandler);
}
Also used : SchemaContextHandler(org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Before(org.junit.Before)

Example 3 with SchemaContextHandler

use of org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler in project netconf by opendaylight.

the class TestUtils method newSchemaContextHandler.

public static SchemaContextHandler newSchemaContextHandler(final EffectiveModelContext schemaContext) {
    DOMDataBroker mockDataBroker = mock(DOMDataBroker.class);
    DOMDataTreeWriteTransaction mockTx = mock(DOMDataTreeWriteTransaction.class);
    doReturn(CommitInfo.emptyFluentFuture()).when(mockTx).commit();
    doReturn(mockTx).when(mockDataBroker).newWriteOnlyTransaction();
    SchemaContextHandler schemaContextHandler = new SchemaContextHandler(mockDataBroker, mock(DOMSchemaService.class));
    schemaContextHandler.onModelContextUpdated(schemaContext);
    return schemaContextHandler;
}
Also used : SchemaContextHandler(org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService)

Example 4 with SchemaContextHandler

use of org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler in project netconf by opendaylight.

the class RestconfDataServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    doReturn(Set.of()).when(queryParamenters).entrySet();
    doReturn(queryParamenters).when(uriInfo).getQueryParameters();
    baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
    containerPlayerQname = QName.create(baseQName, "player");
    leafQname = QName.create(baseQName, "gap");
    final QName containerLibraryQName = QName.create(baseQName, "library");
    final QName listPlaylistQName = QName.create(baseQName, "playlist");
    final LeafNode<?> buildLeaf = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(leafQname)).withValue(0.2).build();
    buildPlayerCont = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(containerPlayerQname)).withChild(buildLeaf).build();
    buildLibraryCont = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(containerLibraryQName)).build();
    buildPlaylistList = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(listPlaylistQName)).build();
    buildBaseCont = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(baseQName)).withChild(buildPlayerCont).build();
    // config contains one child the same as in operational and one additional
    buildBaseContConfig = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(baseQName)).withChild(buildPlayerCont).withChild(buildLibraryCont).build();
    // operational contains one child the same as in config and one additional
    buildBaseContOperational = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(baseQName)).withChild(buildPlayerCont).withChild(buildPlaylistList).build();
    iidBase = YangInstanceIdentifier.builder().node(baseQName).build();
    contextRef = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
    schemaNode = DataSchemaContextTree.from(contextRef).findChild(iidBase).orElseThrow().getDataSchemaNode();
    doReturn(CommitInfo.emptyFluentFuture()).when(write).commit();
    doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
    DOMDataBroker mockDataBroker = mock(DOMDataBroker.class);
    doReturn(read).when(mockDataBroker).newReadOnlyTransaction();
    doReturn(readWrite).when(mockDataBroker).newReadWriteTransaction();
    doReturn(write).when(mockDataBroker).newWriteOnlyTransaction();
    final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(mockDataBroker, mock(DOMSchemaService.class));
    schemaContextHandler.onModelContextUpdated(contextRef);
    dataService = new RestconfDataServiceImpl(schemaContextHandler, mockDataBroker, mountPointService, delegRestconfSubscrService, actionService, configuration);
    doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any(YangInstanceIdentifier.class));
    doReturn(Optional.of(FixedDOMSchemaService.of(contextRef))).when(mountPoint).getService(DOMSchemaService.class);
    doReturn(Optional.of(mountDataBroker)).when(mountPoint).getService(DOMDataBroker.class);
    doReturn(Optional.empty()).when(mountPoint).getService(NetconfDataTreeService.class);
    doReturn(read).when(mountDataBroker).newReadOnlyTransaction();
    doReturn(readWrite).when(mountDataBroker).newReadWriteTransaction();
}
Also used : SchemaContextHandler(org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler) QName(org.opendaylight.yangtools.yang.common.QName) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) FixedDOMSchemaService(org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) Before(org.junit.Before)

Example 5 with SchemaContextHandler

use of org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler in project netconf by opendaylight.

the class RestconfStreamsSubscriptionServiceImplTest method setUp.

@Before
public void setUp() throws FileNotFoundException, URISyntaxException {
    final DOMDataTreeWriteTransaction wTx = mock(DOMDataTreeWriteTransaction.class);
    doReturn(wTx).when(dataBroker).newWriteOnlyTransaction();
    doReturn(CommitInfo.emptyFluentFuture()).when(wTx).commit();
    schemaHandler = new SchemaContextHandler(dataBroker, mock(DOMSchemaService.class));
    DOMDataTreeChangeService dataTreeChangeService = mock(DOMDataTreeChangeService.class);
    doReturn(mock(ListenerRegistration.class)).when(dataTreeChangeService).registerDataTreeChangeListener(any(), any());
    doReturn(ImmutableClassToInstanceMap.of(DOMDataTreeChangeService.class, dataTreeChangeService)).when(dataBroker).getExtensions();
    doReturn(new MultivaluedHashMap<>()).when(uriInfo).getQueryParameters();
    doReturn(new LocalUriInfo().getBaseUriBuilder()).when(uriInfo).getBaseUriBuilder();
    doReturn(new URI("http://127.0.0.1/" + URI)).when(uriInfo).getAbsolutePath();
    schemaHandler.onModelContextUpdated(YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/notifications")));
    configurationWs = new Configuration(0, 100, 10, false);
    configurationSse = new Configuration(0, 100, 10, true);
}
Also used : DOMDataTreeChangeService(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) SchemaContextHandler(org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler) Configuration(org.opendaylight.restconf.nb.rfc8040.streams.Configuration) ListenerRegistration(org.opendaylight.yangtools.concepts.ListenerRegistration) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) URI(java.net.URI) Before(org.junit.Before)

Aggregations

SchemaContextHandler (org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler)9 DOMDataBroker (org.opendaylight.mdsal.dom.api.DOMDataBroker)5 Before (org.junit.Before)4 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)4 DOMSchemaService (org.opendaylight.mdsal.dom.api.DOMSchemaService)4 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)3 URI (java.net.URI)2 Test (org.junit.Test)2 Configuration (org.opendaylight.restconf.nb.rfc8040.streams.Configuration)2 BeforeClass (org.junit.BeforeClass)1 DOMActionService (org.opendaylight.mdsal.dom.api.DOMActionService)1 DOMDataTreeChangeService (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService)1 DOMMountPointService (org.opendaylight.mdsal.dom.api.DOMMountPointService)1 FixedDOMSchemaService (org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService)1 SimpleDOMActionResult (org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult)1 InstanceIdentifierContext (org.opendaylight.restconf.common.context.InstanceIdentifierContext)1 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)1 NormalizedNodePayload (org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload)1 RestconfStreamsSubscriptionService (org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfStreamsSubscriptionService)1 ListenerAdapter (org.opendaylight.restconf.nb.rfc8040.streams.listeners.ListenerAdapter)1