Use version 13.1.0 of openroadm-network models
[transportpce.git] / networkmodel / src / test / java / org / opendaylight / transportpce / networkmodel / util / OpenRoadmOtnTopologyTest.java
1 /*
2  * Copyright © 2020 Orange Labs, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.networkmodel.util;
9
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.CoreMatchers.either;
12 import static org.hamcrest.CoreMatchers.hasItem;
13 import static org.hamcrest.CoreMatchers.hasItems;
14 import static org.hamcrest.CoreMatchers.not;
15 import static org.hamcrest.MatcherAssert.assertThat;
16 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
17 import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
18 import static org.junit.jupiter.api.Assertions.assertEquals;
19 import static org.junit.jupiter.api.Assertions.assertNotNull;
20 import static org.junit.jupiter.api.Assertions.assertNull;
21 import static org.junit.jupiter.api.Assertions.assertTrue;
22 import static org.junit.jupiter.api.Assertions.fail;
23
24 import com.google.gson.stream.JsonReader;
25 import java.io.FileReader;
26 import java.io.IOException;
27 import java.io.Reader;
28 import java.nio.charset.StandardCharsets;
29 import java.util.ArrayList;
30 import java.util.HashMap;
31 import java.util.List;
32 import java.util.Map;
33 import java.util.stream.Collectors;
34 import org.junit.jupiter.api.Test;
35 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
36 import org.opendaylight.transportpce.networkmodel.util.test.JsonUtil;
37 import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.OtnLinkType;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.MappingBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.MappingKey;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes;
44 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.NodesBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.nodes.NodeInfoBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPools;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmLinkType;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmTpType;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU2;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU2e;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU4;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Link1;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.networks.network.node.SwitchingPools;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If100GE;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If100GEODU4;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If10GE;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If10GEODU2;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.If10GEODU2e;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.IfOCH;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.IfOCHOTU4ODU4;
67 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
68 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
69 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
70 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
71 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder;
72 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
73 import org.opendaylight.yangtools.yang.common.Uint16;
74 import org.opendaylight.yangtools.yang.common.Uint32;
75 import org.slf4j.Logger;
76 import org.slf4j.LoggerFactory;
77
78 public class OpenRoadmOtnTopologyTest {
79
80     private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnTopologyTest.class);
81     private Nodes portMappingTpdr;
82     private Nodes portMappingSpdr;
83     private Nodes portMappingBad;
84
85     public OpenRoadmOtnTopologyTest() {
86         try (Reader reader = new FileReader("src/test/resources/portMapping.json", StandardCharsets.UTF_8);
87                 JsonReader portMappingReader = new JsonReader(reader)) {
88             Network portMapping = (Network) JsonUtil.getInstance()
89                 .getDataObjectFromJson(portMappingReader, Network.QNAME);
90             for (Nodes nodes : portMapping.nonnullNodes().values()) {
91                 if (nodes.getNodeId().equals("XPDR-A1")) {
92                     this.portMappingTpdr = nodes;
93                 } else {
94                     this.portMappingSpdr = nodes;
95                 }
96             }
97             Map<MappingKey,Mapping> mappingList = new HashMap<>();
98             Mapping mapping = new MappingBuilder().setLogicalConnectionPoint("XPDR0-NETWORK0").build();
99             mappingList.put(mapping.key(),mapping);
100             this.portMappingBad = new NodesBuilder()
101                 .setNodeId(this.portMappingTpdr.getNodeId())
102                 .setNodeInfo(new NodeInfoBuilder(this.portMappingTpdr.getNodeInfo()).setNodeType(NodeTypes.Ila).build())
103                 .setMapping(mappingList)
104                 .build();
105             LOG.info("tpdr portMapping = {}", this.portMappingTpdr.toString());
106             LOG.info("spdr portMapping = {}", this.portMappingSpdr.toString());
107             LOG.info("ila portMapping = {}", this.portMappingBad.toString());
108         } catch (IOException e) {
109             LOG.error("Cannot init OpenRoadmOtnTopologyTest ", e);
110             fail("Cannot init OpenRoadmOtnTopologyTest ");
111         }
112     }
113
114     @Test
115     void createTopologyShardForTpdrTest() {
116         TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr);
117         assertNotNull(topologyShard, "TopologyShard should never be null");
118         assertEquals(1, topologyShard.getNodes().size(), "Should contain a single node");
119         assertEquals(0, topologyShard.getLinks().size(), "Should contain no link");
120         Node node = topologyShard.getNodes().get(0);
121         assertEquals("XPDR-A1-XPDR1", node.getNodeId().getValue());
122         // tests supporting nodes
123         List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
124             .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
125             .collect(Collectors.toList());
126         assertEquals(3, supportingNodes.size(),"Should contain 3 supporting nodes");
127         assertEquals(supportingNodes.get(0).getNetworkRef().getValue(), "clli-network");
128         assertEquals(supportingNodes.get(0).getNodeRef().getValue(), "NodeA");
129         assertEquals(supportingNodes.get(1).getNetworkRef().getValue(), "openroadm-network");
130         assertEquals(supportingNodes.get(1).getNodeRef().getValue(), "XPDR-A1");
131         assertEquals(supportingNodes.get(2).getNetworkRef().getValue(), "openroadm-topology");
132         assertEquals(supportingNodes.get(2).getNodeRef().getValue(), "XPDR-A1-XPDR1");
133         assertEquals(OpenroadmNodeType.TPDR, node.augmentation(Node1.class).getNodeType());
134         assertEquals(
135             Uint16.valueOf(1),
136             node.augmentation(
137                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Node1.class)
138                     .getXpdrAttributes().getXpdrNumber());
139         //tests list of TPs
140         List<TerminationPoint> tps = node.augmentation(
141                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
142             .nonnullTerminationPoint().values().stream()
143                 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
144                 .collect(Collectors.toList());
145         assertEquals(4, tps.size(), "node should contain 4 TPs");
146         //tests client tp
147         assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue());
148         assertEquals(
149             "XPDR1-NETWORK1",
150             tps.get(0).augmentation(
151                         TerminationPoint1.class).getAssociatedConnectionMapTp().iterator().next().getValue());
152         assertEquals(
153             1,
154             tps.get(0).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
155                         .TerminationPoint1.class)
156                     .getTpSupportedInterfaces().getSupportedInterfaceCapability().size(),
157             "only If100GE interface capabitily expected");
158         assertEquals(
159             If100GE.VALUE,
160             tps.get(0).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
161                         .TerminationPoint1.class)
162                     .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability().values().stream().findFirst()
163                         .orElseThrow().getIfCapType());
164         assertEquals(OpenroadmTpType.XPONDERCLIENT,tps.get(0).augmentation(TerminationPoint1.class).getTpType(),
165             "first TP must be of type client");
166         //tests network tp
167         assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue());
168         assertEquals("XPDR1-CLIENT1", tps.get(2).augmentation(TerminationPoint1.class)
169                     .getAssociatedConnectionMapTp().iterator().next().getValue());
170         assertEquals(
171             1,
172             tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
173                         .TerminationPoint1.class)
174                     .getTpSupportedInterfaces().getSupportedInterfaceCapability().size());
175         assertEquals(
176             IfOCH.VALUE,
177             tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
178                         .TerminationPoint1.class)
179                     .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst()
180                         .orElseThrow().getIfCapType());
181         assertNull(
182             tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
183                     .TerminationPoint1.class)
184                 .getXpdrTpPortConnectionAttributes().getRate(),
185             "the rate should be null");
186         assertEquals(OpenroadmTpType.XPONDERNETWORK,tps.get(2).augmentation(TerminationPoint1.class).getTpType(),
187             "third TP must be of type network");
188     }
189
190     @Test
191     void createTopologyShardForSpdrTest() {
192         TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr);
193         assertNotNull(topologyShard, "TopologyShard should never be null");
194         assertEquals(2, topologyShard.getNodes().size(), "Should contain two nodes");
195         assertEquals(0, topologyShard.getLinks().size(), "Should contain no link");
196         List<Node> nodes = topologyShard.getNodes().stream()
197             .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue()))
198             .collect(Collectors.toList());
199         for (Node node : nodes) {
200             checkSpdrNode(node);
201         }
202     }
203
204     @Test
205     void createOtnLinksForOTU4NormalTest() {
206         String nodeA = "SPDRA";
207         String tpA = "XPDR1-NETWORK1";
208         String nodeZ = "SPDRZ";
209         String tpZ = "XPDR1-NETWORK1";
210         List<Link> links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks();
211         assertEquals(2, links.size(), "2 OTU4 links should have been created");
212         List<Link> sortedLinks = links.stream()
213             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
214             .collect(Collectors.toList());
215         assertEquals(
216             "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
217             sortedLinks.get(0).getLinkId().getValue(),
218             "name of OTU4 linkid AZ");
219         assertEquals(
220             "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
221             sortedLinks.get(1).getLinkId().getValue(),
222             "name of OTU4 linkid ZA");
223         assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
224         assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
225         assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
226         assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
227         assertEquals(
228             Uint32.valueOf(100000),
229             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(),
230             "available BW at OTU4 creation should be 100G (100000)");
231         assertEquals(
232             Uint32.valueOf(0),
233             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(),
234             "used BW at OTU4 creation should be 0");
235         assertEquals(
236             OpenroadmLinkType.OTNLINK,
237             sortedLinks.get(0).augmentation(
238                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1.class)
239                 .getLinkType());
240         assertEquals(
241             "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
242             sortedLinks.get(0).augmentation(
243                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1.class)
244                 .getOppositeLink().getValue(),
245             "opposite link must be present");
246         assertEquals(
247             OtnLinkType.OTU4,
248             sortedLinks.get(0).augmentation(
249                     org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.Link1.class)
250                 .getOtnLinkType(),
251             "otn link type should be OTU4");
252     }
253
254     @Test
255     void createOtnLinksForNotManagedOtnlinktypeTest() {
256         String nodeA = "SPDRA";
257         String tpA = "XPDR1-NETWORK1";
258         String nodeZ = "SPDRZ";
259         String tpZ = "XPDR1-NETWORK1";
260         TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0);
261         assertNotNull(topoShard, "TopologyShard should never be null");
262         assertNull(topoShard.getNodes(), "TopologyShard should not contain any node");
263         assertNull(topoShard.getLinks(), "TopologyShard should not contain any link");
264     }
265
266     @Test
267     void createOtnLinksForODU4NormalTest() {
268         TopologyShard topoShard = OpenRoadmOtnTopology
269             .createOtnLinks(
270                 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(100000)),
271                 NetworkmodelTestUtil.createTpList(false), OtnLinkType.ODTU4);
272         assertNotNull(topoShard, "TopologyShard should never be null");
273         assertNull(topoShard.getNodes(), "list of nodes should be null");
274         List<Link> sortedLinks = topoShard.getLinks().stream()
275             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
276             .collect(Collectors.toList());
277         assertEquals(4, sortedLinks.size(), "list of links should contain 4 links");
278         assertTrue(sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"), "link 3 should be of type OTU4");
279         assertEquals(
280             Uint32.valueOf(0),
281             sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth(),
282             "after odu4 creation, available BW of supported OTU4 should be 0");
283         assertEquals(
284             Uint32.valueOf(100000),
285             sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth(),
286             "after odu4 creation, used BW of supported OTU4 should be 100 000");
287         assertEquals(
288             "ODTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
289             sortedLinks.get(0).getLinkId().getValue());
290         assertEquals(
291             "ODTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
292             sortedLinks.get(1).getLinkId().getValue());
293         assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
294         assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
295         assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
296         assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
297         assertEquals(
298             Uint32.valueOf(100000),
299             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(),
300             "after odu4 creation, its available BW should be 100 000");
301         assertEquals(
302             Uint32.valueOf(0),
303             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(),
304             "after odu4 creation, its used BW should be 0");
305         assertEquals(
306             OpenroadmLinkType.OTNLINK,
307             sortedLinks.get(0).augmentation(
308                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1.class)
309                 .getLinkType());
310         assertEquals(
311             "ODTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
312             sortedLinks.get(0).augmentation(
313                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1.class)
314                 .getOppositeLink().getValue(),
315             "opposite link must be present");
316         assertEquals(
317             OtnLinkType.ODTU4,
318             sortedLinks.get(0).augmentation(
319                     org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.Link1.class)
320                 .getOtnLinkType(),
321             "otn link type should be ODTU4");
322
323         assertEquals(2, topoShard.getTps().size(), "list of TPs should contain 2 updated TPs");
324         assertNotNull(
325             topoShard.getTps().get(0).augmentation(
326                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
327                         .TerminationPoint1.class)
328                 .getXpdrTpPortConnectionAttributes().getTsPool(),
329             "after ODU4 creation, its termination point should contain a TsPool list");
330         assertEquals(
331             80,
332             topoShard.getTps().get(0).augmentation(
333                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
334                         .TerminationPoint1.class)
335                 .getXpdrTpPortConnectionAttributes().getTsPool().size(),
336             "Ts pool list should be full, with 80 trib slots");
337         assertNotNull(
338             topoShard.getTps().get(0).augmentation(
339                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
340                         .TerminationPoint1.class)
341                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
342                 .getTpnPool(),
343             "after ODU4 creation, its termination point should contain a TpnPool list");
344         assertEquals(
345             80,
346             topoShard.getTps().get(0).augmentation(
347                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
348                         .TerminationPoint1.class)
349                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
350                 .getTpnPool().size(),
351             "Tpn pool list should be full, with 80 trib ports");
352     }
353
354     @Test
355     void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
356         List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(100000));
357         List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
358         for (Link link : otu4Links) {
359             otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
360         }
361         TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(
362                 otu4LinksWithBadBWParam,
363                 NetworkmodelTestUtil.createTpList(false),
364                 OtnLinkType.OTU4);
365         assertNotNull(topoShard, "TopologyShard should never be null");
366         assertNull(topoShard.getNodes(), "list of nodes should be null");
367         assertNull(topoShard.getLinks(), "list of links should be null");
368         assertNull(topoShard.getTps(), "list of tps should be null");
369
370         otu4LinksWithBadBWParam.clear();
371         topoShard = OpenRoadmOtnTopology.createOtnLinks(
372                 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(99000)),
373                 NetworkmodelTestUtil.createTpList(false),
374                 OtnLinkType.OTU4);
375         assertNull(topoShard.getNodes(), "list of nodes should be null");
376         assertNull(topoShard.getLinks(), "list of links should be null");
377         assertNull(topoShard.getTps(), "list of tps should be null");
378     }
379
380     @Test
381     void deleteOtnLinksForODU4NormalTest() {
382         TopologyShard topoShard = OpenRoadmOtnTopology.deleteOtnLinks(
383                     NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(0)),
384                     NetworkmodelTestUtil.createTpList(true),
385                     OtnLinkType.OTU4);
386         assertNotNull(topoShard, "TopologyShard should never be null");
387         assertEquals(2, topoShard.getLinks().size(), "list of links should contain 2 links");
388         assertEquals(
389             Uint32.valueOf(100000),
390             topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth(),
391             "after ODU4 deletion, available BW of supported OTU4 should be 100 000");
392         assertEquals(
393             Uint32.valueOf(0),
394             topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth(),
395             "after ODU4 deletion, used BW of supported OTU4 should be 0");
396
397         assertEquals(2, topoShard.getTps().size(), "list of TPs should contain 2 updated TPs");
398         assertNull(
399             topoShard.getTps().get(0).augmentation(
400                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
401                         .TerminationPoint1.class)
402                 .getXpdrTpPortConnectionAttributes().getTsPool(),
403             "after ODU4 deletion, its termination points should not contain any TsPool list");
404         assertNull(
405             topoShard.getTps().get(0).augmentation(
406                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
407                         .TerminationPoint1.class)
408                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool(),
409             "after ODU4 deletion, its termination points should not contain any TpnPool list");
410     }
411
412     @Test
413     void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
414         List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(0));
415         List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
416         for (Link link : otu4Links) {
417             otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
418         }
419         TopologyShard topoShard = OpenRoadmOtnTopology.deleteOtnLinks(
420                 otu4LinksWithBadBWParam,
421                 NetworkmodelTestUtil.createTpList(true),
422                 OtnLinkType.OTU4);
423         assertNotNull(topoShard, "TopologyShard should never be null");
424         assertNull(topoShard.getNodes(), "list of nodes should be null");
425         assertNull(topoShard.getLinks(), "list of links should be null");
426         assertNull(topoShard.getTps(), "list of tps should be null");
427     }
428
429     @Test
430     void updateOtnLinksFor10GTest() {
431         // tests update for 10G creation
432         TopologyShard topoShard = OpenRoadmOtnTopology.updateOtnLinks(
433                     NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)),
434                     NetworkmodelTestUtil.createTpList(true),
435                     Uint32.valueOf(10), (short)1, (short)1, (short)8, false);
436         assertNotNull(topoShard, "TopologyShard should never be null");
437         assertNull(topoShard.getNodes(), "list of nodes should be null");
438         List<Link> sortedLinks = topoShard.getLinks().stream()
439             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
440             .collect(Collectors.toList());
441         assertEquals(2, sortedLinks.size(), "list of links should contain 2 links");
442         assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-"));
443         assertEquals(
444             Uint32.valueOf(90000),
445             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(),
446             "after 10G creation, available BW of supported ODU4 should be 90000");
447         assertEquals(
448             Uint32.valueOf(10000),
449             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(),
450             "after 10G creation, used BW of supported ODU4 should be 10000");
451
452         assertEquals(
453             72,
454             topoShard.getTps().get(0).augmentation(
455                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
456                         .TerminationPoint1.class)
457                 .getXpdrTpPortConnectionAttributes().getTsPool().size(),
458             "after 10G creation, 8 (over 80) trib slot should be occupied");
459         assertThat(
460             "trib slot 1-8 should no longer be present in Trib slot list",
461             topoShard.getTps().get(0).augmentation(
462                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
463                         .TerminationPoint1.class)
464                 .getXpdrTpPortConnectionAttributes().getTsPool(),
465             not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8))));
466         assertThat(
467             "trib slot 9 should always be present in trib slot list",
468             topoShard.getTps().get(0).augmentation(
469                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
470                         .TerminationPoint1.class)
471                 .getXpdrTpPortConnectionAttributes().getTsPool(),
472             hasItem(Uint16.valueOf(9)));
473         assertEquals(
474             79,
475             topoShard.getTps().get(0).augmentation(
476                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
477                         .TerminationPoint1.class)
478                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
479                 .getTpnPool().size(),
480             "after 10G creation, 1 (over 80) trib port should be occupied");
481         assertThat(
482             "trib port 1 should no longer be present",
483             topoShard.getTps().get(0).augmentation(
484                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
485                         .TerminationPoint1.class)
486                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
487                 .getTpnPool(),
488             not(hasItem(Uint16.valueOf(1))));
489
490         // tests update for 10G deletion
491         sortedLinks.clear();
492         topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), Uint32.valueOf(10),
493                 (short)1, (short)1, (short)8, true);
494         sortedLinks = topoShard.getLinks().stream()
495             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
496             .collect(Collectors.toList());
497         assertEquals(2, sortedLinks.size(), "list of links should contain 2 links");
498         assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-"));
499         assertEquals(
500             Uint32.valueOf(100000),
501             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(),
502             "after 10G deletion, available BW of supported ODU4 should be 100 000");
503         assertEquals(
504             Uint32.valueOf(0),
505             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(),
506             "after 10G deletion, used BW of supported ODU4 should be 0");
507
508         assertEquals(
509             80,
510             topoShard.getTps().get(0).augmentation(
511                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
512                         .TerminationPoint1.class)
513                 .getXpdrTpPortConnectionAttributes().getTsPool().size(),
514             "after 10G deletion, trib slot list should be full");
515         assertThat(
516             "after 10G deletion, trib slot list should contain items 1-8",
517             topoShard.getTps().get(0).augmentation(
518                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
519                         .TerminationPoint1.class)
520                 .getXpdrTpPortConnectionAttributes().getTsPool(),
521             hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9)));
522         assertEquals(
523                 80,
524                 topoShard.getTps().get(0).augmentation(
525                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
526                             .TerminationPoint1.class)
527                     .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
528                     .getTpnPool().size(),
529                 "after 10G deletion, trib port list should be full");
530         assertThat(
531             "after 10G deletion, trib port list should contain items 1",
532             topoShard.getTps().get(0).augmentation(
533                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
534                         .TerminationPoint1.class)
535                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
536                 .getTpnPool(),
537             hasItem(Uint16.valueOf(1)));
538     }
539
540     @Test
541     void updateOtnLinksFor1GCreationTest() {
542         // tests update for 1G creation
543         TopologyShard topoShard = OpenRoadmOtnTopology.updateOtnLinks(
544                     NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)),
545                     NetworkmodelTestUtil.createTpList(true),
546                     Uint32.valueOf(1), (short)1, (short)1, (short)1, false);
547         assertNotNull(topoShard, "TopologyShard should never be null");
548         assertNull(topoShard.getNodes(), "list of nodes should be null");
549         List<Link> sortedLinks = topoShard.getLinks().stream()
550             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
551             .collect(Collectors.toList());
552         assertEquals(2, sortedLinks.size(), "list of links should contain 2 links");
553         assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-"));
554         assertEquals(
555             Uint32.valueOf(99000),
556             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(),
557             "after 1G creation, available BW of supported ODU4 should be 99000");
558         assertEquals(
559             Uint32.valueOf(1000),
560             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(),
561             "after 1G creation, used BW of supported ODU4 should be 1000");
562
563         assertEquals(
564             79,
565             topoShard.getTps().get(0).augmentation(
566                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
567                         .TerminationPoint1.class)
568                 .getXpdrTpPortConnectionAttributes().getTsPool().size(),
569             "after 1G creation, 1 (over 80) trib slot should be occupied");
570         assertThat(
571             "trib slot 1 should no longer be present in Trib slot list",
572             topoShard.getTps().get(0).augmentation(
573                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
574                         .TerminationPoint1.class)
575                 .getXpdrTpPortConnectionAttributes().getTsPool(),
576             not(hasItem(Uint16.valueOf(1))));
577         assertThat(
578             "trib slot 2 should always be present in Trib slot list",
579             topoShard.getTps().get(0).augmentation(
580                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
581                         .TerminationPoint1.class)
582                 .getXpdrTpPortConnectionAttributes().getTsPool(),
583             hasItem(Uint16.valueOf(2)));
584         assertEquals(
585             79,
586             topoShard.getTps().get(0).augmentation(
587                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
588                         .TerminationPoint1.class)
589                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
590                 .getTpnPool().size(),
591             "after 1G creation, 1 (over 80) trib port should be occupied");
592         assertThat(
593             "trib port 1 should no longer be present in Trib port list",
594             topoShard.getTps().get(0).augmentation(
595                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
596                         .TerminationPoint1.class)
597                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
598                 .getTpnPool(),
599             not(hasItem(Uint16.valueOf(1))));
600
601         // tests update for 1G deletion
602         sortedLinks.clear();
603         topoShard = OpenRoadmOtnTopology.updateOtnLinks(
604                     topoShard.getLinks(),
605                     topoShard.getTps(),
606                     Uint32.valueOf(1), (short)1, (short)1, (short)1, true);
607         sortedLinks = topoShard.getLinks().stream()
608             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
609             .collect(Collectors.toList());
610         assertEquals(2, sortedLinks.size(), "list of links should contain 2 links");
611         assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-"));
612         assertEquals(
613             Uint32.valueOf(100000),
614             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(),
615             "after 1G deletion, available BW of supported ODU4 should be 100 000");
616         assertEquals(
617             Uint32.valueOf(0),
618             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(),
619             "after 1G deletion, used BW of supported ODU4 should be 0");
620
621         assertEquals(
622             80,
623             topoShard.getTps().get(0).augmentation(
624                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
625                         .TerminationPoint1.class)
626                 .getXpdrTpPortConnectionAttributes().getTsPool().size(),
627             "after 1G deletion, trib slot list should be full");
628         assertThat(
629             "after 1G deletion, trib slot list should contain items 1 and 2",
630             topoShard.getTps().get(0).augmentation(
631                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
632                         .TerminationPoint1.class)
633                 .getXpdrTpPortConnectionAttributes().getTsPool(),
634             hasItems(Uint16.valueOf(1), Uint16.valueOf(2)));
635         assertEquals(
636             80,
637             topoShard.getTps().get(0).augmentation(
638                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
639                         .TerminationPoint1.class)
640                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
641                 .getTpnPool().size(),
642             "after 1G deletion, trib port list should be full");
643         assertThat(
644             "after 1G deletion, trib port list should contain items 1",
645             topoShard.getTps().get(0).augmentation(
646                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
647                         .TerminationPoint1.class)
648                 .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
649                 .getTpnPool(),
650             hasItem(Uint16.valueOf(1)));
651     }
652
653     @Test
654     void updateOtnLinksForODU4WhenBWParamsNotPresentTest() {
655         List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000));
656         List<Link> odu4LinksWithBadBWParam = new ArrayList<>();
657         for (Link link : odu4Links) {
658             odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
659         }
660         TopologyShard topoShard =
661             OpenRoadmOtnTopology.updateOtnLinks(
662                     odu4LinksWithBadBWParam,
663                     NetworkmodelTestUtil.createTpList(true),
664                     Uint32.valueOf(1), (short)1, (short)1, (short)10, false);
665         assertNotNull(topoShard, "TopologyShard should never be null");
666         assertNull(topoShard.getNodes(), "list of nodes should be null");
667         assertNull(topoShard.getLinks(), "list of links should be null");
668         assertNull(topoShard.getTps(), "list of tps should be null");
669     }
670
671     @Test
672     void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() {
673         List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(
674                 OtnLinkType.ODTU4,
675                 Uint32.valueOf(8000));
676         TopologyShard topoShard = OpenRoadmOtnTopology.updateOtnLinks(
677                     odu4LinksWithBadBWParam,
678                     NetworkmodelTestUtil.createTpList(true),
679                     Uint32.valueOf(10), (short)1, (short)1, (short)10, false);
680         assertNotNull(topoShard, "TopologyShard should never be null");
681         assertNull(topoShard.getNodes(), "list of nodes should be null");
682         assertNull(topoShard.getLinks(), "list of links should be null");
683         assertNull(topoShard.getTps(), "list of tps should be null");
684     }
685
686     private void checkSpdrNode(Node node) {
687         Uint16 xpdrNb = node.augmentation(
688                 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Node1.class)
689             .getXpdrAttributes().getXpdrNumber();
690         assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue());
691         if (xpdrNb.equals(Uint16.valueOf(1))) {
692             assertEquals(OpenroadmNodeType.MUXPDR, node.augmentation(Node1.class).getNodeType());
693         } else if (xpdrNb.equals(Uint16.valueOf(2))) {
694             assertEquals(OpenroadmNodeType.SWITCH, node.augmentation(Node1.class).getNodeType());
695         }
696         // tests supporting nodes
697         List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
698             .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
699             .collect(Collectors.toList());
700         assertEquals(3, supportingNodes.size(), "Should contain 3 supporting nodes");
701         assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
702         assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue());
703         assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
704         assertEquals("SPDR-SA1", supportingNodes.get(1).getNodeRef().getValue());
705         assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
706         assertEquals("SPDR-SA1-XPDR" + xpdrNb, supportingNodes.get(2).getNodeRef().getValue());
707         checkSpdrSwitchingPools(
708             xpdrNb,
709             node.augmentation(
710                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Node1.class)
711                 .getSwitchingPools());
712         List<TerminationPoint> tpList = node.augmentation(
713                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
714             .nonnullTerminationPoint().values().stream()
715             .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
716             .collect(Collectors.toList());
717         checkSpdrTpList(xpdrNb, tpList);
718     }
719
720     private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) {
721         List<OduSwitchingPools> oduSwitchingPools = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
722         assertEquals(
723             1,
724             oduSwitchingPools.size(),
725             "switching-pools augmentation should contain a single odu-switching-pools");
726         assertEquals(
727             Uint16.valueOf(1),
728             oduSwitchingPools.get(0).getSwitchingPoolNumber(),
729             "switching-pool-number should be 1");
730         assertEquals(
731             "non-blocking",
732             oduSwitchingPools.get(0).getSwitchingPoolType().getName(),
733             "switching-pool-type should be non-blocking");
734
735         List<NonBlockingList> nonBlockingList =
736                 new ArrayList<>(oduSwitchingPools.get(0).nonnullNonBlockingList().values());
737         if (xpdrNb.equals(Uint16.valueOf(1))) {
738             assertEquals(4, nonBlockingList.size(), "Mux should contain 4 non blocking list");
739             assertEquals(Uint16.valueOf(1), nonBlockingList.get(0).getNblNumber());
740             List<NonBlockingList> nblList = oduSwitchingPools.get(0).nonnullNonBlockingList().values().stream()
741                 .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber()))
742                 .collect(Collectors.toList());
743             for (NonBlockingList nbl : nblList) {
744                 assertEquals(
745                     Uint32.valueOf(10),
746                     nbl.getAvailableInterconnectBandwidth(),
747                     "for a 10G mux, interconnect BW should be 10G");
748                 assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit());
749                 assertThat(
750                     "for a 10G mux, non blocking list should contain 2 entries (client + network ports)",
751                     nbl.getTpList(),
752                     hasSize(2));
753                 String nb = nbl.getNblNumber().toString();
754                 assertThat(
755                     nbl.getTpList(),
756                     containsInAnyOrder(new TpId("XPDR1-NETWORK1"), new TpId("XPDR1-CLIENT" + nb)));
757             }
758         } else if (xpdrNb.equals(Uint16.valueOf(2))) {
759             assertEquals(1, nonBlockingList.size(), "Switch should contain a single non blocking list");
760             assertEquals(Uint16.valueOf(1), nonBlockingList.get(0).getNblNumber());
761             assertThat(
762                 "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)",
763                 nonBlockingList.get(0).getTpList(),
764                 hasSize(8));
765             assertThat(
766                 nonBlockingList.get(0).getTpList(),
767                 containsInAnyOrder(
768                     new TpId("XPDR2-CLIENT1"), new TpId("XPDR2-NETWORK1"), new TpId("XPDR2-CLIENT2"),
769                     new TpId("XPDR2-NETWORK2"), new TpId("XPDR2-CLIENT3"), new TpId("XPDR2-NETWORK3"),
770                     new TpId("XPDR2-CLIENT4"), new TpId("XPDR2-NETWORK4")));
771         }
772     }
773
774     private void checkSpdrTpList(Uint16 xpdrNb, List<TerminationPoint> tpList) {
775         LOG.info("tpList = {}", tpList);
776         assertEquals(
777             IfOCHOTU4ODU4.VALUE,
778             tpList.get(4).augmentation(
779                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
780                         .TerminationPoint1.class)
781                 .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst()
782                 .orElseThrow().getIfCapType(),
783             "only IfOCHOTU4ODU4 interface capabitily expected");
784         assertEquals(
785             ODU4.VALUE,
786             tpList.get(4).augmentation(
787                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
788                         .TerminationPoint1.class)
789                 .getXpdrTpPortConnectionAttributes().getRate(),
790             "the rate should be ODU4");
791         assertEquals(
792             "openroadm-topology",
793             tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().orElseThrow().getNetworkRef()
794                 .getValue());
795         assertEquals(
796             "SPDR-SA1-XPDR" + xpdrNb,
797             tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().orElseThrow().getNodeRef()
798                 .getValue());
799         assertEquals(
800             "XPDR" + xpdrNb + "-NETWORK1",
801             tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().orElseThrow().getTpRef()
802                 .getValue());
803         if (xpdrNb.equals(Uint16.valueOf(1))) {
804             assertEquals(5, tpList.size(), "should contain 5 TPs");
805             assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
806             assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue());
807             assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue());
808             assertEquals(
809                 2,
810                 tpList.get(1).augmentation(
811                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
812                             .TerminationPoint1.class)
813                     .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().size(),
814                 "supported interface capability of tp-id XPDR1-CLIENT2 should contain 2 if-cap-type");
815             assertEquals(
816                 3,
817                 tpList.get(2).augmentation(
818                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
819                             .TerminationPoint1.class)
820                     .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().size(),
821                 "supported interface capability of tp-id XPDR1-CLIENT3 should contain 3 if-cap-type");
822             List<SupportedInterfaceCapability> sicListClient1 = tpList.get(0).augmentation(
823                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
824                         .TerminationPoint1.class)
825                 .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream()
826                 .collect(Collectors.toList());
827             for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient1) {
828                 assertThat("tp should have 2 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2",
829                     String.valueOf(supportedInterfaceCapability.getIfCapType()),
830                     either(containsString(String.valueOf(If10GEODU2e.VALUE)))
831                         .or(containsString(String.valueOf(If10GEODU2.VALUE))));
832             }
833             List<SupportedInterfaceCapability> sicListClient3 = tpList.get(3).augmentation(
834                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
835                         .TerminationPoint1.class)
836                 .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream()
837                 .collect(Collectors.toList());
838             for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) {
839                 assertThat("tp should have 3 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2, if-10GE",
840                     String.valueOf(supportedInterfaceCapability.getIfCapType()),
841                     either(containsString(String.valueOf(If10GEODU2e.VALUE)))
842                         .or(containsString(String.valueOf(If10GEODU2.VALUE)))
843                         .or(containsString(String.valueOf(If10GE.VALUE))));
844             }
845             assertThat("the rate should be ODU2 or ODU2e",
846                 String.valueOf(tpList.get(2).augmentation(
847                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
848                             .TerminationPoint1.class)
849                     .getXpdrTpPortConnectionAttributes().getRate()),
850                 either(containsString(String.valueOf(ODU2e.VALUE)))
851                     .or(containsString(String.valueOf(ODU2.VALUE))));
852             assertEquals(
853                 OpenroadmTpType.XPONDERCLIENT,
854                 tpList.get(2).augmentation(TerminationPoint1.class).getTpType(),
855                 "TP should be of type client");
856             assertEquals(
857                 OpenroadmTpType.XPONDERNETWORK,
858                 tpList.get(4).augmentation(TerminationPoint1.class).getTpType(),
859                 "TP should be of type network");
860         } else if (xpdrNb.equals(Uint16.valueOf(2))) {
861             assertEquals(8, tpList.size(), "should contain 8 TPs");
862             assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue());
863             assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue());
864             assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue());
865             assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue());
866             assertEquals(
867                 IfOCHOTU4ODU4.VALUE,
868                 tpList.get(5).augmentation(
869                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
870                             .TerminationPoint1.class)
871                     .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst()
872                     .orElseThrow().getIfCapType(),
873                 "only IfOCHOTU4ODU4 interface capabitily expected");
874             assertEquals(
875                 2,
876                 tpList.get(2).augmentation(
877                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
878                             .TerminationPoint1.class)
879                     .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().size(),
880                 "supported interface capability of tp should contain 2 IfCapType");
881             List<SupportedInterfaceCapability> sicListClient3 = tpList.get(2).augmentation(
882                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526
883                         .TerminationPoint1.class)
884                 .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream()
885                 .collect(Collectors.toList());
886             for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) {
887                 assertThat(
888                     "tp should have 2 if-cap-type: if-100GE-ODU4, if-100GE",
889                     String.valueOf(supportedInterfaceCapability.getIfCapType()),
890                     either(containsString(String.valueOf(If100GEODU4.VALUE)))
891                         .or(containsString(String.valueOf(If100GE.VALUE))));
892             }
893             assertEquals(
894                 OpenroadmTpType.XPONDERCLIENT,
895                 tpList.get(2).augmentation(TerminationPoint1.class).getTpType(),
896                 "TP should be of type client");
897             assertEquals(
898                 OpenroadmTpType.XPONDERNETWORK,
899                 tpList.get(6).augmentation(TerminationPoint1.class).getTpType(),
900                 "TP should be of type network");
901         }
902     }
903 }