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