Merge "Handle missing spanloss in PCE without crashing"
authorGuillaume Lambert <guillaume.lambert@orange.com>
Thu, 15 Dec 2022 09:28:01 +0000 (09:28 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 15 Dec 2022 09:28:01 +0000 (09:28 +0000)
35 files changed:
api/pom.xml
common/pom.xml
dmaap-client/pom.xml
features/odl-transportpce-dmaap-client/pom.xml
features/odl-transportpce-inventory/pom.xml
features/odl-transportpce-nbinotifications/pom.xml
features/odl-transportpce-swagger/pom.xml
features/odl-transportpce-tapi/pom.xml
features/odl-transportpce/pom.xml
features/pom.xml
inventory/pom.xml
karaf/pom.xml
nbinotifications/pom.xml
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/NbiNotificationsUtils.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceDeserializerTest.java [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceSerializerTest.java [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java
nbinotifications/src/test/resources/expected_tapi_event.json [new file with mode: 0755]
nbinotifications/src/test/resources/tapi_event.json [new file with mode: 0644]
networkmodel/pom.xml
olm/pom.xml
pce/pom.xml
pom.xml
renderer/pom.xml
servicehandler/pom.xml
tapi/pom.xml
test-common/pom.xml
tests/transportpce_tests/common/test_utils.py
tests/transportpce_tests/with_docker/test03_tapi_nbinotifications.py
tox.ini

index 5446af859c7bad0822faf1a207e6dc8971a57c91..3e5cae3f18ceb838090a0393067e47ba87ad6e4e 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
index 9d71e7ca2a1b3ceb630a8ffbebc607d9f91fe45c..5b36385a9cfe489d4683a5b18aa403c4292056ae 100644 (file)
@@ -10,7 +10,7 @@
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
@@ -28,7 +28,7 @@
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>4.0.3</version>
+        <version>4.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
index 443ddaaa575954c28bc567a2a2fdf76de074ba5b..c060234fb965d51855c465711a72a80bf8ccc22b 100644 (file)
@@ -9,7 +9,7 @@
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
index e65d64956ab2fc5379a661a1b464426e86b314d1..f88a8342953d8cb91b8e55d3d941a1a0e450cb8e 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>single-feature-parent</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
index 15bdac736e76bdb344d16df2181d740ca7b8567b..9d9a52a1996b1de0a0d1eb862067ff232b6d6a54 100644 (file)
@@ -9,7 +9,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>single-feature-parent</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
index c8307eb8da2a00ea1364598cb3bde85e81358418..5d96b2bd21e00ec81c343d5605b1f0454f73ae12 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>single-feature-parent</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
index 7ce768e1eabc6e00f75d329618f9508674d501d9..43d0ce2d0fb5691fafdc4b3eca0925cebf080317 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>single-feature-parent</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
@@ -23,7 +23,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <name>OpenDaylight :: transportpce :: swagger</name>
 
   <properties>
-    <netconf.version>4.0.3</netconf.version>
+    <netconf.version>4.0.4</netconf.version>
     <configfile.directory>etc/opendaylight/karaf</configfile.directory>
   </properties>
 
index 5ad88ab8597973872952892770b9ddf23f650699..9e83100310e55ff379be48fe825eeb2018da6fad 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>single-feature-parent</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
index b45038bd330fbf19c82faad22d607633725d6ce8..b7a87d7e17602b6c96f6748ae9e940988fa98b65 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>single-feature-parent</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
@@ -23,7 +23,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <name>OpenDaylight :: transportpce</name>
 
   <properties>
-    <netconf.version>4.0.3</netconf.version>
+    <netconf.version>4.0.4</netconf.version>
     <transportpce.models.version>17.1.0-SNAPSHOT</transportpce.models.version>
     <configfile.directory>etc/opendaylight/karaf</configfile.directory>
   </properties>
index 91e98f334db919b6d56e616cefeeba7c24e6e69e..383e5e01b68afdcd6619c4b60fac8dbfefbad90a 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
index bce055f72dd9f632ef5472b0fc796ec70ad0727c..781ab9ca096940cddfa30fe7f1057228aef5204b 100644 (file)
@@ -10,7 +10,7 @@
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
   <packaging>bundle</packaging>
 
   <properties>
+    <!--
+          FIXME: these versions should be communicated from tpce-models' artifacts pom
+                 and then should be imported just like netconf below
+      -->
     <transportpce.models.version>17.1.0-SNAPSHOT</transportpce.models.version>
   </properties>
 
@@ -28,7 +32,7 @@
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>4.0.1</version>
+        <version>4.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
index 413dafadd1373452cdd907766bf72336664a2af0..414f0cfe41b07e9c16eb1f632d26c5134054245e 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>karaf4-parent</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
index 2c84013b198e48c60ea82428f5e7c7e2bbf261dc..f7071d930d98d8c3c6a5211565b7e0c1aa563f09 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
index 797fca71966b61d8a654fd07b591a7127982022c..7450fa6711503272d3be8ca59efadbdea5f848d7 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.transportpce.nbinotifications.listener;
 
-import java.util.HashMap;
 import java.util.Map;
 import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
+import org.opendaylight.transportpce.nbinotifications.utils.NbiNotificationsUtils;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsListener;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmServiceBuilder;
@@ -20,20 +20,6 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapi
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AdditionalInfo;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AdditionalInfoBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AdditionalInfoKey;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AlarmInfoBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.ChangedAttributes;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.ChangedAttributesBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.ChangedAttributesKey;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectName;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectNameBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectNameKey;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TcaInfoBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -98,64 +84,8 @@ public class NbiNotificationsListenerImpl implements NbiNotificationsListener {
             return;
         }
         Publisher<NotificationTapiService> publisher = tapiPublisherMap.get(topic);
-        publisher.sendEvent(new NotificationTapiServiceBuilder(transformTapiNotification(notification))
-                .build(), topic);
-    }
-
-    private NotificationTapiService transformTapiNotification(PublishTapiNotificationService notification) {
-        Map<AdditionalInfoKey, AdditionalInfo> addInfoMap = new HashMap<>();
-        if (notification.getAdditionalInfo() != null) {
-            for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.AdditionalInfo
-                addInfo:notification.getAdditionalInfo().values()) {
-                AdditionalInfo transAddInfo = new AdditionalInfoBuilder(addInfo).build();
-                addInfoMap.put(transAddInfo.key(), transAddInfo);
-            }
-        }
-        Map<ChangedAttributesKey, ChangedAttributes> changedAttMap = new HashMap<>();
-        if (notification.getChangedAttributes() != null) {
-            for (org.opendaylight.yang.gen.v1
-                .urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes
-                    changedAtt:notification.getChangedAttributes().values()) {
-                ChangedAttributes transChangedAtt = new ChangedAttributesBuilder(changedAtt).build();
-                changedAttMap.put(transChangedAtt.key(), transChangedAtt);
-            }
-        }
-        Map<NameKey, Name> nameMap = new HashMap<>();
-        if (notification.getName() != null) {
-            for (Name name:notification.getName().values()) {
-                Name transName = new NameBuilder(name).build();
-                nameMap.put(transName.key(), transName);
-            }
-        }
-        Map<TargetObjectNameKey, TargetObjectName> targetObjNameMap = new HashMap<>();
-        if (notification.getTargetObjectName() != null) {
-            for (org.opendaylight.yang.gen.v1
-                .urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectName
-                    targetObjectName:notification.getTargetObjectName().values()) {
-                TargetObjectName transTargetObjName = new TargetObjectNameBuilder(targetObjectName).build();
-                targetObjNameMap.put(transTargetObjName.key(), transTargetObjName);
-            }
-        }
-        LOG.info("Notification uuid = {}", notification.getUuid());
-        return new NotificationTapiServiceBuilder()
-            .setAlarmInfo(notification.getAlarmInfo() == null ? null
-                : new AlarmInfoBuilder(notification.getAlarmInfo()).build())
-            .setAdditionalText(notification.getAdditionalText())
-            .setAdditionalInfo(addInfoMap)
-            .setNotificationType(notification.getNotificationType())
-            .setChangedAttributes(changedAttMap)
-            .setEventTimeStamp(notification.getEventTimeStamp())
-            .setLayerProtocolName(notification.getLayerProtocolName())
-            .setName(nameMap)
-            .setSequenceNumber(notification.getSequenceNumber())
-            .setSourceIndicator(notification.getSourceIndicator())
-            .setTargetObjectIdentifier(notification.getTargetObjectIdentifier())
-            .setTargetObjectName(targetObjNameMap)
-            .setTargetObjectType(notification.getTargetObjectType())
-            .setTcaInfo(notification.getTcaInfo() == null ? null
-                : new TcaInfoBuilder(notification.getTcaInfo()).build())
-            .setUuid(notification.getUuid())
-            .build();
+        publisher.sendEvent(new NotificationTapiServiceBuilder(
+                NbiNotificationsUtils.transformTapiNotification(notification)).build(), topic);
     }
 
     public void setPublishersServiceMap(Map<String, Publisher<NotificationProcessService>> publishersServiceMap) {
@@ -169,4 +99,8 @@ public class NbiNotificationsListenerImpl implements NbiNotificationsListener {
     public void setTapiPublishersMap(Map<String, Publisher<NotificationTapiService>> tapiPublishersMap) {
         this.tapiPublisherMap = tapiPublishersMap;
     }
+
+    public Publisher<NotificationTapiService> getTapiPublisherFromTopic(String topic) {
+        return this.tapiPublisherMap.get(topic);
+    }
 }
index af097c35b86d1ec0b222a59126c97f77ad95338b..219f5288f73070200a9798fe30723ca7f25d7c86 100644 (file)
@@ -9,7 +9,26 @@ package org.opendaylight.transportpce.nbinotifications.utils;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Map;
 import java.util.Properties;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AdditionalInfo;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AdditionalInfoBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AdditionalInfoKey;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AlarmInfoBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.ChangedAttributes;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.ChangedAttributesBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.ChangedAttributesKey;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectName;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectNameBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectNameKey;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TcaInfoBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,4 +53,41 @@ public final class NbiNotificationsUtils {
         }
         return props;
     }
+
+    public static NotificationTapiService transformTapiNotification(PublishTapiNotificationService notification) {
+        Map<AdditionalInfoKey, AdditionalInfo> addInfoMap = notification.nonnullAdditionalInfo().values().stream()
+            .collect(Collectors.toMap(
+                    e -> new AdditionalInfoKey(e.getValueName()),
+                    e -> new AdditionalInfoBuilder(e).build()));
+        Map<ChangedAttributesKey, ChangedAttributes> changedAttMap = notification.nonnullChangedAttributes().values()
+                .stream().collect(Collectors.toMap(
+                        e -> new ChangedAttributesKey(e.getValueName()),
+                        e -> new ChangedAttributesBuilder(e).build()));
+        Map<NameKey, Name> nameMap = notification.nonnullName().values().stream()
+                .collect(Collectors.toMap(Name::key, Function.identity()));
+        Map<TargetObjectNameKey, TargetObjectName> targetObjNameMap = notification.nonnullTargetObjectName().values()
+                .stream().collect(Collectors.toMap(
+                        e -> new TargetObjectNameKey(e.getValueName()),
+                        e -> new TargetObjectNameBuilder(e).build()));
+        LOG.info("Notification uuid = {}", notification.getUuid());
+        return new NotificationTapiServiceBuilder()
+                .setAlarmInfo(notification.getAlarmInfo() == null ? null
+                        : new AlarmInfoBuilder(notification.getAlarmInfo()).build())
+                .setAdditionalText(notification.getAdditionalText())
+                .setAdditionalInfo(addInfoMap)
+                .setNotificationType(notification.getNotificationType())
+                .setChangedAttributes(changedAttMap)
+                .setEventTimeStamp(notification.getEventTimeStamp())
+                .setLayerProtocolName(notification.getLayerProtocolName())
+                .setName(nameMap)
+                .setSequenceNumber(notification.getSequenceNumber())
+                .setSourceIndicator(notification.getSourceIndicator())
+                .setTargetObjectIdentifier(notification.getTargetObjectIdentifier())
+                .setTargetObjectName(targetObjNameMap)
+                .setTargetObjectType(notification.getTargetObjectType())
+                .setTcaInfo(notification.getTcaInfo() == null ? null
+                        : new TcaInfoBuilder(notification.getTcaInfo()).build())
+                .setUuid(notification.getUuid())
+                .build();
+    }
 }
