- private static SchemaContext parseYangStreams(final List<InputStream> streams) {
- CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
- .newBuild();
- final SchemaContext schemaContext;
- try {
- schemaContext = reactor.buildEffective(streams);
- } catch (ReactorException e) {
- throw new RuntimeException("Unable to build schema context from " + streams, e);
- }
- return schemaContext;
+ @Test
+ public void testNetconfDeviceNotificationsModelIsPresent() throws Exception {
+ final RemoteDeviceHandler facade = getFacade();
+ final NetconfDeviceCommunicator listener = getListener();
+ final EffectiveModelContextFactory schemaContextProviderFactory = getSchemaFactory();
+
+ final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO(
+ getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
+ final NetconfDevice device = new NetconfDeviceBuilder()
+ .setSchemaResourcesDTO(schemaResourcesDTO)
+ .setGlobalProcessingExecutor(getExecutor())
+ .setId(getId())
+ .setSalFacade(facade)
+ .setBaseSchemas(BASE_SCHEMAS)
+ .build();
+ final NetconfDevice netconfSpy = spy(device);
+
+ final NetconfSessionPreferences sessionCaps = getSessionCaps(false, Collections.emptyList());
+
+ final Map<QName, AvailableCapability.CapabilityOrigin> moduleBasedCaps = new HashMap<>();
+ moduleBasedCaps.put(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714
+ .$YangModuleInfoImpl.getInstance().getName(),
+ AvailableCapability.CapabilityOrigin.DeviceAdvertised);
+ moduleBasedCaps.put(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715
+ .$YangModuleInfoImpl.getInstance().getName(),
+ AvailableCapability.CapabilityOrigin.DeviceAdvertised);
+
+
+ netconfSpy.onRemoteSessionUp(sessionCaps.replaceModuleCaps(moduleBasedCaps), listener);
+
+ final ArgumentCaptor<NetconfDeviceSchema> argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class);
+ verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class),
+ any(DOMRpcService.class), isNull());
+ final Set<AvailableCapability> resolvedCapabilities = argument.getValue().capabilities().resolvedCapabilities();
+
+ List<String> notificationModulesName = Arrays.asList(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714
+ .$YangModuleInfoImpl.getInstance().getName().toString(),
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715
+ .$YangModuleInfoImpl.getInstance().getName().toString());
+
+ assertEquals(2, resolvedCapabilities.size());
+ assertTrue(resolvedCapabilities.stream().anyMatch(entry -> notificationModulesName
+ .contains(entry.getCapability())));