Merge changes Icd0ec3e4,Ied393b60,I117bfce8,Ia8e86650,Id583e292
authorGuillaume Lambert <guillaume.lambert@orange.com>
Mon, 7 Mar 2022 08:05:55 +0000 (08:05 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 7 Mar 2022 08:05:55 +0000 (08:05 +0000)
* changes:
  Clean JUnit tests
  Remove usage of DOMNotificationRouter.create meth
  Remove usage of deprecated initMocks method
  Clean dependency declaration in common module
  Remove usage of SchemaPath from converters

nbinotifications/pom.xml
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java

index 54792eddbe046b1384ae7f4379fec754a6fbed24..4cf525a3aea93200135563214a0a33999579a323 100644 (file)
@@ -22,7 +22,7 @@
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <kafka.version>2.6.0</kafka.version>
+    <kafka.version>3.0.0</kafka.version>
   </properties>
 
   <dependencies>
index 86e33307bda1b2366405c2557a3f47219481f334..4b9e160f585428727d90592833295b15055f8f62 100644 (file)
@@ -37,16 +37,16 @@ public class PublisherTest extends AbstractTest {
 
     @Before
     public void setUp() {
+        converterService = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
+        converterAlarm = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         NotificationServiceSerializer serializerService = new NotificationServiceSerializer();
         NotificationAlarmServiceSerializer serializerAlarm = new NotificationAlarmServiceSerializer();
-        Map<String, Object> properties = Map.of(ConfigConstants.CONVERTER, serializerService);
-        Map<String, Object> propertiesAlarm = Map.of(ConfigConstants.CONVERTER, serializerAlarm);
+        Map<String, Object> properties = Map.of(ConfigConstants.CONVERTER, converterService);
+        Map<String, Object> propertiesAlarm = Map.of(ConfigConstants.CONVERTER, converterAlarm);
         serializerService.configure(properties, false);
         serializerAlarm.configure(propertiesAlarm, false);
         mockProducer = new MockProducer<>(true, new StringSerializer(), serializerService);
         mockAlarmProducer = new MockProducer<>(true, new StringSerializer(), serializerAlarm);
-        converterService = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
-        converterAlarm = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         publisherService = new Publisher<>("test", mockProducer);
         publisherAlarm = new Publisher<>("test", mockAlarmProducer);
     }
index a8483d09567be9e143d5623f8efb32fc473a9680..1b423dec0428e8110eb4fbd5be893ad3bdb27adf 100644 (file)
@@ -74,6 +74,8 @@ public class PceOtnNode implements PceNode {
         StringConstants.SERVICE_TYPE_1GE, "ODU0",
         StringConstants.SERVICE_TYPE_10GE, "ODU2e",
         StringConstants.SERVICE_TYPE_100GE_M, "ODU4");
+    private static final String INTERMEDIATE_MODETYPE = "intermediate";
+    private static final String AZ_MODETYPE = "AZ";
 
     private boolean valid = true;
 
@@ -178,50 +180,33 @@ public class PceOtnNode implements PceNode {
             //TODO many nested structures below, this needs to be reworked
             switch (ocnTp1.getTpType()) {
                 case XPONDERNETWORK:
-                    if (SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)
-                            || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)) {
-                            // TODO verify the capability of network port to support ODU4 CTP interface creation
-                        if (!checkTpForOdtuTermination(ontTp1)) {
-                            LOG.error("TP {} of {} does not allow {} termination creation",
-                                tp.getTpId().getValue(),
-                                node.getNodeId().getValue(),
-                                "ODU4");
-                            continue;
-                        }
-                    } else if (SERVICE_TYPE_ETH_TS_NB_MAP.containsKey(this.otnServiceType)) {
-                        if (!checkOdtuTTPforLoOduCreation(
-                                ontTp1, SERVICE_TYPE_ETH_TS_NB_MAP.get(this.otnServiceType))) {
-                            LOG.error("TP {} of {} does not allow {} termination creation",
-                                tp.getTpId().getValue(),
-                                node.getNodeId().getValue(),
-                                SERVICE_TYPE_ETH_ODU_STRING_MAP.get(this.otnServiceType));
-                            continue;
-                        }
+                    String notCreatedServiceType = xpdrNetTpCreation(ontTp1);
+                    if (notCreatedServiceType == null) {
+                        LOG.info("TP {} of XPONDER {} is validated",
+                            tp.getTpId(),
+                            node.getNodeId().getValue());
+                        this.availableXpdrNWTps.add(tp.getTpId());
                     } else {
                         LOG.error("TP {} of {} does not allow {} termination creation",
                             tp.getTpId().getValue(),
                             node.getNodeId().getValue(),
-                            "any");
-                        continue;
+                            notCreatedServiceType);
                     }
-                    LOG.info("TP {} of XPONDER {} is validated",
-                        tp.getTpId(),
-                        node.getNodeId().getValue());
-                    this.availableXpdrNWTps.add(tp.getTpId());
                     break;
 
                 case XPONDERCLIENT:
-                    if (SERVICE_TYPE_ETH_CLASS_MAP.containsKey(otnServiceType)) {
-                        if (checkClientTp(ontTp1)) {
-                            LOG.info("TP {} of XPONDER {} is validated",
-                                tp.getTpId(),
-                                node.getNodeId().getValue());
-                            this.availableXpdrClientTps.add(tp.getTpId());
-                        } else {
-                            LOG.error("TP {} of {} does not allow lo-ODU (ODU2e or ODU0) termination creation",
-                                tp.getTpId().getValue(),
-                                node.getNodeId().getValue());
-                        }
+                    if (!SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType)) {
+                        continue;
+                    }
+                    if (checkClientTp(ontTp1)) {
+                        LOG.info("TP {} of XPONDER {} is validated",
+                            tp.getTpId(),
+                            node.getNodeId().getValue());
+                        this.availableXpdrClientTps.add(tp.getTpId());
+                    } else {
+                        LOG.error("TP {} of {} does not allow lo-ODU (ODU2e or ODU0) termination creation",
+                            tp.getTpId().getValue(),
+                            node.getNodeId().getValue());
                     }
                     break;
 
@@ -229,13 +214,40 @@ public class PceOtnNode implements PceNode {
                     LOG.debug("unsupported ocn TP type {}", ocnTp1.getTpType());
             }
         }
-        this.valid = SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)
-                || SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType)
-                    && checkSwPool(availableXpdrNWTps, availableXpdrClientTps);
+        this.valid = checkSwPool(availableXpdrNWTps, availableXpdrClientTps);
+    }
+
+    private String xpdrNetTpCreation(TerminationPoint1 ontTp1) {
+        if (SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)
+                || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)) {
+                // TODO verify the capability of network port to support ODU4 CTP interface creation
+            if (checkTpForOdtuTermination(ontTp1)) {
+                //success
+                return null;
+            }
+            return "ODU4";
+        }
+        if (SERVICE_TYPE_ETH_TS_NB_MAP.containsKey(this.otnServiceType)) {
+            if (checkOdtuTTPforLoOduCreation(
+                    ontTp1,
+                    SERVICE_TYPE_ETH_TS_NB_MAP.get(this.otnServiceType))) {
+                //success
+                return null;
+            }
+            return SERVICE_TYPE_ETH_ODU_STRING_MAP.get(this.otnServiceType);
+        }
+        //failure
+        return "any";
     }
 
     private boolean checkSwPool(List<TpId> netwTps, List<TpId> clientTps) {
 
+        if (SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)) {
+            return true;
+        }
+        if (!SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType)) {
+            return false;
+        }
         if (netwTps == null) {
             return false;
         }