index c32142f23b57e047cca5707190ddbb77b0927351..326c4ecdd9522dbdbf4edeec7c405a08b40954a6 100644 (file)
@@ -24,23 +24,29 @@ import org.opendaylight.transportpce.nbinotifications.utils.NotificationServiceD
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.alarm.service.output.NotificationsAlarmService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.process.service.output.NotificationsProcessService;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.get.notification.list.output.Notification;
 
 public class SubscriberTest extends AbstractTest {
     private static final String TOPIC = "topic";
     private static final int PARTITION = 0;
     private MockConsumer<String, NotificationsProcessService> mockConsumer;
     private MockConsumer<String, NotificationsAlarmService> mockConsumerAlarm;
+    private MockConsumer<String, Notification> mockConsumerTapi;
     private Subscriber<NotificationProcessService, NotificationsProcessService> subscriberService;
     private Subscriber<NotificationAlarmService, NotificationsAlarmService> subscriberAlarmService;
+    private Subscriber<NotificationTapiService, Notification> subscriberTapiService;
 
     @Before
     public void setUp() {
         mockConsumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
         mockConsumerAlarm = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
+        mockConsumerTapi = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
         subscriberService = new Subscriber<>(mockConsumer);
         subscriberAlarmService = new Subscriber<>(mockConsumerAlarm);
+        subscriberTapiService = new Subscriber<>(mockConsumerTapi);
     }
 
     @Test
@@ -82,4 +88,24 @@ public class SubscriberTest extends AbstractTest {
         assertEquals("There should be 1 record", 1, result.size());
         assertTrue("Consumer should be closed", mockConsumerAlarm.closed());
     }
+
+    @Test
+    public void subscribeTapiAlarmShouldBeSuccessful() {
+        // from https://www.baeldung.com/kafka-mockconsumer
+        ConsumerRecord<String, Notification> record = new ConsumerRecord<>(
+            TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedTapiAlarmEvent());
+        mockConsumerTapi.schedulePollTask(() -> {
+            mockConsumerTapi.rebalance(Collections.singletonList(new TopicPartition(TOPIC, PARTITION)));
+            mockConsumerTapi.addRecord(record);
+        });
+
+        Map<TopicPartition, Long> startOffsets = new HashMap<>();
+        TopicPartition tp = new TopicPartition(TOPIC, PARTITION);
+        startOffsets.put(tp, 0L);
+        mockConsumerTapi.updateBeginningOffsets(startOffsets);
+        List<Notification> result = subscriberTapiService.subscribe(TOPIC,
+            NotificationTapiService.QNAME);
+        assertEquals("There should be 1 record", 1, result.size());
+        assertTrue("Consumer should be closed", mockConsumerTapi.closed());
+    }
 }
index 018c2d62257796d9afdf3bc7d09ec4c8717b1730..bc025c5d0f6959976a5280a5749d52eecb828742 100644 (file)
@@ -7,17 +7,18 @@
  */
 package org.opendaylight.transportpce.nbinotifications.impl;
 
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.ExecutionException;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.Mock;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.common.network.RequestProcessor;
+import org.opendaylight.transportpce.nbinotifications.utils.NotificationServiceDataUtils;
 import org.opendaylight.transportpce.nbinotifications.utils.TopicManager;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType;
