X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=networkmodel%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnetworkmodel%2Futil%2FOpenRoadmOtnTopologyTest.java;h=fae5e6828f7dfffd5288811e043bcb9d27c1da0e;hb=b0715d1ebf9280df4e39de69d4bc3bc3164267b6;hp=0f75a6f5d79fb83c56599a638de5291d353e51e5;hpb=68d00560b21cafc8c1438bdbcde09eeb477c436f;p=transportpce.git diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopologyTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopologyTest.java index 0f75a6f5d..fae5e6828 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopologyTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopologyTest.java @@ -7,64 +7,74 @@ */ package org.opendaylight.transportpce.networkmodel.util; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.either; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.google.gson.stream.JsonReader; import java.io.FileReader; import java.io.IOException; import java.io.Reader; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.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.rev200827.Network; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.Nodes; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.NodesBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.Mapping; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.MappingBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.NodeInfoBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Node1; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev181130.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmNodeType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmTpType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU2e; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU4; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Link1; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.networks.network.node.SwitchingPools; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If100GE; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If100GEODU4; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If10GEODU2e; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.IfOCHOTU4ODU4; -import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.OtnLinkType; -import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.TerminationPoint1; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.OtnLinkType; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.MappingBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.MappingKey; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.NodesBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.nodes.NodeInfoBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1; +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.rev230526.xpdr.odu.switching.pools.OduSwitchingPools; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmLinkType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmTpType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapability; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU2; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU2e; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU4; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Link1; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.networks.network.node.SwitchingPools; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If100GE; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If100GEODU4; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If10GE; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If10GEODU2; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If10GEODU2e; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.IfOCH; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.IfOCHOTU4ODU4; 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; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint; -import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public class OpenRoadmOtnTopologyTest { private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnTopologyTest.class); @@ -73,19 +83,20 @@ public class OpenRoadmOtnTopologyTest { private Nodes portMappingBad; public OpenRoadmOtnTopologyTest() { - try (Reader reader = new FileReader("src/test/resources/portMapping.json"); + 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", "2020-08-27", "network")); - for (Nodes nodes : portMapping.getNodes()) { + Network portMapping = (Network) JsonUtil.getInstance() + .getDataObjectFromJson(portMappingReader, Network.QNAME); + for (Nodes nodes : portMapping.nonnullNodes().values()) { if (nodes.getNodeId().equals("XPDR-A1")) { this.portMappingTpdr = nodes; } else { this.portMappingSpdr = nodes; } } - List mappingList = new ArrayList<>(); - mappingList.add(new MappingBuilder().setLogicalConnectionPoint("XPDR0-NETWORK0").build()); + Map mappingList = new HashMap<>(); + Mapping mapping = new MappingBuilder().setLogicalConnectionPoint("XPDR0-NETWORK0").build(); + mappingList.put(mapping.key(),mapping); this.portMappingBad = new NodesBuilder() .setNodeId(this.portMappingTpdr.getNodeId()) .setNodeInfo(new NodeInfoBuilder(this.portMappingTpdr.getNodeInfo()).setNodeType(NodeTypes.Ila).build()) @@ -101,113 +112,87 @@ public class OpenRoadmOtnTopologyTest { } @Test - public void createTopologyShardForTpdrTest() { + void createTopologyShardForTpdrTest() { TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr); - assertNotNull("TopologyShard should never be null", topologyShard); - assertEquals("Should contain a single node", 1, topologyShard.getNodes().size()); - assertEquals("Should contain no link", 0, topologyShard.getLinks().size()); + assertNotNull(topologyShard, "TopologyShard should never be null"); + assertEquals(1, topologyShard.getNodes().size(), "Should contain a single node"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain no link"); Node node = topologyShard.getNodes().get(0); assertEquals("XPDR-A1-XPDR1", node.getNodeId().getValue()); // tests supporting nodes - List supportingNodes = node.getSupportingNode().stream() + List supportingNodes = node.nonnullSupportingNode().values().stream() .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue())) .collect(Collectors.toList()); - assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size()); - assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue()); - assertEquals("NodeA", supportingNodes.get(0).getNodeRef().getValue()); - assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue()); - assertEquals("XPDR-A1", supportingNodes.get(1).getNodeRef().getValue()); - assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue()); - assertEquals("XPDR-A1-XPDR1", supportingNodes.get(2).getNodeRef().getValue()); + assertEquals(3, supportingNodes.size(),"Should contain 3 supporting nodes"); + assertEquals(supportingNodes.get(0).getNetworkRef().getValue(), "clli-network"); + assertEquals(supportingNodes.get(0).getNodeRef().getValue(), "NodeA"); + assertEquals(supportingNodes.get(1).getNetworkRef().getValue(), "openroadm-network"); + assertEquals(supportingNodes.get(1).getNodeRef().getValue(), "XPDR-A1"); + assertEquals(supportingNodes.get(2).getNetworkRef().getValue(), "openroadm-topology"); + assertEquals(supportingNodes.get(2).getNodeRef().getValue(), "XPDR-A1-XPDR1"); assertEquals(OpenroadmNodeType.TPDR, node.augmentation(Node1.class).getNodeType()); assertEquals( Uint16.valueOf(1), node.augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class) - .getXpdrAttributes() - .getXpdrNumber()); + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Node1.class) + .getXpdrAttributes().getXpdrNumber()); //tests list of TPs List tps = node.augmentation( org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) - .getTerminationPoint().stream() - .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue())) - .collect(Collectors.toList()); - assertEquals("node should contain 4 TPs", 4, tps.size()); + .nonnullTerminationPoint().values().stream() + .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue())) + .collect(Collectors.toList()); + assertEquals(4, tps.size(), "node should contain 4 TPs"); //tests client tp assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue()); assertEquals( "XPDR1-NETWORK1", - tps.get(0).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort()); - assertEquals( - "only If100GE interface capabitily expected", - 1, tps.get(0).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability() - .size()); + TerminationPoint1.class).getAssociatedConnectionMapTp().iterator().next().getValue()); assertEquals( - If100GE.class.getName(), - tps.get(0).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + 1, + tps.get(0).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getTpSupportedInterfaces().getSupportedInterfaceCapability() - .get(0).getIfCapType().getName()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().size(), + "only If100GE interface capabitily expected"); assertEquals( - "first TP must be of type client", - OpenroadmTpType.XPONDERCLIENT, - tps.get(0).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130 + If100GE.VALUE, + tps.get(0).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getTpType()); + .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability().values().stream().findFirst() + .orElseThrow().getIfCapType()); + assertEquals(OpenroadmTpType.XPONDERCLIENT,tps.get(0).augmentation(TerminationPoint1.class).getTpType(), + "first TP must be of type client"); //tests network tp assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue()); + assertEquals("XPDR1-CLIENT1", tps.get(2).augmentation(TerminationPoint1.class) + .getAssociatedConnectionMapTp().iterator().next().getValue()); assertEquals( - "XPDR1-CLIENT1", - tps.get(2).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort()); - assertEquals( - "only IfOCHOTU4ODU4 interface capabitily expected", 1, - tps.get(2).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability() - .size()); - assertEquals( - IfOCHOTU4ODU4.class.getName(), - tps.get(2).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability() - .get(0) - .getIfCapType() - .getName()); - assertEquals( - "the rate should be ODU4", - ODU4.class.getName(), - tps.get(2).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getRate() - .getName()); - assertEquals( - "third TP must be of type network", - OpenroadmTpType.XPONDERNETWORK, - tps.get(2).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.TerminationPoint1.class) - .getTpType()); + tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().size()); + assertEquals( + IfOCH.VALUE, + tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst() + .orElseThrow().getIfCapType()); + assertNull( + tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getRate(), + "the rate should be null"); + assertEquals(OpenroadmTpType.XPONDERNETWORK,tps.get(2).augmentation(TerminationPoint1.class).getTpType(), + "third TP must be of type network"); } @Test - public void createTopologyShardForSpdrTest() { + void createTopologyShardForSpdrTest() { TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr); - assertNotNull("TopologyShard should never be null", topologyShard); - assertEquals("Should contain two nodes", 2, topologyShard.getNodes().size()); - assertEquals("Should contain no link", 0, topologyShard.getLinks().size()); + assertNotNull(topologyShard, "TopologyShard should never be null"); + assertEquals(2, topologyShard.getNodes().size(), "Should contain two nodes"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain no link"); List nodes = topologyShard.getNodes().stream() .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue())) .collect(Collectors.toList()); @@ -217,519 +202,457 @@ public class OpenRoadmOtnTopologyTest { } @Test - public void createOtnLinksForOTU4NormalTest() { + void createOtnLinksForOTU4NormalTest() { String nodeA = "SPDRA"; String tpA = "XPDR1-NETWORK1"; String nodeZ = "SPDRZ"; String tpZ = "XPDR1-NETWORK1"; List links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks(); - assertEquals("2 OTU4 links should have been created", 2, links.size()); + assertEquals(2, links.size(), "2 OTU4 links should have been created"); List sortedLinks = links.stream() .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue())) .collect(Collectors.toList()); assertEquals( - "name of OTU4 linkid AZ", "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1", - sortedLinks.get(0).getLinkId().getValue()); + sortedLinks.get(0).getLinkId().getValue(), + "name of OTU4 linkid AZ"); assertEquals( - "name of OTU4 linkid ZA", "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1", - sortedLinks.get(1).getLinkId().getValue()); + sortedLinks.get(1).getLinkId().getValue(), + "name of OTU4 linkid ZA"); assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue()); assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue()); assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue()); assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue()); assertEquals( - "available BW at OTU4 creation should be 100G (100000)", Uint32.valueOf(100000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "available BW at OTU4 creation should be 100G (100000)"); assertEquals( - "used BW at OTU4 creation should be 0", Uint32.valueOf(0), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "used BW at OTU4 creation should be 0"); assertEquals( OpenroadmLinkType.OTNLINK, sortedLinks.get(0).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class) + org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1.class) .getLinkType()); assertEquals( - "opposite link must be present", "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1", sortedLinks.get(0).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class) - .getOppositeLink() - .getValue()); + org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1.class) + .getOppositeLink().getValue(), + "opposite link must be present"); assertEquals( - "otn link type should be OTU4", OtnLinkType.OTU4, sortedLinks.get(0).augmentation( - org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class) - .getOtnLinkType()); + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.Link1.class) + .getOtnLinkType(), + "otn link type should be OTU4"); } @Test - public void createOtnLinksForNotManagedOtnlinktypeTest() { + void createOtnLinksForNotManagedOtnlinktypeTest() { String nodeA = "SPDRA"; String tpA = "XPDR1-NETWORK1"; String nodeZ = "SPDRZ"; String tpZ = "XPDR1-NETWORK1"; TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("TopologyShard should not contain any node", topoShard.getNodes()); - assertNull("TopologyShard should not contain any link", topoShard.getLinks()); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "TopologyShard should not contain any node"); + assertNull(topoShard.getLinks(), "TopologyShard should not contain any link"); } @Test - public void createOtnLinksForODU4NormalTest() { + void createOtnLinksForODU4NormalTest() { TopologyShard topoShard = OpenRoadmOtnTopology .createOtnLinks( - NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000), - NetworkmodelTestUtil.createTpList(false)); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); + NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(100000)), + NetworkmodelTestUtil.createTpList(false), OtnLinkType.ODTU4); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); List sortedLinks = topoShard.getLinks().stream() .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue())) .collect(Collectors.toList()); - assertEquals("list of links should contain 4 links", 4, sortedLinks.size()); - assertTrue("link 3 should be of type OTU4", sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-")); + assertEquals(4, sortedLinks.size(), "list of links should contain 4 links"); + assertTrue(sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"), "link 3 should be of type OTU4"); assertEquals( - "after odu4 creation, available BW of supported OTU4 should be 0", Uint32.valueOf(0), - sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth(), + "after odu4 creation, available BW of supported OTU4 should be 0"); assertEquals( - "after odu4 creation, used BW of supported OTU4 should be 100 000", Uint32.valueOf(100000), - sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth()); - + sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth(), + "after odu4 creation, used BW of supported OTU4 should be 100 000"); 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()); assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue()); assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue()); assertEquals( - "after odu4 creation, its available BW should be 100 000", Uint32.valueOf(100000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after odu4 creation, its available BW should be 100 000"); assertEquals( - "after odu4 creation, its used BW should be 0", Uint32.valueOf(0), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after odu4 creation, its used BW should be 0"); assertEquals( OpenroadmLinkType.OTNLINK, - sortedLinks.get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class) + sortedLinks.get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1.class) .getLinkType()); assertEquals( - "opposite link must be present", - "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1", - sortedLinks.get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class) - .getOppositeLink() - .getValue()); + "ODTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1", + sortedLinks.get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1.class) + .getOppositeLink().getValue(), + "opposite link must be present"); assertEquals( - "otn link type should be ODTU4", OtnLinkType.ODTU4, - sortedLinks.get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class) - .getOtnLinkType()); + sortedLinks.get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.Link1.class) + .getOtnLinkType(), + "otn link type should be ODTU4"); - assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size()); + assertEquals(2, topoShard.getTps().size(), "list of TPs should contain 2 updated TPs"); assertNotNull( - "after ODU4 creation, its termination point should contain a TsPool list", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool()); + .getXpdrTpPortConnectionAttributes().getTsPool(), + "after ODU4 creation, its termination point should contain a TsPool list"); assertEquals( - "Ts pool list should be full, with 80 trib slots", 80, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "Ts pool list should be full, with 80 trib slots"); assertNotNull( - "after ODU4 creation, its termination point should contain a TpnPool list", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) - .getTpnPool()); + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() + .getTpnPool(), + "after ODU4 creation, its termination point should contain a TpnPool list"); assertEquals( - "Tpn pool list should be full, with 80 trib ports", 80, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) - .getTpnPool() - .size()); + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() + .getTpnPool().size(), + "Tpn pool list should be full, with 80 trib ports"); } @Test - public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() { - List otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000); + void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() { + List otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(100000)); List otu4LinksWithBadBWParam = new ArrayList<>(); for (Link link : otu4Links) { otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build()); } - TopologyShard topoShard = - OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(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()); - assertNull("list of tps should be null", topoShard.getTps()); + TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks( + otu4LinksWithBadBWParam, + NetworkmodelTestUtil.createTpList(false), + OtnLinkType.OTU4); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); otu4LinksWithBadBWParam.clear(); - topoShard = - OpenRoadmOtnTopology.createOtnLinks( - NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 99000), - NetworkmodelTestUtil.createTpList(false)); - 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()); + topoShard = OpenRoadmOtnTopology.createOtnLinks( + NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(99000)), + NetworkmodelTestUtil.createTpList(false), + OtnLinkType.OTU4); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); } @Test - public void deleteOtnLinksForODU4NormalTest() { - TopologyShard topoShard = - OpenRoadmOtnTopology.deleteOtnLinks( - NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0), - NetworkmodelTestUtil.createTpList(true)); - assertNotNull("TopologyShard should never be null", topoShard); - assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size()); + void deleteOtnLinksForODU4NormalTest() { + TopologyShard topoShard = OpenRoadmOtnTopology.deleteOtnLinks( + NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(0)), + NetworkmodelTestUtil.createTpList(true), + OtnLinkType.OTU4); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertEquals(2, topoShard.getLinks().size(), "list of links should contain 2 links"); assertEquals( - "after ODU4 deletion, available BW of supported OTU4 should be 100 000", Uint32.valueOf(100000), - topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth()); + topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after ODU4 deletion, available BW of supported OTU4 should be 100 000"); assertEquals( - "after ODU4 deletion, used BW of supported OTU4 should be 0", Uint32.valueOf(0), - topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth()); + topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth(), + "after ODU4 deletion, used BW of supported OTU4 should be 0"); - assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size()); + assertEquals(2, topoShard.getTps().size(), "list of TPs should contain 2 updated TPs"); assertNull( - "after ODU4 deletion, its termination points should not contain any TsPool list", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool()); + .getXpdrTpPortConnectionAttributes().getTsPool(), + "after ODU4 deletion, its termination points should not contain any TsPool list"); assertNull( - "after ODU4 deletion, its termination points should not contain any TpnPool list", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool()); + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool(), + "after ODU4 deletion, its termination points should not contain any TpnPool list"); } @Test - public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() { - List otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0); + void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() { + List otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(0)); List otu4LinksWithBadBWParam = new ArrayList<>(); for (Link link : otu4Links) { otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build()); } - TopologyShard topoShard = - OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true)); - 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()); - assertNull("list of tps should be null", topoShard.getTps()); + TopologyShard topoShard = OpenRoadmOtnTopology.deleteOtnLinks( + otu4LinksWithBadBWParam, + NetworkmodelTestUtil.createTpList(true), + OtnLinkType.OTU4); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); } @Test - public void updateOtnLinksFor10GTest() { + void updateOtnLinksFor10GTest() { // tests update for 10G creation - TopologyShard topoShard = - OpenRoadmOtnTopology.updateOtnLinks( - NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000), + TopologyShard topoShard = OpenRoadmOtnTopology.updateOtnLinks( + NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)), NetworkmodelTestUtil.createTpList(true), - "10G", (short)1, (short)1, false); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); + Uint32.valueOf(10), (short)1, (short)1, (short)8, false); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); List 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-")); + assertEquals(2, sortedLinks.size(), "list of links should contain 2 links"); + assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-")); assertEquals( - "after 10G creation, available BW of supported ODU4 should be 90000", Uint32.valueOf(90000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after 10G creation, available BW of supported ODU4 should be 90000"); assertEquals( - "after 10G creation, used BW of supported ODU4 should be 10000", Uint32.valueOf(10000), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after 10G creation, used BW of supported ODU4 should be 10000"); assertEquals( - "after 10G creation, 8 (over 80) trib slot should be occupied", 72, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "after 10G creation, 8 (over 80) trib slot should be occupied"); assertThat( "trib slot 1-8 should no longer be present in Trib slot list", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + .getXpdrTpPortConnectionAttributes().getTsPool(), not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8)))); assertThat( "trib slot 9 should always be present in trib slot list", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + .getXpdrTpPortConnectionAttributes().getTsPool(), hasItem(Uint16.valueOf(9))); assertEquals( - "after 10G creation, 1 (over 80) trib port should be occupied", 79, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) - .getTpnPool() - .size()); + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() + .getTpnPool().size(), + "after 10G creation, 1 (over 80) trib port should be occupied"); assertThat( "trib port 1 should no longer be present", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() .getTpnPool(), not(hasItem(Uint16.valueOf(1)))); // 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-")); + assertEquals(2, sortedLinks.size(), "list of links should contain 2 links"); + assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-")); assertEquals( - "after 10G deletion, available BW of supported ODU4 should be 100 000", Uint32.valueOf(100000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after 10G deletion, available BW of supported ODU4 should be 100 000"); assertEquals( - "after 10G deletion, used BW of supported ODU4 should be 0", Uint32.valueOf(0), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after 10G deletion, used BW of supported ODU4 should be 0"); assertEquals( - "after 10G deletion, trib slot list should be full", 80, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "after 10G deletion, trib slot list should be full"); assertThat( "after 10G deletion, trib slot list should contain items 1-8", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + .getXpdrTpPortConnectionAttributes().getTsPool(), hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9))); assertEquals( - "after 10G deletion, trib port list should be full", 80, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) - .getTpnPool() - .size()); + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() + .getTpnPool().size(), + "after 10G deletion, trib port list should be full"); assertThat( "after 10G deletion, trib port list should contain items 1", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() .getTpnPool(), hasItem(Uint16.valueOf(1))); } @Test - public void updateOtnLinksFor1GCreationTest() { + void updateOtnLinksFor1GCreationTest() { // tests update for 1G creation - TopologyShard topoShard = - OpenRoadmOtnTopology.updateOtnLinks( - NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000), + TopologyShard topoShard = OpenRoadmOtnTopology.updateOtnLinks( + NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)), NetworkmodelTestUtil.createTpList(true), - "1G", (short)1, (short)1, false); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); + Uint32.valueOf(1), (short)1, (short)1, (short)1, false); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); List 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-")); + assertEquals(2, sortedLinks.size(), "list of links should contain 2 links"); + assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-")); assertEquals( - "after 1G creation, available BW of supported ODU4 should be 99000", Uint32.valueOf(99000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after 1G creation, available BW of supported ODU4 should be 99000"); assertEquals( - "after 1G creation, used BW of supported ODU4 should be 1000", Uint32.valueOf(1000), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after 1G creation, used BW of supported ODU4 should be 1000"); assertEquals( - "after 1G creation, 1 (over 80) trib slot should be occupied", 79, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "after 1G creation, 1 (over 80) trib slot should be occupied"); assertThat( "trib slot 1 should no longer be present in Trib slot list", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + .getXpdrTpPortConnectionAttributes().getTsPool(), not(hasItem(Uint16.valueOf(1)))); assertThat( "trib slot 2 should always be present in Trib slot list", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) .getXpdrTpPortConnectionAttributes().getTsPool(), hasItem(Uint16.valueOf(2))); assertEquals( - "after 1G creation, 1 (over 80) trib port should be occupied", 79, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) - .getTpnPool() - .size()); + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() + .getTpnPool().size(), + "after 1G creation, 1 (over 80) trib port should be occupied"); assertThat( "trib port 1 should no longer be present in Trib port list", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() .getTpnPool(), not(hasItem(Uint16.valueOf(1)))); // tests update for 1G deletion sortedLinks.clear(); - topoShard = - OpenRoadmOtnTopology.updateOtnLinks( + topoShard = 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-")); + assertEquals(2, sortedLinks.size(), "list of links should contain 2 links"); + assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-")); assertEquals( - "after 1G deletion, available BW of supported ODU4 should be 100 000", Uint32.valueOf(100000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after 1G deletion, available BW of supported ODU4 should be 100 000"); assertEquals( - "after 1G deletion, used BW of supported ODU4 should be 0", Uint32.valueOf(0), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after 1G deletion, used BW of supported ODU4 should be 0"); assertEquals( - "after 1G deletion, trib slot list should be full", 80, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "after 1G deletion, trib slot list should be full"); assertThat( "after 1G deletion, trib slot list should contain items 1 and 2", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getTsPool(), hasItems(Uint16.valueOf(1), Uint16.valueOf(2))); assertEquals( - "after 1G deletion, trib port list should be full", 80, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) - .getTpnPool() - .size()); + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() + .getTpnPool().size(), + "after 1G deletion, trib port list should be full"); assertThat( "after 1G deletion, trib port list should contain items 1", - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow() .getTpnPool(), hasItem(Uint16.valueOf(1))); } @Test - public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() { - List odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000); + void updateOtnLinksForODU4WhenBWParamsNotPresentTest() { + List odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)); List odu4LinksWithBadBWParam = new ArrayList<>(); for (Link link : odu4Links) { odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build()); @@ -738,30 +661,31 @@ public class OpenRoadmOtnTopologyTest { OpenRoadmOtnTopology.updateOtnLinks( odu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true), - "1G", (short)1, (short)1, 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()); - assertNull("list of tps should be null", topoShard.getTps()); + Uint32.valueOf(1), (short)1, (short)1, (short)10, false); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); } @Test - public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() { - List odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 8000); - TopologyShard topoShard = - OpenRoadmOtnTopology.updateOtnLinks( + void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() { + List odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks( + OtnLinkType.ODTU4, + Uint32.valueOf(8000)); + TopologyShard topoShard = OpenRoadmOtnTopology.updateOtnLinks( odu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true), - "10G", (short)1, (short)1, 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()); - assertNull("list of tps should be null", topoShard.getTps()); + Uint32.valueOf(10), (short)1, (short)1, (short)10, false); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); } private void checkSpdrNode(Node node) { - Uint16 xpdrNb = node - .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class) + Uint16 xpdrNb = node.augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Node1.class) .getXpdrAttributes().getXpdrNumber(); assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue()); if (xpdrNb.equals(Uint16.valueOf(1))) { @@ -770,10 +694,10 @@ public class OpenRoadmOtnTopologyTest { assertEquals(OpenroadmNodeType.SWITCH, node.augmentation(Node1.class).getNodeType()); } // tests supporting nodes - List supportingNodes = node.getSupportingNode().stream() + List supportingNodes = node.nonnullSupportingNode().values().stream() .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue())) .collect(Collectors.toList()); - assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size()); + assertEquals(3, supportingNodes.size(), "Should contain 3 supporting nodes"); assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue()); assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue()); assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue()); @@ -783,45 +707,44 @@ public class OpenRoadmOtnTopologyTest { checkSpdrSwitchingPools( xpdrNb, node.augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class) + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Node1.class) .getSwitchingPools()); List tpList = node.augmentation( org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) - .getTerminationPoint().stream() + .nonnullTerminationPoint().values().stream() .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue())) .collect(Collectors.toList()); checkSpdrTpList(xpdrNb, tpList); } private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) { + List oduSwitchingPools = new ArrayList<>(sp.nonnullOduSwitchingPools().values()); assertEquals( - "switching-pools augmentation should contain a single odu-switching-pools", 1, - sp.getOduSwitchingPools().size()); + oduSwitchingPools.size(), + "switching-pools augmentation should contain a single odu-switching-pools"); assertEquals( - "switching-pool-number should be 1", Uint16.valueOf(1), - sp.getOduSwitchingPools().get(0).getSwitchingPoolNumber()); + oduSwitchingPools.get(0).getSwitchingPoolNumber(), + "switching-pool-number should be 1"); assertEquals( - "switching-pool-type should be non-blocking", "non-blocking", - sp.getOduSwitchingPools().get(0).getSwitchingPoolType().getName()); + oduSwitchingPools.get(0).getSwitchingPoolType().getName(), + "switching-pool-type should be non-blocking"); + + List nonBlockingList = + new ArrayList<>(oduSwitchingPools.get(0).nonnullNonBlockingList().values()); if (xpdrNb.equals(Uint16.valueOf(1))) { - assertEquals( - "Mux should contain 4 non blocking list", - 4, - sp.getOduSwitchingPools().get(0).getNonBlockingList().size()); - assertEquals( - Uint16.valueOf(1), - sp.getOduSwitchingPools().get(0).getNonBlockingList().get(0).getNblNumber()); - List nblList = sp.getOduSwitchingPools().get(0).getNonBlockingList().stream() + assertEquals(4, nonBlockingList.size(), "Mux should contain 4 non blocking list"); + assertEquals(Uint16.valueOf(1), nonBlockingList.get(0).getNblNumber()); + List nblList = oduSwitchingPools.get(0).nonnullNonBlockingList().values().stream() .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber())) .collect(Collectors.toList()); for (NonBlockingList nbl : nblList) { assertEquals( - "for a 10G mux, interconnect BW should be 10G", Uint32.valueOf(10), - nbl.getAvailableInterconnectBandwidth()); + nbl.getAvailableInterconnectBandwidth(), + "for a 10G mux, interconnect BW should be 10G"); assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit()); assertThat( "for a 10G mux, non blocking list should contain 2 entries (client + network ports)", @@ -830,23 +753,17 @@ public class OpenRoadmOtnTopologyTest { String nb = nbl.getNblNumber().toString(); assertThat( nbl.getTpList(), - containsInAnyOrder(new TpId("XPDR1-NETWORK1"), - new TpId("XPDR1-CLIENT" + nb))); + containsInAnyOrder(new TpId("XPDR1-NETWORK1"), new TpId("XPDR1-CLIENT" + nb))); } } else if (xpdrNb.equals(Uint16.valueOf(2))) { - assertEquals( - "Switch should contain a single non blocking list", - 1, - sp.getOduSwitchingPools().get(0).getNonBlockingList().size()); - assertEquals( - Uint16.valueOf(1), - sp.getOduSwitchingPools().get(0).getNonBlockingList().get(0).getNblNumber()); + assertEquals(1, nonBlockingList.size(), "Switch should contain a single non blocking list"); + assertEquals(Uint16.valueOf(1), nonBlockingList.get(0).getNblNumber()); assertThat( "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)", - sp.getOduSwitchingPools().get(0).getNonBlockingList().get(0).getTpList(), + nonBlockingList.get(0).getTpList(), hasSize(8)); assertThat( - sp.getOduSwitchingPools().get(0).getNonBlockingList().get(0).getTpList(), + nonBlockingList.get(0).getTpList(), containsInAnyOrder( new TpId("XPDR2-CLIENT1"), new TpId("XPDR2-NETWORK1"), new TpId("XPDR2-CLIENT2"), new TpId("XPDR2-NETWORK2"), new TpId("XPDR2-CLIENT3"), new TpId("XPDR2-NETWORK3"), @@ -855,113 +772,132 @@ public class OpenRoadmOtnTopologyTest { } private void checkSpdrTpList(Uint16 xpdrNb, List tpList) { + LOG.info("tpList = {}", tpList); assertEquals( - "only IfOCHOTU4ODU4 interface capabitily expected", - IfOCHOTU4ODU4.class, - tpList.get(4) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + IfOCHOTU4ODU4.VALUE, + tpList.get(4).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().get(0) - .getIfCapType()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst() + .orElseThrow().getIfCapType(), + "only IfOCHOTU4ODU4 interface capabitily expected"); assertEquals( - "the rate should be ODU4", - ODU4.class, - tpList.get(4) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + ODU4.VALUE, + tpList.get(4).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getRate()); + .getXpdrTpPortConnectionAttributes().getRate(), + "the rate should be ODU4"); assertEquals( "openroadm-topology", - tpList.get(4).getSupportingTerminationPoint().get(0).getNetworkRef().getValue()); + tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().orElseThrow().getNetworkRef() + .getValue()); assertEquals( "SPDR-SA1-XPDR" + xpdrNb, - tpList.get(4).getSupportingTerminationPoint().get(0).getNodeRef().getValue()); + tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().orElseThrow().getNodeRef() + .getValue()); assertEquals( "XPDR" + xpdrNb + "-NETWORK1", - tpList.get(4).getSupportingTerminationPoint().get(0).getTpRef()); + tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().orElseThrow().getTpRef() + .getValue()); if (xpdrNb.equals(Uint16.valueOf(1))) { - assertEquals("should contain 5 TPs", 5, tpList.size()); + assertEquals(5, tpList.size(), "should contain 5 TPs"); assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue()); assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue()); assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue()); assertEquals( - "only If10GEODU2e interface capabitily expected", - If10GEODU2e.class, - tpList.get(2) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + 2, + tpList.get(1).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().get(0) - .getIfCapType()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().size(), + "supported interface capability of tp-id XPDR1-CLIENT2 should contain 2 if-cap-type"); assertEquals( - "the rate should be ODU2e", - ODU2e.class, - tpList.get(2) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + 3, + tpList.get(2).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().size(), + "supported interface capability of tp-id XPDR1-CLIENT3 should contain 3 if-cap-type"); + List sicListClient1 = tpList.get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream() + .collect(Collectors.toList()); + for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient1) { + assertThat("tp should have 2 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2", + String.valueOf(supportedInterfaceCapability.getIfCapType()), + either(containsString(String.valueOf(If10GEODU2e.VALUE))) + .or(containsString(String.valueOf(If10GEODU2.VALUE)))); + } + List sicListClient3 = tpList.get(3).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream() + .collect(Collectors.toList()); + for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) { + assertThat("tp should have 3 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2, if-10GE", + String.valueOf(supportedInterfaceCapability.getIfCapType()), + either(containsString(String.valueOf(If10GEODU2e.VALUE))) + .or(containsString(String.valueOf(If10GEODU2.VALUE))) + .or(containsString(String.valueOf(If10GE.VALUE)))); + } + 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.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getRate()); + .getXpdrTpPortConnectionAttributes().getRate()), + either(containsString(String.valueOf(ODU2e.VALUE))) + .or(containsString(String.valueOf(ODU2.VALUE)))); assertEquals( - "TP should be of type client", OpenroadmTpType.XPONDERCLIENT, - tpList.get(2) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130 - .TerminationPoint1.class) - .getTpType()); + tpList.get(2).augmentation(TerminationPoint1.class).getTpType(), + "TP should be of type client"); assertEquals( - "TP should be of type network", OpenroadmTpType.XPONDERNETWORK, - tpList.get(4) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130 - .TerminationPoint1.class) - .getTpType()); + tpList.get(4).augmentation(TerminationPoint1.class).getTpType(), + "TP should be of type network"); } else if (xpdrNb.equals(Uint16.valueOf(2))) { - assertEquals("should contain 8 TPs", 8, tpList.size()); + assertEquals(8, tpList.size(), "should contain 8 TPs"); assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue()); assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue()); assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue()); assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue()); assertEquals( - "only If100GEODU4 interface capabitily expected", - If100GEODU4.class, - tpList.get(2) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 - .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().get(0) - .getIfCapType()); - assertEquals( - "the rate should be ODU4", - ODU4.class, - tpList.get(2) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130 + IfOCHOTU4ODU4.VALUE, + tpList.get(5).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getRate()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst() + .orElseThrow().getIfCapType(), + "only IfOCHOTU4ODU4 interface capabitily expected"); assertEquals( - "TP should be of type client", OpenroadmTpType.XPONDERCLIENT, - tpList.get(2) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130 + 2, + tpList.get(2).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 .TerminationPoint1.class) - .getTpType()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().size(), + "supported interface capability of tp should contain 2 IfCapType"); + List sicListClient3 = tpList.get(2).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526 + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream() + .collect(Collectors.toList()); + for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) { + assertThat( + "tp should have 2 if-cap-type: if-100GE-ODU4, if-100GE", + String.valueOf(supportedInterfaceCapability.getIfCapType()), + either(containsString(String.valueOf(If100GEODU4.VALUE))) + .or(containsString(String.valueOf(If100GE.VALUE)))); + } assertEquals( - "TP should be of type network", OpenroadmTpType.XPONDERNETWORK, - tpList.get(6) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130 - .TerminationPoint1.class) - .getTpType()); + OpenroadmTpType.XPONDERCLIENT, + tpList.get(2).augmentation(TerminationPoint1.class).getTpType(), + "TP should be of type client"); + assertEquals( + OpenroadmTpType.XPONDERNETWORK, + tpList.get(6).augmentation(TerminationPoint1.class).getTpType(), + "TP should be of type network"); } } }