edc3a825acd09db094e324408bb742728e52fac7
[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.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertNull;
21 import static org.junit.Assert.assertTrue;
22 import static org.junit.Assert.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.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.portmapping.rev210310.Network;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
44 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmLinkType;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU2e;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU4;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Link1;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.networks.network.node.SwitchingPools;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GE;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GE;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
64 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.OtnLinkType;
65 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.TerminationPoint1;
66 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
67 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
68 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
69 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
70 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder;
71 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
72 import org.opendaylight.yangtools.yang.common.QName;
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().getDataObjectFromJson(portMappingReader,
89                     QName.create("http://org/opendaylight/transportpce/portmapping", "2021-03-10", "network"));
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     public void createTopologyShardForTpdrTest() {
116         TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr);
117         assertNotNull("TopologyShard should never be null", topologyShard);
118         assertEquals("Should contain a single node", 1, topologyShard.getNodes().size());
119         assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
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("Should contain 3 supporting nodes", 3, supportingNodes.size());
127         assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
128         assertEquals("NodeA", supportingNodes.get(0).getNodeRef().getValue());
129         assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
130         assertEquals("XPDR-A1", supportingNodes.get(1).getNodeRef().getValue());
131         assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
132         assertEquals("XPDR-A1-XPDR1", supportingNodes.get(2).getNodeRef().getValue());
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.rev200529.Node1.class)
138                 .getXpdrAttributes()
139                 .getXpdrNumber());
140         //tests list of TPs
141         List<TerminationPoint> tps = node.augmentation(
142                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
143             .nonnullTerminationPoint().values().stream()
144             .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
145             .collect(Collectors.toList());
146         assertEquals("node should contain 4 TPs", 4, tps.size());
147         //tests client tp
148         assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue());
149         assertEquals(
150             "XPDR1-NETWORK1",
151             tps.get(0).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
152         assertEquals(
153             "only If100GE interface capabitily expected",
154             1,
155             tps.get(0).augmentation(
156                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
157                         .TerminationPoint1.class)
158                 .getTpSupportedInterfaces()
159                 .getSupportedInterfaceCapability()
160                 .size());
161         assertEquals(
162             If100GE.class.getName(),
163             tps.get(0).augmentation(
164                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
165                         .TerminationPoint1.class)
166                 .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability()
167                 .values().stream().findFirst()
168                 .get().getIfCapType().getName());
169         assertEquals(
170             "first TP must be of type client",
171             OpenroadmTpType.XPONDERCLIENT,
172             tps.get(0).augmentation(
173                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
174                         .TerminationPoint1.class)
175                 .getTpType());
176         //tests network tp
177         assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue());
178         assertEquals(
179             "XPDR1-CLIENT1",
180             tps.get(2).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
181         assertEquals(
182             "only IfOCH interface capabitily expected",
183             1,
184             tps.get(2).augmentation(
185                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
186                         .TerminationPoint1.class)
187                 .getTpSupportedInterfaces()
188                 .getSupportedInterfaceCapability()
189                 .size());
190         assertEquals(
191             IfOCH.class.getName(),
192             tps.get(2).augmentation(
193                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
194                         .TerminationPoint1.class)
195                 .getTpSupportedInterfaces()
196                 .getSupportedInterfaceCapability()
197                 .values().stream().findFirst()
198                 .get()
199                 .getIfCapType()
200                 .getName());
201         assertNull(
202             "the rate should be null",
203             tps.get(2).augmentation(
204                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
205                         .TerminationPoint1.class)
206                 .getXpdrTpPortConnectionAttributes()
207                 .getRate());
208         assertEquals(
209             "third TP must be of type network",
210             OpenroadmTpType.XPONDERNETWORK,
211             tps.get(2).augmentation(
212                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
213                 .getTpType());
214     }
215
216     @Test
217     public void createTopologyShardForSpdrTest() {
218         TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr);
219         assertNotNull("TopologyShard should never be null", topologyShard);
220         assertEquals("Should contain two nodes", 2, topologyShard.getNodes().size());
221         assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
222         List<Node> nodes = topologyShard.getNodes().stream()
223             .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue()))
224             .collect(Collectors.toList());
225         for (Node node : nodes) {
226             checkSpdrNode(node);
227         }
228     }
229
230     @Test
231     public void createOtnLinksForOTU4NormalTest() {
232         String nodeA = "SPDRA";
233         String tpA = "XPDR1-NETWORK1";
234         String nodeZ = "SPDRZ";
235         String tpZ = "XPDR1-NETWORK1";
236         List<Link> links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks();
237         assertEquals("2 OTU4 links should have been created", 2, links.size());
238         List<Link> sortedLinks = links.stream()
239             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
240             .collect(Collectors.toList());
241         assertEquals(
242             "name of OTU4 linkid AZ",
243             "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
244             sortedLinks.get(0).getLinkId().getValue());
245         assertEquals(
246             "name of OTU4 linkid ZA",
247             "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
248             sortedLinks.get(1).getLinkId().getValue());
249         assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
250         assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
251         assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
252         assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
253         assertEquals(
254             "available BW at OTU4 creation should be 100G (100000)",
255             Uint32.valueOf(100000),
256             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
257         assertEquals(
258             "used BW at OTU4 creation should be 0",
259             Uint32.valueOf(0),
260             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
261         assertEquals(
262             OpenroadmLinkType.OTNLINK,
263             sortedLinks.get(0).augmentation(
264                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
265                 .getLinkType());
266         assertEquals(
267             "opposite link must be present",
268             "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
269             sortedLinks.get(0).augmentation(
270                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
271                 .getOppositeLink()
272                 .getValue());
273         assertEquals(
274             "otn link type should be OTU4",
275             OtnLinkType.OTU4,
276             sortedLinks.get(0).augmentation(
277                     org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.Link1.class)
278                 .getOtnLinkType());
279     }
280
281     @Test
282     public void createOtnLinksForNotManagedOtnlinktypeTest() {
283         String nodeA = "SPDRA";
284         String tpA = "XPDR1-NETWORK1";
285         String nodeZ = "SPDRZ";
286         String tpZ = "XPDR1-NETWORK1";
287         TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0);
288         assertNotNull("TopologyShard should never be null", topoShard);
289         assertNull("TopologyShard should not contain any node", topoShard.getNodes());
290         assertNull("TopologyShard should not contain any link", topoShard.getLinks());
291     }
292
293     @Test
294     public void createOtnLinksForODU4NormalTest() {
295         TopologyShard topoShard = OpenRoadmOtnTopology
296             .createOtnLinks(
297                 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000),
298                 NetworkmodelTestUtil.createTpList(false));
299         assertNotNull("TopologyShard should never be null", topoShard);
300         assertNull("list of nodes should be null", topoShard.getNodes());
301         List<Link> sortedLinks = topoShard.getLinks().stream()
302             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
303             .collect(Collectors.toList());
304         assertEquals("list of links should contain 4 links", 4, sortedLinks.size());
305         assertTrue("link 3 should be of type OTU4", sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"));
306         assertEquals(
307             "after odu4 creation, available BW of supported OTU4 should be 0",
308             Uint32.valueOf(0),
309             sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth());
310         assertEquals(
311             "after odu4 creation, used BW of supported OTU4 should be 100 000",
312             Uint32.valueOf(100000),
313             sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth());
314
315         assertEquals(
316             "ODU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
317             sortedLinks.get(0).getLinkId().getValue());
318         assertEquals(
319             "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
320             sortedLinks.get(1).getLinkId().getValue());
321         assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
322         assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
323         assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
324         assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
325         assertEquals(
326             "after odu4 creation, its available BW should be 100 000",
327             Uint32.valueOf(100000),
328             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
329         assertEquals(
330             "after odu4 creation, its used BW should be 0",
331             Uint32.valueOf(0),
332             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
333         assertEquals(
334             OpenroadmLinkType.OTNLINK,
335             sortedLinks.get(0)
336                 .augmentation(
337                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
338                 .getLinkType());
339         assertEquals(
340             "opposite link must be present",
341             "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
342             sortedLinks.get(0)
343                 .augmentation(
344                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
345                 .getOppositeLink()
346                 .getValue());
347         assertEquals(
348             "otn link type should be ODTU4",
349             OtnLinkType.ODTU4,
350             sortedLinks.get(0)
351                 .augmentation(
352                     org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.Link1.class)
353                 .getOtnLinkType());
354
355         assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
356         assertNotNull(
357             "after ODU4 creation, its termination point should contain a TsPool list",
358             topoShard.getTps().get(0)
359                 .augmentation(
360                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
361                         .TerminationPoint1.class)
362                 .getXpdrTpPortConnectionAttributes()
363                 .getTsPool());
364         assertEquals(
365             "Ts pool list should be full, with 80 trib slots",
366             80,
367             topoShard.getTps().get(0)
368                 .augmentation(
369                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
370                         .TerminationPoint1.class)
371                 .getXpdrTpPortConnectionAttributes()
372                 .getTsPool()
373                 .size());
374         assertNotNull(
375             "after ODU4 creation, its termination point should contain a TpnPool list",
376             topoShard.getTps().get(0)
377                 .augmentation(
378                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
379                         .TerminationPoint1.class)
380                 .getXpdrTpPortConnectionAttributes()
381                 .getOdtuTpnPool().values().stream().findFirst()
382                 .get()
383                 .getTpnPool());
384         assertEquals(
385             "Tpn pool list should be full, with 80 trib ports",
386             80,
387             topoShard.getTps().get(0)
388                 .augmentation(
389                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
390                         .TerminationPoint1.class)
391                 .getXpdrTpPortConnectionAttributes()
392                 .getOdtuTpnPool().values().stream().findFirst()
393                 .get()
394                 .getTpnPool()
395                 .size());
396     }
397
398     @Test
399     public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
400         List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000);
401         List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
402         for (Link link : otu4Links) {
403             otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
404         }
405         TopologyShard topoShard =
406             OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false));
407         assertNotNull("TopologyShard should never be null", topoShard);
408         assertNull("list of nodes should be null", topoShard.getNodes());
409         assertNull("list of links should be null", topoShard.getLinks());
410         assertNull("list of tps should be null", topoShard.getTps());
411
412         otu4LinksWithBadBWParam.clear();
413         topoShard =
414             OpenRoadmOtnTopology.createOtnLinks(
415                     NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 99000),
416                     NetworkmodelTestUtil.createTpList(false));
417         assertNull("list of nodes should be null", topoShard.getNodes());
418         assertNull("list of links should be null", topoShard.getLinks());
419         assertNull("list of tps should be null", topoShard.getTps());
420     }
421
422     @Test
423     public void deleteOtnLinksForODU4NormalTest() {
424         TopologyShard topoShard =
425             OpenRoadmOtnTopology.deleteOtnLinks(
426                     NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0),
427                     NetworkmodelTestUtil.createTpList(true));
428         assertNotNull("TopologyShard should never be null", topoShard);
429         assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size());
430         assertEquals(
431             "after ODU4 deletion, available BW of supported OTU4 should be 100 000",
432             Uint32.valueOf(100000),
433             topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth());
434         assertEquals(
435             "after ODU4 deletion, used BW of supported OTU4 should be 0",
436             Uint32.valueOf(0),
437             topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth());
438
439         assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
440         assertNull(
441             "after ODU4 deletion, its termination points should not contain any TsPool list",
442             topoShard.getTps().get(0)
443                 .augmentation(
444                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
445                         .TerminationPoint1.class)
446                 .getXpdrTpPortConnectionAttributes()
447                 .getTsPool());
448         assertNull(
449             "after ODU4 deletion, its termination points should not contain any TpnPool list",
450             topoShard.getTps().get(0)
451                 .augmentation(
452                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
453                         .TerminationPoint1.class)
454                 .getXpdrTpPortConnectionAttributes()
455                 .getOdtuTpnPool());
456     }
457
458     @Test
459     public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
460         List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0);
461         List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
462         for (Link link : otu4Links) {
463             otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
464         }
465         TopologyShard topoShard =
466             OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true));
467         assertNotNull("TopologyShard should never be null", topoShard);
468         assertNull("list of nodes should be null", topoShard.getNodes());
469         assertNull("list of links should be null", topoShard.getLinks());
470         assertNull("list of tps should be null", topoShard.getTps());
471     }
472
473     @Test
474     public void updateOtnLinksFor10GTest() {
475         // tests update for 10G creation
476         TopologyShard topoShard =
477             OpenRoadmOtnTopology.updateOtnLinks(
478                     NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
479                     NetworkmodelTestUtil.createTpList(true),
480                     "10G", (short)1, (short)1, false);
481         assertNotNull("TopologyShard should never be null", topoShard);
482         assertNull("list of nodes should be null", topoShard.getNodes());
483         List<Link> sortedLinks = topoShard.getLinks().stream()
484             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
485             .collect(Collectors.toList());
486         assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
487         assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
488         assertEquals(
489             "after 10G creation, available BW of supported ODU4 should be 90000",
490             Uint32.valueOf(90000),
491             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
492         assertEquals(
493             "after 10G creation, used BW of supported ODU4 should be 10000",
494             Uint32.valueOf(10000),
495             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
496
497         assertEquals(
498             "after 10G creation, 8 (over 80) trib slot should be occupied",
499             72,
500             topoShard.getTps().get(0)
501                 .augmentation(
502                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
503                         .TerminationPoint1.class)
504                 .getXpdrTpPortConnectionAttributes()
505                 .getTsPool()
506                 .size());
507         assertThat(
508             "trib slot 1-8 should no longer be present in Trib slot list",
509             topoShard.getTps().get(0)
510                 .augmentation(
511                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
512                         .TerminationPoint1.class)
513                 .getXpdrTpPortConnectionAttributes()
514                 .getTsPool(),
515             not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8))));
516         assertThat(
517             "trib slot 9 should always be present in trib slot list",
518             topoShard.getTps().get(0)
519                 .augmentation(
520                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
521                         .TerminationPoint1.class)
522                 .getXpdrTpPortConnectionAttributes()
523                 .getTsPool(),
524             hasItem(Uint16.valueOf(9)));
525         assertEquals(
526             "after 10G creation, 1 (over 80) trib port should be occupied",
527             79,
528             topoShard.getTps().get(0)
529                 .augmentation(
530                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
531                         .TerminationPoint1.class)
532                 .getXpdrTpPortConnectionAttributes()
533                 .getOdtuTpnPool().values().stream().findFirst()
534                 .get()
535                 .getTpnPool()
536                 .size());
537         assertThat(
538             "trib port 1 should no longer be present",
539             topoShard.getTps().get(0)
540                 .augmentation(
541                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
542                         .TerminationPoint1.class)
543                 .getXpdrTpPortConnectionAttributes()
544                 .getOdtuTpnPool().values().stream().findFirst()
545                 .get()
546                 .getTpnPool(),
547             not(hasItem(Uint16.valueOf(1))));
548
549         // tests update for 10G deletion
550         sortedLinks.clear();
551         topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), "10G", (short)1,
552             (short)1, true);
553         sortedLinks = topoShard.getLinks().stream()
554             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
555             .collect(Collectors.toList());
556         assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
557         assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
558         assertEquals(
559             "after 10G deletion, available BW of supported ODU4 should be 100 000",
560             Uint32.valueOf(100000),
561             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
562         assertEquals(
563             "after 10G deletion, used BW of supported ODU4 should be 0",
564             Uint32.valueOf(0),
565             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
566
567         assertEquals(
568             "after 10G deletion, trib slot list should be full",
569             80,
570             topoShard.getTps().get(0)
571                 .augmentation(
572                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
573                         .TerminationPoint1.class)
574                 .getXpdrTpPortConnectionAttributes()
575                 .getTsPool()
576                 .size());
577         assertThat(
578             "after 10G deletion, trib slot list should contain items 1-8",
579             topoShard.getTps().get(0)
580                 .augmentation(
581                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
582                         .TerminationPoint1.class)
583                 .getXpdrTpPortConnectionAttributes()
584                 .getTsPool(),
585             hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9)));
586         assertEquals(
587             "after 10G deletion, trib port list should be full",
588                 80,
589                 topoShard.getTps().get(0)
590                     .augmentation(
591                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
592                         .TerminationPoint1.class)
593                     .getXpdrTpPortConnectionAttributes()
594                     .getOdtuTpnPool().values().stream().findFirst()
595                     .get()
596                     .getTpnPool()
597                     .size());
598         assertThat(
599             "after 10G deletion, trib port list should contain items 1",
600             topoShard.getTps().get(0)
601                 .augmentation(
602                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
603                         .TerminationPoint1.class)
604                 .getXpdrTpPortConnectionAttributes()
605                 .getOdtuTpnPool().values().stream().findFirst()
606                 .get()
607                 .getTpnPool(),
608             hasItem(Uint16.valueOf(1)));
609     }
610
611     @Test
612     public void updateOtnLinksFor1GCreationTest() {
613         // tests update for 1G creation
614         TopologyShard topoShard =
615             OpenRoadmOtnTopology.updateOtnLinks(
616                     NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
617                     NetworkmodelTestUtil.createTpList(true),
618                     "1G", (short)1, (short)1, false);
619         assertNotNull("TopologyShard should never be null", topoShard);
620         assertNull("list of nodes should be null", topoShard.getNodes());
621         List<Link> sortedLinks = topoShard.getLinks().stream()
622             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
623             .collect(Collectors.toList());
624         assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
625         assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
626         assertEquals(
627             "after 1G creation, available BW of supported ODU4 should be 99000",
628             Uint32.valueOf(99000),
629             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
630         assertEquals(
631             "after 1G creation, used BW of supported ODU4 should be 1000",
632             Uint32.valueOf(1000),
633             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
634
635         assertEquals(
636             "after 1G creation, 1 (over 80) trib slot should be occupied",
637             79,
638             topoShard.getTps().get(0)
639                 .augmentation(
640                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
641                         .TerminationPoint1.class)
642                 .getXpdrTpPortConnectionAttributes()
643                 .getTsPool()
644                 .size());
645         assertThat(
646             "trib slot 1 should no longer be present in Trib slot list",
647             topoShard.getTps().get(0)
648                 .augmentation(
649                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
650                         .TerminationPoint1.class)
651                 .getXpdrTpPortConnectionAttributes()
652                 .getTsPool(),
653             not(hasItem(Uint16.valueOf(1))));
654         assertThat(
655             "trib slot 2 should always be present in Trib slot list",
656             topoShard.getTps().get(0)
657                 .augmentation(
658                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
659                         .TerminationPoint1.class)
660                 .getXpdrTpPortConnectionAttributes().getTsPool(),
661             hasItem(Uint16.valueOf(2)));
662         assertEquals(
663             "after 1G creation, 1 (over 80) trib port should be occupied",
664             79,
665             topoShard.getTps().get(0)
666                 .augmentation(
667                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
668                         .TerminationPoint1.class)
669                 .getXpdrTpPortConnectionAttributes()
670                 .getOdtuTpnPool().values().stream().findFirst()
671                 .get()
672                 .getTpnPool()
673                 .size());
674         assertThat(
675             "trib port 1 should no longer be present in Trib port list",
676             topoShard.getTps().get(0)
677                 .augmentation(
678                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
679                         .TerminationPoint1.class)
680                 .getXpdrTpPortConnectionAttributes()
681                 .getOdtuTpnPool().values().stream().findFirst()
682                 .get()
683                 .getTpnPool(),
684             not(hasItem(Uint16.valueOf(1))));
685
686         // tests update for 1G deletion
687         sortedLinks.clear();
688         topoShard =
689             OpenRoadmOtnTopology.updateOtnLinks(
690                     topoShard.getLinks(),
691                     topoShard.getTps(),
692                     "1G", (short)1, (short)1, true);
693         sortedLinks = topoShard.getLinks().stream()
694             .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
695             .collect(Collectors.toList());
696         assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
697         assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
698         assertEquals(
699             "after 1G deletion, available BW of supported ODU4 should be 100 000",
700             Uint32.valueOf(100000),
701             sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
702         assertEquals(
703             "after 1G deletion, used BW of supported ODU4 should be 0",
704             Uint32.valueOf(0),
705             sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
706
707         assertEquals(
708             "after 1G deletion, trib slot list should be full",
709             80,
710             topoShard.getTps().get(0)
711                 .augmentation(
712                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
713                         .TerminationPoint1.class)
714                 .getXpdrTpPortConnectionAttributes()
715                 .getTsPool()
716                 .size());
717         assertThat(
718             "after 1G deletion, trib slot list should contain items 1 and 2",
719             topoShard.getTps().get(0)
720                 .augmentation(
721                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
722                     .TerminationPoint1.class)
723                 .getXpdrTpPortConnectionAttributes()
724                 .getTsPool(),
725             hasItems(Uint16.valueOf(1), Uint16.valueOf(2)));
726         assertEquals(
727             "after 1G deletion, trib port list should be full",
728             80,
729             topoShard.getTps().get(0)
730                 .augmentation(
731                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
732                         .TerminationPoint1.class)
733                 .getXpdrTpPortConnectionAttributes()
734                 .getOdtuTpnPool().values().stream().findFirst()
735                 .get()
736                 .getTpnPool()
737                 .size());
738         assertThat(
739             "after 1G deletion, trib port list should contain items 1",
740             topoShard.getTps().get(0)
741                 .augmentation(
742                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
743                         .TerminationPoint1.class)
744                 .getXpdrTpPortConnectionAttributes()
745                 .getOdtuTpnPool().values().stream().findFirst()
746                 .get()
747                 .getTpnPool(),
748             hasItem(Uint16.valueOf(1)));
749     }
750
751     @Test
752     public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() {
753         List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000);
754         List<Link> odu4LinksWithBadBWParam = new ArrayList<>();
755         for (Link link : odu4Links) {
756             odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
757         }
758         TopologyShard topoShard =
759             OpenRoadmOtnTopology.updateOtnLinks(
760                     odu4LinksWithBadBWParam,
761                     NetworkmodelTestUtil.createTpList(true),
762                     "1G", (short)1, (short)1, false);
763         assertNotNull("TopologyShard should never be null", topoShard);
764         assertNull("list of nodes should be null", topoShard.getNodes());
765         assertNull("list of links should be null", topoShard.getLinks());
766         assertNull("list of tps should be null", topoShard.getTps());
767     }
768
769     @Test
770     public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() {
771         List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 8000);
772         TopologyShard topoShard =
773             OpenRoadmOtnTopology.updateOtnLinks(
774                     odu4LinksWithBadBWParam,
775                     NetworkmodelTestUtil.createTpList(true),
776                     "10G", (short)1, (short)1, false);
777         assertNotNull("TopologyShard should never be null", topoShard);
778         assertNull("list of nodes should be null", topoShard.getNodes());
779         assertNull("list of links should be null", topoShard.getLinks());
780         assertNull("list of tps should be null", topoShard.getTps());
781     }
782
783     private void checkSpdrNode(Node node) {
784         Uint16 xpdrNb = node
785             .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class)
786             .getXpdrAttributes().getXpdrNumber();
787         assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue());
788         if (xpdrNb.equals(Uint16.valueOf(1))) {
789             assertEquals(OpenroadmNodeType.MUXPDR, node.augmentation(Node1.class).getNodeType());
790         } else if (xpdrNb.equals(Uint16.valueOf(2))) {
791             assertEquals(OpenroadmNodeType.SWITCH, node.augmentation(Node1.class).getNodeType());
792         }
793         // tests supporting nodes
794         List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
795             .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
796             .collect(Collectors.toList());
797         assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
798         assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
799         assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue());
800         assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
801         assertEquals("SPDR-SA1", supportingNodes.get(1).getNodeRef().getValue());
802         assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
803         assertEquals("SPDR-SA1-XPDR" + xpdrNb, supportingNodes.get(2).getNodeRef().getValue());
804         checkSpdrSwitchingPools(
805             xpdrNb,
806             node.augmentation(
807                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class)
808                 .getSwitchingPools());
809         List<TerminationPoint> tpList = node.augmentation(
810                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
811             .nonnullTerminationPoint().values().stream()
812             .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
813             .collect(Collectors.toList());
814         checkSpdrTpList(xpdrNb, tpList);
815     }
816
817     private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) {
818         List<OduSwitchingPools> oduSwitchingPools = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
819         assertEquals(
820             "switching-pools augmentation should contain a single odu-switching-pools",
821             1,
822             oduSwitchingPools.size());
823         assertEquals(
824             "switching-pool-number should be 1",
825             Uint16.valueOf(1),
826             oduSwitchingPools.get(0).getSwitchingPoolNumber());
827         assertEquals(
828             "switching-pool-type should be non-blocking",
829             "non-blocking",
830             oduSwitchingPools.get(0).getSwitchingPoolType().getName());
831
832         List<NonBlockingList> nonBlockingList =
833                 new ArrayList<>(oduSwitchingPools.get(0).nonnullNonBlockingList().values());
834         if (xpdrNb.equals(Uint16.valueOf(1))) {
835             assertEquals(
836                 "Mux should contain 4 non blocking list",
837                 4,
838                 nonBlockingList.size());
839             assertEquals(
840                 Uint16.valueOf(1),
841                 nonBlockingList.get(0).getNblNumber());
842             List<NonBlockingList> nblList = oduSwitchingPools.get(0).nonnullNonBlockingList().values().stream()
843                 .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber()))
844                 .collect(Collectors.toList());
845             for (NonBlockingList nbl : nblList) {
846                 assertEquals(
847                     "for a 10G mux, interconnect BW should be 10G",
848                     Uint32.valueOf(10),
849                     nbl.getAvailableInterconnectBandwidth());
850                 assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit());
851                 assertThat(
852                     "for a 10G mux, non blocking list should contain 2 entries (client + network ports)",
853                     nbl.getTpList(),
854                     hasSize(2));
855                 String nb = nbl.getNblNumber().toString();
856                 assertThat(
857                     nbl.getTpList(),
858                     containsInAnyOrder(new TpId("XPDR1-NETWORK1"),
859                         new TpId("XPDR1-CLIENT" + nb)));
860             }
861         } else if (xpdrNb.equals(Uint16.valueOf(2))) {
862             assertEquals(
863                 "Switch should contain a single non blocking list",
864                 1,
865                 nonBlockingList.size());
866             assertEquals(
867                 Uint16.valueOf(1),
868                 nonBlockingList.get(0).getNblNumber());
869             assertThat(
870                 "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)",
871                 nonBlockingList.get(0).getTpList(),
872                 hasSize(8));
873             assertThat(
874                 nonBlockingList.get(0).getTpList(),
875                 containsInAnyOrder(
876                     new TpId("XPDR2-CLIENT1"), new TpId("XPDR2-NETWORK1"), new TpId("XPDR2-CLIENT2"),
877                     new TpId("XPDR2-NETWORK2"), new TpId("XPDR2-CLIENT3"), new TpId("XPDR2-NETWORK3"),
878                     new TpId("XPDR2-CLIENT4"), new TpId("XPDR2-NETWORK4")));
879         }
880     }
881
882     private void checkSpdrTpList(Uint16 xpdrNb, List<TerminationPoint> tpList) {
883         assertEquals(
884             "only IfOCHOTU4ODU4 interface capabitily expected",
885             IfOCHOTU4ODU4.class,
886             tpList.get(4)
887                 .augmentation(
888                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
889                         .TerminationPoint1.class)
890                 .getTpSupportedInterfaces()
891                 .getSupportedInterfaceCapability().values().stream().findFirst()
892                 .get()
893                 .getIfCapType());
894         assertEquals(
895             "the rate should be ODU4",
896             ODU4.class,
897             tpList.get(4)
898                 .augmentation(
899                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
900                         .TerminationPoint1.class)
901                 .getXpdrTpPortConnectionAttributes()
902                 .getRate());
903         assertEquals(
904             "openroadm-topology",
905             tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
906             .get().getNetworkRef().getValue());
907         assertEquals(
908             "SPDR-SA1-XPDR" + xpdrNb,
909             tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
910             .get().getNodeRef().getValue());
911         assertEquals(
912             "XPDR" + xpdrNb + "-NETWORK1",
913             tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
914             .get().getTpRef().toString());
915         if (xpdrNb.equals(Uint16.valueOf(1))) {
916             assertEquals("should contain 5 TPs", 5, tpList.size());
917             assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
918             assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue());
919             assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue());
920             assertEquals(
921                 "supported interface capability of tp-id XPDR1-CLIENT2 should contain 2 if-cap-type",
922                 2,
923                 tpList.get(1)
924                     .augmentation(
925                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
926                             .TerminationPoint1.class)
927                     .getTpSupportedInterfaces()
928                     .getSupportedInterfaceCapability().values().size());
929             assertEquals(
930                 "supported interface capability of tp-id XPDR1-CLIENT1 should contain 3 if-cap-type",
931                 3,
932                 tpList.get(0)
933                     .augmentation(
934                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
935                             .TerminationPoint1.class)
936                     .getTpSupportedInterfaces()
937                     .getSupportedInterfaceCapability().values().size());
938             List<SupportedInterfaceCapability> sicListClient3 = tpList.get(2)
939                 .augmentation(
940                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
941                     .TerminationPoint1.class)
942                 .getTpSupportedInterfaces()
943                 .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList());
944             for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) {
945                 assertThat("tp should have 2 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2",
946                     String.valueOf(supportedInterfaceCapability.getIfCapType()),
947                     either(containsString(String.valueOf(If10GEODU2e.class)))
948                     .or(containsString(String.valueOf(If10GEODU2.class))));
949             }
950             List<SupportedInterfaceCapability> sicListClient1 = tpList.get(0)
951                 .augmentation(
952                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
953                     .TerminationPoint1.class)
954                 .getTpSupportedInterfaces()
955                 .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList());
956             for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient1) {
957                 assertThat("tp should have 3 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2, if-10GE",
958                     String.valueOf(supportedInterfaceCapability.getIfCapType()),
959                     either(containsString(String.valueOf(If10GEODU2e.class)))
960                     .or(containsString(String.valueOf(If10GEODU2.class)))
961                     .or(containsString(String.valueOf(If10GE.class))));
962             }
963             assertEquals(
964                 "the rate should be ODU2e",
965                 ODU2e.class,
966                 tpList.get(2)
967                     .augmentation(
968                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
969                             .TerminationPoint1.class)
970                     .getXpdrTpPortConnectionAttributes()
971                     .getRate());
972             assertEquals(
973                 "TP should be of type client",
974                 OpenroadmTpType.XPONDERCLIENT,
975                 tpList.get(2)
976                     .augmentation(
977                         org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
978                             .TerminationPoint1.class)
979                     .getTpType());
980             assertEquals(
981                 "TP should be of type network",
982                 OpenroadmTpType.XPONDERNETWORK,
983                 tpList.get(4)
984                     .augmentation(
985                         org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
986                             .TerminationPoint1.class)
987                     .getTpType());
988         } else if (xpdrNb.equals(Uint16.valueOf(2))) {
989             assertEquals("should contain 8 TPs", 8, tpList.size());
990             assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue());
991             assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue());
992             assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue());
993             assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue());
994             assertEquals(
995                 "only IfOCHOTU4ODU4 interface capabitily expected",
996                 IfOCHOTU4ODU4.class,
997                 tpList.get(5)
998                     .augmentation(
999                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
1000                                 .TerminationPoint1.class)
1001                     .getTpSupportedInterfaces()
1002                     .getSupportedInterfaceCapability().values().stream().findFirst()
1003                     .get()
1004                     .getIfCapType());
1005             assertEquals(
1006                 "supported interface capability of tp should contain 2 IfCapType",
1007                 2,
1008                 tpList.get(2)
1009                     .augmentation(
1010                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
1011                             .TerminationPoint1.class)
1012                     .getTpSupportedInterfaces()
1013                     .getSupportedInterfaceCapability().values().size());
1014             List<SupportedInterfaceCapability> sicListClient3 = tpList.get(2)
1015                 .augmentation(
1016                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
1017                     .TerminationPoint1.class)
1018                 .getTpSupportedInterfaces()
1019                 .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList());
1020             for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) {
1021                 assertThat("tp should have 2 if-cap-type: if-100GE-ODU4, if-100GE",
1022                     String.valueOf(supportedInterfaceCapability.getIfCapType()),
1023                     either(containsString(String.valueOf(If100GEODU4.class)))
1024                     .or(containsString(String.valueOf(If100GE.class))));
1025             }
1026             assertEquals(
1027                 "TP should be of type client", OpenroadmTpType.XPONDERCLIENT,
1028                 tpList.get(2)
1029                     .augmentation(
1030                         org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
1031                             .TerminationPoint1.class)
1032                     .getTpType());
1033             assertEquals(
1034                 "TP should be of type network", OpenroadmTpType.XPONDERNETWORK,
1035                 tpList.get(6)
1036                     .augmentation(
1037                         org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
1038                             .TerminationPoint1.class)
1039                     .getTpType());
1040         }
1041     }
1042 }