@@ -28,17 +29,20 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotifications
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceOutput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationListOutput;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 public class NbiNotificationsImplTest extends AbstractTest {
     private NbiNotificationsImpl nbiNotificationsImpl;
     public static NetworkTransactionService networkTransactionService;
-
-    @Mock
     private TopicManager topicManager;
 
     @Before
-    public void setUp() {
+    public void setUp() throws ExecutionException, InterruptedException {
+        topicManager = TopicManager.getInstance();
         networkTransactionService = new NetworkTransactionImpl(
             new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
         JsonStringConverter<NotificationProcessService> converter = new JsonStringConverter<>(
@@ -47,6 +51,8 @@ public class NbiNotificationsImplTest extends AbstractTest {
                 getDataStoreContextUtil().getBindingDOMCodecServices());
         JsonStringConverter<NotificationTapiService> converterTapi = new JsonStringConverter<>(
             getDataStoreContextUtil().getBindingDOMCodecServices());
+        topicManager.setTapiConverter(converterTapi);
+        NotificationServiceDataUtils.createTapiContext(networkTransactionService);
 
         nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm, converterTapi,
             "localhost:8080", networkTransactionService, topicManager);
@@ -81,4 +87,28 @@ public class NbiNotificationsImplTest extends AbstractTest {
                 nbiNotificationsImpl.getNotificationsAlarmService(builder.build());
         assertNull("Should be null", result.get().getResult().getNotificationsAlarmService());
     }
+
+    @Test
+    public void createTapiNotificationSubscriptionServiceTest() throws InterruptedException, ExecutionException {
+        CreateNotificationSubscriptionServiceInputBuilder builder
+            = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder();
+        ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
+            nbiNotificationsImpl.createNotificationSubscriptionService(builder.build());
+        assertNotNull("Should receive UUID for subscription service",
+            result.get().getResult().getSubscriptionService().getUuid().toString());
+    }
+
+    @Test
+    public void getTapiNotificationsServiceTest() throws InterruptedException, ExecutionException {
+        CreateNotificationSubscriptionServiceInputBuilder builder
+            = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder();
+        ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
+            nbiNotificationsImpl.createNotificationSubscriptionService(builder.build());
+        GetNotificationListInputBuilder builder1 = new GetNotificationListInputBuilder()
+            .setTimePeriod("Time Period")
+            .setSubscriptionIdOrName(result.get().getResult().getSubscriptionService().getUuid().getValue());
+        ListenableFuture<RpcResult<GetNotificationListOutput>> result1 =
+            nbiNotificationsImpl.getNotificationList(builder1.build());
+        assertNull("Should be null", result1.get().getResult().getNotification());
+    }
 }
index 1743723e6883853be8d9a3563d6fad0199953e23..ced79a2cc9668a296c350c7a895c5d0827e7633b 100644 (file)
@@ -7,43 +7,53 @@
  */
 package org.opendaylight.transportpce.nbinotifications.listener;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import java.util.HashMap;
 import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
+import org.opendaylight.transportpce.nbinotifications.utils.NotificationServiceDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmServiceBuilder;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationServiceBuilder;
 
 public class NbiNotificationsListenerImplTest extends AbstractTest {
     @Mock
     private Publisher<NotificationProcessService> publisherService;
     @Mock
     private Publisher<NotificationAlarmService> publisherAlarm;
+    @Mock
+    private Publisher<NotificationTapiService> publisherTapiService;
 
     @Before
-    public void setUp() {
+    public void setUp() throws ExecutionException, InterruptedException {
         MockitoAnnotations.openMocks(this);
     }
 
     @Test
     public void onPublishNotificationServiceTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
-                Map.of("test", publisherAlarm), new HashMap<>());
+                Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder()
                 .setPublisherName("test")
                 .setCommonId("commonId")
@@ -59,7 +69,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     @Test
     public void onPublishNotificationServiceWrongPublisherTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
-                Map.of("test", publisherAlarm), new HashMap<>());
+                Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder()
                 .setPublisherName("wrongPublisher")
                 .setCommonId("commonId")
@@ -75,7 +85,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     @Test
     public void onPublishNotificationAlarmServiceTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
-                Map.of("test", publisherAlarm), new HashMap<>());
+                Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder()
                 .setPublisherName("test")
                 .setConnectionType(ConnectionType.Service)
@@ -90,7 +100,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     @Test
     public void onPublishNotificationAlarmServiceWrongPublisherTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
-                Map.of("test", publisherAlarm), new HashMap<>());
+                Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder()
                 .setPublisherName("wrongPublisher")
                 .setConnectionType(ConnectionType.Service)
@@ -101,4 +111,37 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
         listener.onPublishNotificationAlarmService(notification);
         verify(publisherAlarm, times(0)).sendEvent(any(), anyString());
     }
+
+    @Test
+    public void onPublishTapiNotificationServiceTest() throws ExecutionException, InterruptedException {
+        NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
+                Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
+
+        PublishTapiNotificationService notification
+            = new PublishTapiNotificationServiceBuilder(NotificationServiceDataUtils.buildReceivedTapiAlarmEvent())
+                .setTopic("test")
+                .build();
+        listener.onPublishTapiNotificationService(notification);
+        verify(publisherTapiService, times(1)).sendEvent(any(), anyString());
+    }
+
+    @Test
+    public void onPublishTapiNotificationServiceTestWrongPublisherTest() {
+        NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
+            Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
+        PublishTapiNotificationService notification
+            = new PublishTapiNotificationServiceBuilder(NotificationServiceDataUtils.buildReceivedTapiAlarmEvent())
+                .setTopic(UUID.randomUUID().toString())
+                .build();
+        listener.onPublishTapiNotificationService(notification);
+        verify(publisherTapiService, times(0)).sendEvent(any(), eq(notification.getTopic()));
+    }
+
+    @Test
+    public void getTapiPublisherFromTopicTest() {
+        NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
+                Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
+        assertNull(listener.getTapiPublisherFromTopic("toto"));
+        assertEquals(publisherTapiService, listener.getTapiPublisherFromTopic("test"));
+    }
 }
index 1d988fc0ce2700b4bd6ca9d43fc7cb168879f181..0e07aff231382b9e25252ff41d30eae7b5ffa9b5 100644 (file)
@@ -9,46 +9,86 @@ package org.opendaylight.transportpce.nbinotifications.producer;
 
 import static org.junit.Assert.assertEquals;
 
+import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ExecutionException;
 import org.apache.kafka.clients.producer.MockProducer;
 import org.apache.kafka.common.serialization.StringSerializer;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.MockitoAnnotations;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
+import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.transportpce.common.network.RequestProcessor;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
 import org.opendaylight.transportpce.nbinotifications.serialization.ConfigConstants;
 import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceSerializer;
 import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceSerializer;
