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