Fix bug in setting rate of tp in network module
[transportpce.git] / networkmodel / src / test / java / org / opendaylight / transportpce / networkmodel / util / OpenRoadmOtnTopologyTest.java
index c209fbdfb2fade0d4e87fcf6019083f4652f7fce..e6c209a407df109fef7a0e9b871eaff013219785 100644 (file)
@@ -35,13 +35,13 @@ import org.junit.Test;
 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
 import org.opendaylight.transportpce.networkmodel.util.test.JsonUtil;
 import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.mapping.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.mapping.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.mapping.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
@@ -62,8 +62,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
-import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.OtnLinkType;
-import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.TerminationPoint1;
+import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.OtnLinkType;
+import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.TerminationPoint1;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
@@ -87,7 +87,7 @@ public class OpenRoadmOtnTopologyTest {
         try (Reader reader = new FileReader("src/test/resources/portMapping.json", StandardCharsets.UTF_8);
                 JsonReader portMappingReader = new JsonReader(reader)) {
             Network portMapping = (Network) JsonUtil.getInstance().getDataObjectFromJson(portMappingReader,
-                    QName.create("http://org/opendaylight/transportpce/portmapping", "2021-03-15", "network"));
+                    QName.create("http://org/opendaylight/transportpce/portmapping", "2021-04-26", "network"));
             for (Nodes nodes : portMapping.nonnullNodes().values()) {
                 if (nodes.getNodeId().equals("XPDR-A1")) {
                     this.portMappingTpdr = nodes;
@@ -275,7 +275,7 @@ public class OpenRoadmOtnTopologyTest {
             "otn link type should be OTU4",
             OtnLinkType.OTU4,
             sortedLinks.get(0).augmentation(
-                    org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.Link1.class)
+                    org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.Link1.class)
                 .getOtnLinkType());
     }
 
@@ -295,8 +295,8 @@ public class OpenRoadmOtnTopologyTest {
     public void createOtnLinksForODU4NormalTest() {
         TopologyShard topoShard = OpenRoadmOtnTopology
             .createOtnLinks(
-                NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000),
-                NetworkmodelTestUtil.createTpList(false));
+                NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(100000)),
+                NetworkmodelTestUtil.createTpList(false), OtnLinkType.ODTU4);
         assertNotNull("TopologyShard should never be null", topoShard);
         assertNull("list of nodes should be null", topoShard.getNodes());
         List<Link> sortedLinks = topoShard.getLinks().stream()
@@ -314,10 +314,10 @@ public class OpenRoadmOtnTopologyTest {
             sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth());
 
         assertEquals(
-            "ODU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
+            "ODTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
             sortedLinks.get(0).getLinkId().getValue());
         assertEquals(
-            "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
+            "ODTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
             sortedLinks.get(1).getLinkId().getValue());
         assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
         assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
@@ -339,7 +339,7 @@ public class OpenRoadmOtnTopologyTest {
                 .getLinkType());
         assertEquals(
             "opposite link must be present",
-            "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
+            "ODTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
             sortedLinks.get(0)
                 .augmentation(
                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
@@ -350,7 +350,7 @@ public class OpenRoadmOtnTopologyTest {
             OtnLinkType.ODTU4,
             sortedLinks.get(0)
                 .augmentation(
-                    org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.Link1.class)
+                    org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.Link1.class)
                 .getOtnLinkType());
 
         assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
@@ -398,13 +398,14 @@ public class OpenRoadmOtnTopologyTest {
 
     @Test
     public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
-        List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000);
+        List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(100000));
         List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
         for (Link link : otu4Links) {
             otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
         }
         TopologyShard topoShard =
-            OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false));
+            OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false),
+                OtnLinkType.OTU4);
         assertNotNull("TopologyShard should never be null", topoShard);
         assertNull("list of nodes should be null", topoShard.getNodes());
         assertNull("list of links should be null", topoShard.getLinks());
@@ -413,8 +414,8 @@ public class OpenRoadmOtnTopologyTest {
         otu4LinksWithBadBWParam.clear();
         topoShard =
             OpenRoadmOtnTopology.createOtnLinks(
-                    NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 99000),
-                    NetworkmodelTestUtil.createTpList(false));
+                    NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(99000)),
+                    NetworkmodelTestUtil.createTpList(false), OtnLinkType.OTU4);
         assertNull("list of nodes should be null", topoShard.getNodes());
         assertNull("list of links should be null", topoShard.getLinks());
         assertNull("list of tps should be null", topoShard.getTps());
@@ -424,8 +425,8 @@ public class OpenRoadmOtnTopologyTest {
     public void deleteOtnLinksForODU4NormalTest() {
         TopologyShard topoShard =
             OpenRoadmOtnTopology.deleteOtnLinks(
-                    NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0),
-                    NetworkmodelTestUtil.createTpList(true));
+                    NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(0)),
+                    NetworkmodelTestUtil.createTpList(true), OtnLinkType.OTU4);
         assertNotNull("TopologyShard should never be null", topoShard);
         assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size());
         assertEquals(
@@ -458,13 +459,14 @@ public class OpenRoadmOtnTopologyTest {
 
     @Test
     public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
-        List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0);
+        List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(0));
         List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
         for (Link link : otu4Links) {
             otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
         }
         TopologyShard topoShard =
-            OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true));
+            OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true),
+                OtnLinkType.OTU4);
         assertNotNull("TopologyShard should never be null", topoShard);
         assertNull("list of nodes should be null", topoShard.getNodes());
         assertNull("list of links should be null", topoShard.getLinks());