+import org.opendaylight.transportpce.nbinotifications.serialization.TapiNotificationSerializer;
+import org.opendaylight.transportpce.nbinotifications.utils.NotificationServiceDataUtils;
+import org.opendaylight.transportpce.nbinotifications.utils.TopicManager;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceOutput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.create.notification.subscription.service.input.SubscriptionFilter;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.create.notification.subscription.service.input.SubscriptionFilterBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
 
 public class PublisherTest extends AbstractTest {
     private JsonStringConverter<NotificationProcessService> converterService;
     private JsonStringConverter<NotificationAlarmService> converterAlarm;
+    private JsonStringConverter<NotificationTapiService> converterTapiService;
     private Publisher<NotificationProcessService> publisherService;
     private Publisher<NotificationAlarmService> publisherAlarm;
+    private Publisher<NotificationTapiService> publisherTapiService;
     private MockProducer<String, NotificationProcessService> mockProducer;
     private MockProducer<String, NotificationAlarmService> mockAlarmProducer;
+    private MockProducer<String, NotificationTapiService> mockTapiProducer;
+    private NbiNotificationsImpl nbiNotificationsImpl;
+    private TopicManager topicManager;
+
+    public static NetworkTransactionService networkTransactionService;
 
     @Before
-    public void setUp() {
+    public void setUp() throws ExecutionException, InterruptedException {
+        topicManager = TopicManager.getInstance();
         converterService = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         converterAlarm = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
+        converterTapiService = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         NotificationServiceSerializer serializerService = new NotificationServiceSerializer();
         NotificationAlarmServiceSerializer serializerAlarm = new NotificationAlarmServiceSerializer();
+        TapiNotificationSerializer serializerTapi = new TapiNotificationSerializer();
         Map<String, Object> properties = Map.of(ConfigConstants.CONVERTER, converterService);
         Map<String, Object> propertiesAlarm = Map.of(ConfigConstants.CONVERTER, converterAlarm);
+        Map<String, Object> propertiesTapi = Map.of(ConfigConstants.CONVERTER, converterTapiService);
         serializerService.configure(properties, false);
         serializerAlarm.configure(propertiesAlarm, false);
+        serializerTapi.configure(propertiesTapi, false);
         mockProducer = new MockProducer<>(true, new StringSerializer(), serializerService);
         mockAlarmProducer = new MockProducer<>(true, new StringSerializer(), serializerAlarm);
+        mockTapiProducer = new MockProducer<>(true, new StringSerializer(), serializerTapi);
         publisherService = new Publisher<>("test", mockProducer);
         publisherAlarm = new Publisher<>("test", mockAlarmProducer);
+        publisherTapiService = new Publisher<>("test", mockTapiProducer);
+        MockitoAnnotations.openMocks(this);
+        networkTransactionService = new NetworkTransactionImpl(
+            new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
+        topicManager.setTapiConverter(converterTapiService);
+        NotificationServiceDataUtils.createTapiContext(networkTransactionService);
+        nbiNotificationsImpl = new NbiNotificationsImpl(converterService, converterAlarm, converterTapiService,
+            "localhost:8080", networkTransactionService, topicManager);
     }
 
     @Test
@@ -73,4 +113,23 @@ public class PublisherTest extends AbstractTest {
         assertEquals("We should have one message", 1, mockAlarmProducer.history().size());
         assertEquals("Key should be test", "test", mockAlarmProducer.history().get(0).key());
     }
+
+    @Test
+    public void sendTapiEventShouldBeSuccessful() throws IOException {
+        CreateNotificationSubscriptionServiceInputBuilder builder
+            = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder();
+        SubscriptionFilter subscriptionFilter = new SubscriptionFilterBuilder(builder.getSubscriptionFilter())
+            .setRequestedObjectIdentifier(new HashSet<>(List.of(new Uuid("76d8f07b-ead5-4132-8eb8-cf3fdef7e079"))))
+            .build();
+        builder.setSubscriptionFilter(subscriptionFilter);
+        ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
+            nbiNotificationsImpl.createNotificationSubscriptionService(builder.build());
+        String json = Files.readString(Paths.get("src/test/resources/tapi_event.json"));
+        NotificationTapiService notificationTapiService = converterTapiService
+            .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationTapiService.QNAME),
+                json, JSONCodecFactorySupplier.RFC7951);
+        publisherTapiService.sendEvent(notificationTapiService, "");
+        assertEquals("We should have one message", 1, mockTapiProducer.history().size());
+        assertEquals("Key should be test", "test", mockTapiProducer.history().get(0).key());
+    }
 }
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceDeserializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceDeserializerTest.java
new file mode 100644 (file)
index 0000000..e50231e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright Â© 2021 Nokia, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.serialization;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Map;
+import org.junit.Test;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.get.notification.list.output.Notification;
+
+public class NotificationTapiServiceDeserializerTest extends AbstractTest {
+
+    @Test
+    public void deserializeTest() throws IOException {
+        JsonStringConverter<NotificationTapiService> converter = new JsonStringConverter<>(
+                getDataStoreContextUtil().getBindingDOMCodecServices());
+        TapiNotificationDeserializer deserializer = new TapiNotificationDeserializer();
+        Map<String, Object> configs = Map.of(ConfigConstants.CONVERTER, converter);
+        deserializer.configure(configs, false);
+        Notification readEvent = deserializer.deserialize("76d8f07b-ead5-4132-8eb8-cf3fdef7e079",
+                Files.readAllBytes(Paths.get("src/test/resources/tapi_event.json")));
+        deserializer.close();
+        assertEquals("Service uuid should be 76d8f07b-ead5-4132-8eb8-cf3fdef7e079",
+            "76d8f07b-ead5-4132-8eb8-cf3fdef7e079", readEvent.getTargetObjectIdentifier().getValue());
+    }
+}
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceSerializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceSerializerTest.java
new file mode 100644 (file)
index 0000000..233b1a9
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright Â© 2021 Nokia, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.serialization;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Map;
+import org.junit.Test;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
+
+public class NotificationTapiServiceSerializerTest extends AbstractTest {
+
+    @Test
+    public void serializeTest() throws IOException {
+        JsonStringConverter<NotificationTapiService> converter =
+                new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
+        String json = Files.readString(Paths.get("src/test/resources/tapi_event.json"));
+        NotificationTapiService notificationService = converter
+                .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationTapiService.QNAME),
+                        json, JSONCodecFactorySupplier.RFC7951);
+        TapiNotificationSerializer serializer = new TapiNotificationSerializer();
+        Map<String, Object> configs = Map.of(ConfigConstants.CONVERTER, converter);
+        serializer.configure(configs, false);
+        byte[] data = serializer.serialize("test", notificationService);
+        serializer.close();
+        assertNotNull("Serialized data should not be null", data);
+        String expectedJson = Files.readString(Paths.get("src/test/resources/expected_tapi_event.json"));
+        // Minify the json string
+        expectedJson = new ObjectMapper().readValue(expectedJson, JsonNode.class).toString();
+        assertEquals("The event should be equals", expectedJson, new String(data, StandardCharsets.UTF_8));
+    }
+}
index ea8c5496a548b8c22b0fdff46b7795578bb71b04..195ef39fac788f952e7be3fbc77fbab548d72938 100644 (file)
@@ -7,7 +7,18 @@
  */
 package org.opendaylight.transportpce.nbinotifications.utils;
 
