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