@@ -476,16 +478,16 @@ public class OpenRoadmOtnTopologyTest {
         // tests update for 10G creation
         TopologyShard topoShard =
             OpenRoadmOtnTopology.updateOtnLinks(
-                    NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
+                    NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)),
                     NetworkmodelTestUtil.createTpList(true),
-                    "10G", (short)1, (short)1, false);
+                    Uint32.valueOf(10), (short)1, (short)1, (short)8, false);
         assertNotNull("TopologyShard should never be null", topoShard);
         assertNull("list of nodes should be null", topoShard.getNodes());
         List<Link> sortedLinks = topoShard.getLinks().stream()
             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
             .collect(Collectors.toList());
         assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
-        assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
+        assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-"));
         assertEquals(
             "after 10G creation, available BW of supported ODU4 should be 90000",
             Uint32.valueOf(90000),
@@ -549,13 +551,13 @@ public class OpenRoadmOtnTopologyTest {
 
         // tests update for 10G deletion
         sortedLinks.clear();
-        topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), "10G", (short)1,
-            (short)1, true);
+        topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), Uint32.valueOf(10),
+            (short)1, (short)1, (short)8, true);
         sortedLinks = topoShard.getLinks().stream()
             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
             .collect(Collectors.toList());
         assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
-        assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
+        assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-"));
         assertEquals(
             "after 10G deletion, available BW of supported ODU4 should be 100 000",
             Uint32.valueOf(100000),
@@ -614,16 +616,16 @@ public class OpenRoadmOtnTopologyTest {
         // tests update for 1G creation
         TopologyShard topoShard =
             OpenRoadmOtnTopology.updateOtnLinks(
-                    NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
+                    NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)),
                     NetworkmodelTestUtil.createTpList(true),
-                    "1G", (short)1, (short)1, false);
+                    Uint32.valueOf(1), (short)1, (short)1, (short)1, false);
         assertNotNull("TopologyShard should never be null", topoShard);
         assertNull("list of nodes should be null", topoShard.getNodes());
         List<Link> sortedLinks = topoShard.getLinks().stream()
             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
             .collect(Collectors.toList());
         assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
-        assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
+        assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-"));
         assertEquals(
             "after 1G creation, available BW of supported ODU4 should be 99000",
             Uint32.valueOf(99000),
@@ -690,12 +692,12 @@ public class OpenRoadmOtnTopologyTest {
             OpenRoadmOtnTopology.updateOtnLinks(
                     topoShard.getLinks(),
                     topoShard.getTps(),
-                    "1G", (short)1, (short)1, true);
+                    Uint32.valueOf(1), (short)1, (short)1, (short)1, true);
         sortedLinks = topoShard.getLinks().stream()
             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
             .collect(Collectors.toList());
         assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
-        assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
+        assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-"));
         assertEquals(
             "after 1G deletion, available BW of supported ODU4 should be 100 000",
             Uint32.valueOf(100000),
@@ -751,7 +753,7 @@ public class OpenRoadmOtnTopologyTest {
 
     @Test
     public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() {
-        List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000);
+        List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000));
         List<Link> odu4LinksWithBadBWParam = new ArrayList<>();
         for (Link link : odu4Links) {
             odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
@@ -760,7 +762,7 @@ public class OpenRoadmOtnTopologyTest {
             OpenRoadmOtnTopology.updateOtnLinks(
                     odu4LinksWithBadBWParam,
                     NetworkmodelTestUtil.createTpList(true),
-                    "1G", (short)1, (short)1, false);
+                    Uint32.valueOf(1), (short)1, (short)1, (short)10, false);
         assertNotNull("TopologyShard should never be null", topoShard);
         assertNull("list of nodes should be null", topoShard.getNodes());
         assertNull("list of links should be null", topoShard.getLinks());
@@ -769,12 +771,13 @@ public class OpenRoadmOtnTopologyTest {
 
     @Test
     public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() {
-        List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 8000);
+        List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil
+            .createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(8000));
         TopologyShard topoShard =
             OpenRoadmOtnTopology.updateOtnLinks(
                     odu4LinksWithBadBWParam,
                     NetworkmodelTestUtil.createTpList(true),
-                    "10G", (short)1, (short)1, false);
+                    Uint32.valueOf(10), (short)1, (short)1, (short)10, false);
         assertNotNull("TopologyShard should never be null", topoShard);
         assertNull("list of nodes should be null", topoShard.getNodes());
         assertNull("list of links should be null", topoShard.getLinks());
@@ -913,7 +916,7 @@ public class OpenRoadmOtnTopologyTest {
         assertEquals(
             "XPDR" + xpdrNb + "-NETWORK1",
             tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
-            .get().getTpRef().toString());
+            .get().getTpRef().getValue());
         if (xpdrNb.equals(Uint16.valueOf(1))) {
             assertEquals("should contain 5 TPs", 5, tpList.size());
             assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
@@ -962,7 +965,7 @@ public class OpenRoadmOtnTopologyTest {
                     .or(containsString(String.valueOf(If10GEODU2.class)))
                     .or(containsString(String.valueOf(If10GE.class))));
             }
-            assertThat("the rate should be ODU2 or ODU2e or 10GE",
+            assertThat("the rate should be ODU2 or ODU2e",
                 String.valueOf(tpList.get(2)
                     .augmentation(
                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529