+import java.nio.charset.Charset;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.RxDirection;
@@ -28,11 +39,42 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notification
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.process.service.output.NotificationsProcessServiceBuilder;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1Builder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContextBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationType;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.ObjectType;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.SubscriptionState;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.context.NotificationContextBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.create.notification.subscription.service.input.SubscriptionFilter;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.create.notification.subscription.service.input.SubscriptionFilterBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.get.notification.list.output.Notification;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.get.notification.list.output.NotificationBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectName;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectNameBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContextBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.NwTopologyServiceBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.common.Uint8;
 
 public final class NotificationServiceDataUtils {
 
+    public static final String TAPI_CONTEXT = "T-API context";
+
     private NotificationServiceDataUtils() {
     }
 
@@ -71,6 +113,38 @@ public final class NotificationServiceDataUtils {
                 .build();
     }
 
+    public static Notification buildReceivedTapiAlarmEvent() {
+        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
+        OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
+        DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
+        Uuid targetObjectId = new Uuid(UUID.randomUUID().toString());
+        TargetObjectName objectName = new TargetObjectNameBuilder()
+            .setValue(targetObjectId.getValue())
+            .setValueName("Connectivity Service Name")
+            .build();
+        ChangedAttributes adminStateChange = new ChangedAttributesBuilder()
+            .setValueName("administrativeState")
+            .setOldValue(AdministrativeState.LOCKED.getName())
+            .setNewValue(AdministrativeState.UNLOCKED.getName())
+            .build();
+        ChangedAttributes operStateChange = new ChangedAttributesBuilder()
+            .setValueName("operationalState")
+            .setOldValue(OperationalState.DISABLED.getName())
+            .setNewValue(OperationalState.ENABLED.getName())
+            .build();
+        return new NotificationBuilder()
+            .setNotificationType(NotificationType.ATTRIBUTEVALUECHANGE)
+            .setLayerProtocolName(LayerProtocolName.ETH)
+            .setTargetObjectType(ObjectType.CONNECTIVITYSERVICE)
+            .setEventTimeStamp(datetime)
+            .setUuid(new Uuid(UUID.randomUUID().toString()))
+            .setTargetObjectIdentifier(targetObjectId)
+            .setTargetObjectName(Map.of(objectName.key(), objectName))
+            .setChangedAttributes(Map.of(adminStateChange.key(), adminStateChange,
+                operStateChange.key(), operStateChange))
+            .build();
+    }
+
     public static ServiceAEndBuilder getServiceAEndBuild() {
         return new ServiceAEndBuilder()
                 .setClli("clli")
@@ -91,6 +165,25 @@ public final class NotificationServiceDataUtils {
                 .setRxDirection(getRxDirection());
     }
 
+    public static CreateNotificationSubscriptionServiceInputBuilder buildNotificationSubscriptionServiceInputBuilder() {
+        Name name = new NameBuilder()
+            .setValue("test subscription")
+            .setValueName("Subscription name")
+            .build();
+        SubscriptionFilter subscriptionFilter = new SubscriptionFilterBuilder()
+            .setRequestedObjectTypes(new HashSet<>(List.of(ObjectType.CONNECTIVITYSERVICE)))
+            .setRequestedNotificationTypes(new HashSet<>(List.of(NotificationType.ALARMEVENT)))
+            .setRequestedLayerProtocols(new HashSet<>(List.of(LayerProtocolName.ETH)))
+            .setRequestedObjectIdentifier(new HashSet<>(List.of(new Uuid(UUID.randomUUID().toString()))))
+            .setIncludeContent(true)
+            .setLocalId("localId")
+            .setName(Map.of(name.key(), name))
+            .build();
+        return new CreateNotificationSubscriptionServiceInputBuilder()
+            .setSubscriptionFilter(subscriptionFilter)
+            .setSubscriptionState(SubscriptionState.ACTIVE);
+    }
+
     private static Map<TxDirectionKey, TxDirection> getTxDirection() {
         return Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
                 .setPort(new PortBuilder()
@@ -132,4 +225,71 @@ public final class NotificationServiceDataUtils {
                 .setIndex(Uint8.ZERO)
                 .build());
     }
+
+    public static void createTapiContext(
+            NetworkTransactionService networkTransactionService) throws ExecutionException, InterruptedException {
+        // Augmenting tapi context to include topology and connectivity contexts
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name contextName
+            = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder()
+            .setValue(TAPI_CONTEXT).setValueName("TAPI Context Name").build();
+
+        Context1 connectivityContext =
+            new Context1Builder()
+                .setConnectivityContext(
+                    new ConnectivityContextBuilder()
+                        .setConnection(new HashMap<>())
+                        .setConnectivityService(new HashMap<>())
+                        .build())
+                .build();
+
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name nwTopoServiceName =
+            new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder()
+                .setValue("Network Topo Service")
+                .setValueName("Network Topo Service Name")
+                .build();
+
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1 topologyContext
+            = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1Builder()
+            .setTopologyContext(new TopologyContextBuilder()
+                .setNwTopologyService(new NwTopologyServiceBuilder()
+                    .setTopology(new HashMap<>())
+                    .setUuid(
+                        new Uuid(
+                            UUID.nameUUIDFromBytes("Network Topo Service".getBytes(Charset.forName("UTF-8")))
+                                .toString()))
+                    .setName(Map.of(nwTopoServiceName.key(), nwTopoServiceName))
+                    .build())
+                .setTopology(new HashMap<>())
+                .build())
+            .build();
+
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.Context1 notificationContext
+            = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.Context1Builder()
+            .setNotificationContext(new NotificationContextBuilder()
+                .setNotification(new HashMap<>())
+                .setNotifSubscription(new HashMap<>())
+                .build())
+            .build();
+
+        ContextBuilder contextBuilder = new ContextBuilder()
+            .setName(Map.of(contextName.key(), contextName))
+            .setUuid(
+                new Uuid(UUID.nameUUIDFromBytes(TAPI_CONTEXT.getBytes(Charset.forName("UTF-8"))).toString()))
+            .setServiceInterfacePoint(new HashMap<>())
+            .addAugmentation(connectivityContext)
+            .addAugmentation(topologyContext)
+            .addAugmentation(notificationContext);
+
+        // todo: add notification context
+        InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
+        // put in datastore
+        networkTransactionService.put(LogicalDatastoreType.OPERATIONAL, contextIID, contextBuilder.build());
+        networkTransactionService.commit().get();
+    }
+
+    public static GetNotificationListInputBuilder buildGetNotificationListInputBuilder(String subscriptionUuid) {
+        return new GetNotificationListInputBuilder()
+                .setSubscriptionIdOrName(subscriptionUuid)
+                .setTimePeriod("some string");
+    }
 }
diff --git a/nbinotifications/src/test/resources/expected_tapi_event.json b/nbinotifications/src/test/resources/expected_tapi_event.json
new file mode 100755 (executable)
index 0000000..068a5ed
--- /dev/null
@@ -0,0 +1,28 @@
+{
+  "nbi-notifications:notification-tapi-service": {
+    "layer-protocol-name": "ETH",
+    "notification-type": "ATTRIBUTE_VALUE_CHANGE",
+    "changed-attributes": [
+      {
+        "value-name": "administrativeState",
+        "old-value": "LOCKED",
+        "new-value": "UNLOCKED"
+      },
+      {
+        "value-name": "operationalState",
+        "old-value": "DISABLED",
+        "new-value": "ENABLED"
+      }
+    ],
+    "target-object-name": [
+      {
+        "value-name": "Connectivity Service Name",
+        "value": "76d8f07b-ead5-4132-8eb8-cf3fdef7e079"
+      }
+    ],
+    "uuid": "6ae49721-7f96-4924-b23b-31e5bee4946b",
+    "target-object-type": "CONNECTIVITY_SERVICE",
+    "event-time-stamp": "2022-04-06T09:06:01+00:00",
+    "target-object-identifier": "76d8f07b-ead5-4132-8eb8-cf3fdef7e079"
+  }
+}
\ No newline at end of file
diff --git a/nbinotifications/src/test/resources/tapi_event.json b/nbinotifications/src/test/resources/tapi_event.json
new file mode 100644 (file)
index 0000000..068a5ed
--- /dev/null
@@ -0,0 +1,28 @@
+{
+  "nbi-notifications:notification-tapi-service": {
+    "layer-protocol-name": "ETH",
+    "notification-type": "ATTRIBUTE_VALUE_CHANGE",
+    "changed-attributes": [
+      {
+        "value-name": "administrativeState",
+        "old-value": "LOCKED",
+        "new-value": "UNLOCKED"
+      },
+      {
+        "value-name": "operationalState",
+        "old-value": "DISABLED",
+        "new-value": "ENABLED"
+      }
+    ],
+    "target-object-name": [
+      {
+        "value-name": "Connectivity Service Name",
+        "value": "76d8f07b-ead5-4132-8eb8-cf3fdef7e079"
+      }
+    ],
+    "uuid": "6ae49721-7f96-4924-b23b-31e5bee4946b",
+    "target-object-type": "CONNECTIVITY_SERVICE",
+    "event-time-stamp": "2022-04-06T09:06:01+00:00",
+    "target-object-identifier": "76d8f07b-ead5-4132-8eb8-cf3fdef7e079"
+  }
+}
\ No newline at end of file
index abcbe927944df017d91b8c447feac0cc605788fc..032ec1868f82f3cb717904a50e953538d0509adb 100644 (file)
@@ -13,7 +13,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
@@ -31,21 +31,21 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>9.0.2</version>
+        <version>9.0.5</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
       <dependency>
         <groupId>org.opendaylight.mdsal</groupId>
         <artifactId>mdsal-artifacts</artifactId>
-        <version>10.0.3</version>
+        <version>10.0.5</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>4.0.3</version>
+        <version>4.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
index 1a02100852b86544b5179a2614dd2a82560d5edc..a3d6c1840189b22c226b06108975734b76a1c6b5 100644 (file)
@@ -13,7 +13,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
index ab2dfd1e648e09d2d48ed530682d2ad5071661f5..cbab19fca60eab100454d7e5ba7959ca1f8ade4e 100644 (file)
@@ -14,7 +14,7 @@
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
diff --git a/pom.xml b/pom.xml
index 5367b0fb8b265d9c5102c7148f576bf97a3aa841..f4697981e00c49c3754cb23421f4ca9a6a97fcd0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent</artifactId>
-    <version>11.0.2</version>
+    <version>11.0.3</version>
     <relativePath/>
   </parent>
 
index 638fbe85a292b077d420cc6d8d28f06db1a23471..abf1ce361091dc846ea39c2ab2713bc41c607b88 100644 (file)
@@ -13,7 +13,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
index 947417ef2c582a2ebafc09b66b38cbe2c50fc560..6e9947501163487d0ff29881d5ec6bb5523a42d0 100644 (file)
@@ -15,7 +15,7 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
index 45b1a609861167f05a6ea4d4ab3aee947b6977ec..d43332e3937601350c607ad619a3129c9ccd1383 100644 (file)
@@ -15,7 +15,7 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
@@ -33,7 +33,7 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>4.0.3</version>
+        <version>4.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
index a578dd5d1d07aa198c8a1b3de7d4abc7ad4fc0bc..70effbed4d759d7486d65abf03c1f0b51a818094 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>10.0.3</version>
+    <version>10.0.5</version>
     <relativePath/>
   </parent>
 
@@ -30,7 +30,7 @@
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>4.0.3</version>
+        <version>4.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
index 5a043a7f0f3f50b7f21dc3d1a2ff6f76f914db9e..75c523abf9fc7da3ff7fb41560b3091890e9c18e 100644 (file)
@@ -58,8 +58,10 @@ else:
     RESTCONF_PORT = 8181
 
 RESTCONF_PATH_PREFIX = {'rfc8040': '/rests',
-                        'lighty': '/restconf',
                         'draft-bierman02': '/restconf'}
+if 'USE_LIGHTY' in os.environ and os.environ['USE_LIGHTY'] == 'True':
+    RESTCONF_PATH_PREFIX['rfc8040'] = '/restconf'
+
 if 'USE_ODL_RESTCONF_VERSION' in os.environ:
     RESTCONF_VERSION = os.environ['USE_ODL_RESTCONF_VERSION']
     if RESTCONF_VERSION not in RESTCONF_PATH_PREFIX:
@@ -281,7 +283,6 @@ class TimeOut:
 
 def mount_device(node: str, sim: str):
     url = {'rfc8040': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}',
-           'lighty': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}',
            'draft-bierman02': '{}/config/network-topology:network-topology/topology/topology-netconf/node/{}'}
     body = {'node': [{
         'node-id': node,
@@ -304,7 +305,6 @@ def mount_device(node: str, sim: str):
 
 def unmount_device(node: str):
     url = {'rfc8040': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}',
-           'lighty': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}',
            'draft-bierman02': '{}/config/network-topology:network-topology/topology/topology-netconf/node/{}'}
     response = delete_request(url[RESTCONF_VERSION].format('{}', node))
     if wait_until_log_contains(TPCE_LOG, re.escape("onDeviceDisConnected: " + node), 180):
@@ -316,12 +316,10 @@ def unmount_device(node: str):
 
 def check_device_connection(node: str):
     url = {'rfc8040': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}?content=nonconfig',
-           'lighty': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}?content=nonconfig',
            'draft-bierman02': '{}/operational/network-topology:network-topology/topology/topology-netconf/node/{}'}
     response = get_request(url[RESTCONF_VERSION].format('{}', node))
     res = response.json()
     return_key = {'rfc8040': 'network-topology:node',
-                  'lighty': 'network-topology:node',
                   'draft-bierman02': 'node'}
     if return_key[RESTCONF_VERSION] in res.keys():
         connection_status = res[return_key[RESTCONF_VERSION]][0]['netconf-node-topology:connection-status']
