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());
}
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);
}
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;
}
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();
}
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);
}
Aggregations