@@ -254,10 +266,10 @@ public class PceOtnNode implements PceNode {
 
         switch (modeType) {
 
-            case "intermediate":
+            case INTERMEDIATE_MODETYPE:
                 return checkIntermediateSwPool(nblList, netwTps);
 
-            case "AZ":
+            case AZ_MODETYPE:
                 if (clientTps == null) {
                     return false;
                 }
@@ -342,8 +354,7 @@ public class PceOtnNode implements PceNode {
                 ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values()) {
             LOG.debug("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
             // we could also check the administrative status of the tp
-            if (SERVICE_TYPE_ETH_CLASS_MAP.containsKey(otnServiceType)
-                    && sic.getIfCapType().equals(SERVICE_TYPE_ETH_CLASS_MAP.get(otnServiceType))) {
+            if (sic.getIfCapType().equals(SERVICE_TYPE_ETH_CLASS_MAP.get(otnServiceType))) {
                 return true;
             }
         }
@@ -356,9 +367,9 @@ public class PceOtnNode implements PceNode {
         }
         if (this.nodeId.getValue().equals(anodeId)
                 || (this.nodeId.getValue().equals(znodeId))) {
-            initXndrTps("AZ");
+            initXndrTps(AZ_MODETYPE);
         } else if (OpenroadmNodeType.SWITCH.equals(this.nodeType)) {
-            initXndrTps("intermediate");
+            initXndrTps(INTERMEDIATE_MODETYPE);
         } else {
             LOG.info("validateAZxponder: XPONDER is ignored == {}", nodeId.getValue());
             valid = false;
@@ -397,7 +408,7 @@ public class PceOtnNode implements PceNode {
             return;
         }
         // Validate switch for use as an intermediate XPONDER on the path
-        initXndrTps("intermediate");
+        initXndrTps(INTERMEDIATE_MODETYPE);
         if (this.valid) {
             LOG.info("validateIntermediateSwitch: Switch usable for transit == {}", nodeId.getValue());
         } else {