@@ -334,12 +332,10 @@ def check_device_connection(node: str):
 def check_node_request(node: str):
     # pylint: disable=line-too-long
     url = {'rfc8040': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}/yang-ext:mount/org-openroadm-device:org-openroadm-device?content=config',  # nopep8
-           'lighty': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}/yang-ext:mount/org-openroadm-device:org-openroadm-device?content=config',  # nopep8
            'draft-bierman02': '{}/config/network-topology:network-topology/topology/topology-netconf/node/{}/yang-ext:mount/org-openroadm-device:org-openroadm-device'}  # nopep8
     response = get_request(url[RESTCONF_VERSION].format('{}', node))
     res = response.json()
     return_key = {'rfc8040': 'org-openroadm-device:org-openroadm-device',
-                  'lighty': 'org-openroadm-device:org-openroadm-device',
                   'draft-bierman02': 'org-openroadm-device'}
     if return_key[RESTCONF_VERSION] in res.keys():
         response_attribute = res[return_key[RESTCONF_VERSION]]
@@ -352,12 +348,10 @@ def check_node_request(node: str):
 def check_node_attribute_request(node: str, attribute: str, attribute_value: str):
     # pylint: disable=line-too-long
     url = {'rfc8040': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}/yang-ext:mount/org-openroadm-device:org-openroadm-device/{}={}?content=nonconfig',  # nopep8
-           'lighty': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}/yang-ext:mount/org-openroadm-device:org-openroadm-device/{}={}?content=nonconfig',  # nopep8
            'draft-bierman02': '{}/operational/network-topology:network-topology/topology/topology-netconf/node/{}/yang-ext:mount/org-openroadm-device:org-openroadm-device/{}/{}'}  # nopep8
     response = get_request(url[RESTCONF_VERSION].format('{}', node, attribute, attribute_value))
     res = response.json()
     return_key = {'rfc8040': 'org-openroadm-device:' + attribute,
-                  'lighty': 'org-openroadm-device:' + attribute,
                   'draft-bierman02': attribute}
     if return_key[RESTCONF_VERSION] in res.keys():
         response_attribute = res[return_key[RESTCONF_VERSION]]
@@ -370,7 +364,6 @@ def check_node_attribute_request(node: str, attribute: str, attribute_value: str
 def check_node_attribute2_request(node: str, attribute: str, attribute_value: str, attribute2: str):
     # pylint: disable=line-too-long
     url = {'rfc8040': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}/yang-ext:mount/org-openroadm-device:org-openroadm-device/{}={}/{}?content=config',  # nopep8
-           'lighty': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}/yang-ext:mount/org-openroadm-device:org-openroadm-device/{}={}/{}?content=config',  # nopep8
            'draft-bierman02': '{}/config/network-topology:network-topology/topology/topology-netconf/node/{}/yang-ext:mount/org-openroadm-device:org-openroadm-device/{}/{}/{}'}  # nopep8
     response = get_request(url[RESTCONF_VERSION].format('{}', node, attribute, attribute_value, attribute2))
     res = response.json()
@@ -385,7 +378,6 @@ def check_node_attribute2_request(node: str, attribute: str, attribute_value: st
 def del_node_attribute_request(node: str, attribute: str, attribute_value: str):
     # pylint: disable=line-too-long
     url = {'rfc8040': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}/yang-ext:mount/org-openroadm-device:org-openroadm-device/{}={}',  # nopep8
-           'lighty': '{}/data/network-topology:network-topology/topology=topology-netconf/node={}/yang-ext:mount/org-openroadm-device:org-openroadm-device/{}={}',  # nopep8
            'draft-bierman02': '{}/config/network-topology:network-topology/topology/topology-netconf/node/{}/yang-ext:mount/org-openroadm-device:org-openroadm-device/{}/{}'}  # nopep8
     response = delete_request(url[RESTCONF_VERSION].format('{}', node, attribute, attribute_value))
     return response
@@ -397,7 +389,6 @@ def del_node_attribute_request(node: str, attribute: str, attribute_value: str):
 
 def post_portmapping(payload: str):
     url = {'rfc8040': '{}/data/transportpce-portmapping:network',
-           'lighty': '{}/data/transportpce-portmapping:network',
            'draft-bierman02': '{}/config/transportpce-portmapping:network'}
     json_payload = json.loads(payload)
     response = post_request(url[RESTCONF_VERSION].format('{}'), json_payload)
@@ -406,7 +397,6 @@ def post_portmapping(payload: str):
 
 def del_portmapping():
     url = {'rfc8040': '{}/data/transportpce-portmapping:network',
-           'lighty': '{}/data/transportpce-portmapping:network',
            'draft-bierman02': '{}/config/transportpce-portmapping:network'}
     response = delete_request(url[RESTCONF_VERSION].format('{}'))
     return {'status_code': response.status_code}
