Check for netconf interleave capability
[netconf.git] / plugins / netconf-client-mdsal / src / test / java / org / opendaylight / netconf / client / mdsal / NetconfDeviceTest.java
index d651c6ee25a347976de2a73db22f33d0623f23f6..dc1c1f2b70791a2e4ea49dacd52d01136020ddac 100644 (file)
@@ -308,7 +308,8 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
             .setBaseSchemaProvider(BASE_SCHEMAS)
             .build());
 
-        netconfSpy.onRemoteSessionUp(getSessionCaps(false, CapabilityURN.NOTIFICATION), getListener());
+        netconfSpy.onRemoteSessionUp(getSessionCaps(false, CapabilityURN.NOTIFICATION,
+                CapabilityURN.INTERLEAVE), getListener());
 
         final var argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class);
         verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class),
@@ -323,6 +324,34 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
                 .build()), argument.getValue().capabilities().resolvedCapabilities());
     }
 
+    @Test
+    public void testNetconfDeviceNotificationsModelNotPresentWithoutInterleaveCapability() throws Exception {
+        final var facade = getFacade();
+        final var netconfSpy = spy(new NetconfDeviceBuilder()
+            .setDeviceSchemaProvider(mockDeviceNetconfSchemaProvider())
+            .setProcessingExecutor(MoreExecutors.directExecutor())
+            .setId(getId())
+            .setSalFacade(facade)
+            .setBaseSchemaProvider(BASE_SCHEMAS)
+            .build());
+
+        final var sessionCaps = getSessionCaps(false,
+            TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION, CapabilityURN.NOTIFICATION);
+
+        netconfSpy.onRemoteSessionUp(sessionCaps, getListener());
+
+        final var argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class);
+        verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class),
+            any(RemoteDeviceServices.class));
+
+        // Notification schema was not added when there is no Interleave capability
+        assertEquals(Set.of(
+            new AvailableCapabilityBuilder()
+                .setCapability("(test:namespace?revision=2013-07-22)test-module")
+                .setCapabilityOrigin(CapabilityOrigin.DeviceAdvertised)
+                .build()), argument.getValue().capabilities().resolvedCapabilities());
+    }
+
     @Test
     public void testNetconfDeviceNotificationsModelIsPresent() throws Exception {
         final var facade = getFacade();