@@ -415,20 +405,18 @@ def del_portmapping():
 def get_portmapping_node_attr(node: str, attr: str, value: str):
     # pylint: disable=consider-using-f-string
     url = {'rfc8040': '{}/data/transportpce-portmapping:network/nodes={}',
-           'lighty': '{}/data/transportpce-portmapping:network/nodes={}',
            'draft-bierman02': '{}/config/transportpce-portmapping:network/nodes/{}'}
     target_url = url[RESTCONF_VERSION].format('{}', node)
     if attr is not None:
         target_url = (target_url + '/{}').format('{}', attr)
         if value is not None:
-            suffix = {'rfc8040': '={}', 'lighty': '={}', 'draft-bierman02': '/{}'}
+            suffix = {'rfc8040': '={}', 'draft-bierman02': '/{}'}
             target_url = (target_url + suffix[RESTCONF_VERSION]).format('{}', value)
     else:
         attr = 'nodes'
     response = get_request(target_url)
     res = response.json()
     return_key = {'rfc8040': 'transportpce-portmapping:' + attr,
-                  'lighty': 'transportpce-portmapping:' + attr,
                   'draft-bierman02': attr}
     if return_key[RESTCONF_VERSION] in res.keys():
         return_output = res[return_key[RESTCONF_VERSION]]
@@ -444,9 +432,8 @@ def get_portmapping_node_attr(node: str, attr: str, value: str):
 
 def get_ietf_network_request(network: str, content: str):
     url = {'rfc8040': '{}/data/ietf-network:networks/network={}?content={}',
-           'lighty': '{}/data/ietf-network:networks/network={}?content={}',
            'draft-bierman02': '{}/{}/ietf-network:networks/network/{}'}
-    if RESTCONF_VERSION in ('rfc8040', 'lighty'):
+    if RESTCONF_VERSION in ('rfc8040'):
         format_args = ('{}', network, content)
     elif content == 'config':
         format_args = ('{}', content, network)
@@ -456,7 +443,6 @@ def get_ietf_network_request(network: str, content: str):
     if bool(response):
         res = response.json()
         return_key = {'rfc8040': 'ietf-network:network',
-                      'lighty': 'ietf-network:network',
                       'draft-bierman02': 'network'}
         networks = res[return_key[RESTCONF_VERSION]]
     else:
@@ -467,7 +453,6 @@ def get_ietf_network_request(network: str, content: str):
 
 def put_ietf_network(network: str, payload: str):
     url = {'rfc8040': '{}/data/ietf-network:networks/network={}',
-           'lighty': '{}/data/ietf-network:networks/network={}',
            'draft-bierman02': '{}/config/ietf-network:networks/network/{}'}
     json_payload = json.loads(payload)
     response = put_request(url[RESTCONF_VERSION].format('{}', network), json_payload)
@@ -476,7 +461,6 @@ def put_ietf_network(network: str, payload: str):
 
 def del_ietf_network(network: str):
     url = {'rfc8040': '{}/data/ietf-network:networks/network={}',
-           'lighty': '{}/data/ietf-network:networks/network={}',
            'draft-bierman02': '{}/config/ietf-network:networks/network/{}'}
     response = delete_request(url[RESTCONF_VERSION].format('{}', network))
     return {'status_code': response.status_code}
@@ -484,9 +468,8 @@ def del_ietf_network(network: str):
 
 def get_ietf_network_link_request(network: str, link: str, content: str):
     url = {'rfc8040': '{}/data/ietf-network:networks/network={}/ietf-network-topology:link={}?content={}',
-           'lighty': '{}/data/ietf-network:networks/network={}/ietf-network-topology:link={}?content={}',
            'draft-bierman02': '{}/{}/ietf-network:networks/network/{}/ietf-network-topology:link/{}'}
-    if RESTCONF_VERSION in ('rfc8040', 'lighty'):
+    if RESTCONF_VERSION in ('rfc8040'):
         format_args = ('{}', network, link, content)
     elif content == 'config':
         format_args = ('{}', content, network, link)
@@ -495,7 +478,6 @@ def get_ietf_network_link_request(network: str, link: str, content: str):
     response = get_request(url[RESTCONF_VERSION].format(*format_args))
     res = response.json()
     return_key = {'rfc8040': 'ietf-network-topology:link',
-                  'lighty': 'ietf-network-topology:link',
                   'draft-bierman02': 'ietf-network-topology:link'}
     link = res[return_key[RESTCONF_VERSION]][0]
     return {'status_code': response.status_code,
@@ -504,9 +486,8 @@ def get_ietf_network_link_request(network: str, link: str, content: str):
 
 def del_ietf_network_link_request(network: str, link: str, content: str):
     url = {'rfc8040': '{}/data/ietf-network:networks/network={}/ietf-network-topology:link={}?content={}',
-           'lighty': '{}/data/ietf-network:networks/network={}/ietf-network-topology:link={}?content={}',
            'draft-bierman02': '{}/{}/ietf-network:networks/network/{}/ietf-network-topology:link/{}'}
-    if RESTCONF_VERSION in ('rfc8040', 'lighty'):
+    if RESTCONF_VERSION in ('rfc8040'):
         format_args = ('{}', network, link, content)
     elif content == 'config':
         format_args = ('{}', content, network, link)
@@ -518,7 +499,6 @@ def del_ietf_network_link_request(network: str, link: str, content: str):
 
 def add_oms_attr_request(link: str, oms_attr: str):
     url = {'rfc8040': '{}/data/ietf-network:networks/network={}/ietf-network-topology:link={}',
-           'lighty': '{}/data/ietf-network:networks/network={}/ietf-network-topology:link={}',
            'draft-bierman02': '{}/config/ietf-network:networks/network/{}/ietf-network-topology:link/{}'}
     url2 = url[RESTCONF_VERSION] + '/org-openroadm-network-topology:OMS-attributes/span'
     network = 'openroadm-topology'
@@ -528,7 +508,6 @@ def add_oms_attr_request(link: str, oms_attr: str):
 
 def del_oms_attr_request(link: str,):
     url = {'rfc8040': '{}/data/ietf-network:networks/network={}/ietf-network-topology:link={}',
-           'lighty': '{}/data/ietf-network:networks/network={}/ietf-network-topology:link={}',
            'draft-bierman02': '{}/config/ietf-network:networks/network/{}/ietf-network-topology:link/{}'}
     url2 = url[RESTCONF_VERSION] + '/org-openroadm-network-topology:OMS-attributes/span'
     network = 'openroadm-topology'
@@ -538,9 +517,8 @@ def del_oms_attr_request(link: str,):
 
 def get_ietf_network_node_request(network: str, node: str, content: str):
     url = {'rfc8040': '{}/data/ietf-network:networks/network={}/node={}?content={}',
-           'lighty': '{}/data/ietf-network:networks/network={}/node={}?content={}',
            'draft-bierman02': '{}/{}/ietf-network:networks/network/{}/node/{}'}
-    if RESTCONF_VERSION in ('rfc8040', 'lighty'):
+    if RESTCONF_VERSION in ('rfc8040'):
         format_args = ('{}', network, node, content)
     elif content == 'config':
         format_args = ('{}', content, network, node)
@@ -550,7 +528,6 @@ def get_ietf_network_node_request(network: str, node: str, content: str):
     if bool(response):
         res = response.json()
         return_key = {'rfc8040': 'ietf-network:node',
-                      'lighty': 'ietf-network:node',
                       'draft-bierman02': 'node'}
         node = res[return_key[RESTCONF_VERSION]][0]
     else:
@@ -561,9 +538,8 @@ def get_ietf_network_node_request(network: str, node: str, content: str):
 
 def del_ietf_network_node_request(network: str, node: str, content: str):
     url = {'rfc8040': '{}/data/ietf-network:networks/network={}/node={}?content={}',
-           'lighty': '{}/data/ietf-network:networks/network={}/node={}?content={}',
            'draft-bierman02': '{}/{}/ietf-network:networks/network/{}/node/{}'}
-    if RESTCONF_VERSION in ('rfc8040', 'lighty'):
+    if RESTCONF_VERSION in ('rfc8040'):
         format_args = ('{}', network, node, content)
     elif content == 'config':
         format_args = ('{}', content, network, node)
@@ -580,12 +556,10 @@ def del_ietf_network_node_request(network: str, node: str, content: str):
 
 def get_ordm_serv_list_request():
     url = {'rfc8040': '{}/data/org-openroadm-service:service-list?content=nonconfig',
-           'lighty': '{}/data/org-openroadm-service:service-list?content=nonconfig',
            'draft-bierman02': '{}/operational/org-openroadm-service:service-list/'}
     response = get_request(url[RESTCONF_VERSION])
     res = response.json()
     return_key = {'rfc8040': 'org-openroadm-service:service-list',
-                  'lighty': 'org-openroadm-service:service-list',
                   'draft-bierman02': 'service-list'}
     if return_key[RESTCONF_VERSION] in res.keys():
         response_attribute = res[return_key[RESTCONF_VERSION]]
@@ -597,13 +571,11 @@ def get_ordm_serv_list_request():
 
 def get_ordm_serv_list_attr_request(attribute: str, value: str):
     url = {'rfc8040': '{}/data/org-openroadm-service:service-list/{}={}?content=nonconfig',
-           'lighty': '{}/data/org-openroadm-service:service-list/{}={}?content=nonconfig',
            'draft-bierman02': '{}/operational/org-openroadm-service:service-list/{}/{}'}
     format_args = ('{}', attribute, value)
     response = get_request(url[RESTCONF_VERSION].format(*format_args))
     res = response.json()
     return_key = {'rfc8040': 'org-openroadm-service:' + attribute,
-                  'lighty': 'org-openroadm-service:' + attribute,
                   'draft-bierman02': attribute}
     if return_key[RESTCONF_VERSION] in res.keys():
         response_attribute = res[return_key[RESTCONF_VERSION]]
@@ -615,12 +587,10 @@ def get_ordm_serv_list_attr_request(attribute: str, value: str):
 
 def get_serv_path_list_attr(attribute: str, value: str):
     url = {'rfc8040': '{}/data/transportpce-service-path:service-path-list/{}={}?content=nonconfig',
-           'lighty': '{}/data/transportpce-service-path:service-path-list/{}={}?content=nonconfig',
            'draft-bierman02': '{}/operational/transportpce-service-path:service-path-list/{}/{}'}
     response = get_request(url[RESTCONF_VERSION].format('{}', attribute, value))
     res = response.json()
     return_key = {'rfc8040': 'transportpce-service-path:' + attribute,
-                  'lighty': 'transportpce-service-path:' + attribute,
                   'draft-bierman02': attribute}
     if return_key[RESTCONF_VERSION] in res.keys():
         response_attribute = res[return_key[RESTCONF_VERSION]]
@@ -664,7 +634,6 @@ def transportpce_api_rpc_request(api_module: str, rpc: str, payload: dict):
     else:
         res = response.json()
         return_key = {'rfc8040': api_module + ':output',
-                      'lighty': api_module + ':output',
                       'draft-bierman02': 'output'}
         if response.status_code == requests.codes.internal_server_error:
             return_output = res
index 571549fb0c98f8249c7b50489789fa85a9cba4a0..b9537caf5da703a461974b1cc434a95dcf48374f 100644 (file)
@@ -295,8 +295,6 @@ class TransportNbiNotificationstesting(unittest.TestCase):
                              response['output']['service']['end-point'][0]['name'][0])
         self.assertDictEqual(dict(input_dict_3, **response['output']['service']['end-point'][1]['name'][0]),
                              response['output']['service']['end-point'][1]['name'][0])
-        # If the gate fails is because of the waiting time not being enough
-        time.sleep(self.WAITING)
 
     def test_12_get_service_Ethernet(self):
         response = test_utils.get_ordm_serv_list_attr_request("services", str(self.uuid_services.eth))
@@ -382,10 +380,10 @@ class TransportNbiNotificationstesting(unittest.TestCase):
         response = test_utils.transportpce_api_rpc_request(
             'tapi-notification', 'get-notification-list', self.cr_get_notif_list_input_data)
         self.assertEqual(response['status_code'], requests.codes.ok)
-        self.assertEqual(response['output']['notification'][1]['target-object-identifier'], str(self.uuid_services.eth))
-        self.assertEqual(response['output']['notification'][1]['target-object-type'], 'CONNECTIVITY_SERVICE')
-        self.assertEqual(response['output']['notification'][1]['changed-attributes'][0]['new-value'], 'UNLOCKED')
-        self.assertEqual(response['output']['notification'][1]['changed-attributes'][1]['new-value'], 'ENABLED')
+        self.assertEqual(response['output']['notification'][0]['target-object-identifier'], str(self.uuid_services.eth))
+        self.assertEqual(response['output']['notification'][0]['target-object-type'], 'CONNECTIVITY_SERVICE')
+        self.assertEqual(response['output']['notification'][0]['changed-attributes'][0]['new-value'], 'UNLOCKED')
+        self.assertEqual(response['output']['notification'][0]['changed-attributes'][1]['new-value'], 'ENABLED')
         time.sleep(2)
 
     def test_19_delete_connectivity_service_Ethernet(self):
diff --git a/tox.ini b/tox.ini
index c8d378db8fdd63ca289e9f71a87472946cebd585..7b18494cec9e6de424b8cf2f586bf5e14005e8aa 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -60,7 +60,7 @@ depends = buildcontroller
 setenv =
     PIP_EXTRA_INDEX_URL = https://gitlab.com/api/v4/projects/33090323/packages/pypi/simple
     USE_LIGHTY=True
-    USE_ODL_RESTCONF_VERSION=lighty
+#    USE_ODL_RESTCONF_VERSION=draft-bierman02
 deps =
   -r{toxinidir}/tests/requirements.txt
   -r{toxinidir}/tests/test-requirements.txt
@@ -91,7 +91,7 @@ whitelist_externals = launch_tests.sh
 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
 setenv =
     USE_LIGHTY=True
-    USE_ODL_RESTCONF_VERSION=lighty
+#    USE_ODL_RESTCONF_VERSION=draft-bierman02
     USE_ODL_ALT_KARAF_ENV=./karaf121.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
 commands =
@@ -124,7 +124,7 @@ whitelist_externals = launch_tests.sh
 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
 setenv =
     USE_LIGHTY=True
-    USE_ODL_RESTCONF_VERSION=lighty
+#    USE_ODL_RESTCONF_VERSION=draft-bierman02
     USE_ODL_ALT_KARAF_ENV=./karaf221.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
 commands =
@@ -148,7 +148,7 @@ whitelist_externals = launch_tests.sh
 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
 setenv =
     USE_LIGHTY=True
-    USE_ODL_RESTCONF_VERSION=lighty
+#    USE_ODL_RESTCONF_VERSION=draft-bierman02
     USE_ODL_ALT_KARAF_ENV=./karaf71.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
 commands =
@@ -172,7 +172,7 @@ whitelist_externals = launch_tests.sh
 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
 setenv =
     USE_LIGHTY=True
-    USE_ODL_RESTCONF_VERSION=lighty
+#    USE_ODL_RESTCONF_VERSION=draft-bierman02
     USE_ODL_ALT_KARAF_ENV=./karaf121.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
 commands =
@@ -185,7 +185,7 @@ whitelist_externals = launch_tests.sh
 passenv = LAUNCHER USE_LIGHTY OLM_TIMER1 OLM_TIMER2 USE_ODL_RESTCONF_VERSION
 setenv =
     USE_LIGHTY=True
-    USE_ODL_RESTCONF_VERSION=lighty
+#    USE_ODL_RESTCONF_VERSION=draft-bierman02
     USE_ODL_ALT_KARAF_ENV=./karaf221.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
     INSTALL_TAPI=True
@@ -205,7 +205,7 @@ setenv =
     OLM_TIMER2=2000
     INSTALL_TAPI=True
     INSTALL_NBINOTIFICATIONS=True
-    USE_ODL_RESTCONF_VERSION=lighty
+#    USE_ODL_RESTCONF_VERSION=draft-bierman02
 
 commands =
   ./dockercmd.sh run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 --name tpce_kafka1 teivah/kafka:2.0.0