bda081ce670d36c476153fcda867ae9a2feef659
[transportpce.git] / tapi / src / test / java / org / opendaylight / transportpce / tapi / topology / ConvertORTopoToTapiTopoTest.java
1 /*
2  * Copyright © 2020 Orange, 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.tapi.topology;
9
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.CoreMatchers.either;
12 import static org.hamcrest.CoreMatchers.hasItem;
13 import static org.hamcrest.CoreMatchers.hasItems;
14 import static org.hamcrest.MatcherAssert.assertThat;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16 import static org.junit.jupiter.api.Assertions.assertNull;
17 import static org.junit.jupiter.api.Assertions.fail;
18
19 import com.google.common.util.concurrent.FluentFuture;
20 import java.nio.charset.Charset;
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.Optional;
27 import java.util.UUID;
28 import java.util.concurrent.ExecutionException;
29 import java.util.stream.Collectors;
30 import org.eclipse.jdt.annotation.Nullable;
31 import org.junit.jupiter.api.BeforeAll;
32 import org.junit.jupiter.api.Test;
33 import org.opendaylight.mdsal.binding.api.DataBroker;
34 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
35 import org.opendaylight.transportpce.common.InstanceIdentifiers;
36 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
37 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
38 import org.opendaylight.transportpce.tapi.TapiStringConstants;
39 import org.opendaylight.transportpce.tapi.utils.TapiLink;
40 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
41 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
42 import org.opendaylight.transportpce.test.AbstractTest;
43 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1Builder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1Builder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmTpType;
51 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
52 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
53 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeBuilder;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeKey;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1;
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.LinkKey;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointBuilder;
65 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointKey;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LAYERPROTOCOLQUALIFIER;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2E;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU4;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE100GigE;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE10GigELAN;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
96 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
97 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
98 import org.opendaylight.yangtools.yang.common.Decimal64;
99 import org.opendaylight.yangtools.yang.common.Uint64;
100 import org.slf4j.Logger;
101 import org.slf4j.LoggerFactory;
102
103
104 public class ConvertORTopoToTapiTopoTest extends AbstractTest {
105     private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoToTapiTopoTest.class);
106
107     private static Node otnMuxA;
108     private static Node otnMuxC;
109     private static Node otnSwitch;
110     private static Node tpdr100G;
111     private static Map<LinkKey,org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
112         .networks.network.Link> otnLinks;
113     private static Uuid topologyUuid;
114     private static NetworkTransactionService networkTransactionService;
115     private static TapiLink tapiLink;
116     private static DataBroker dataBroker = getDataBroker();
117
118     @BeforeAll
119     static void setUp() throws InterruptedException, ExecutionException {
120         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
121             TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
122         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
123             TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
124         TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
125             TapiTopologyDataUtils.PORTMAPPING_FILE);
126
127         KeyedInstanceIdentifier<Node, NodeKey> muxAIID = InstanceIdentifier.create(Networks.class)
128             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
129                 .class, new NetworkKey(new NetworkId("otn-topology")))
130             .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1")));
131         FluentFuture<Optional<Node>> muxAFuture = dataBroker.newReadOnlyTransaction()
132             .read(LogicalDatastoreType.CONFIGURATION, muxAIID);
133         KeyedInstanceIdentifier<Node, NodeKey> muxCIID = InstanceIdentifier.create(Networks.class)
134             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
135                 .class, new NetworkKey(new NetworkId("otn-topology")))
136             .child(Node.class, new NodeKey(new NodeId("SPDR-SC1-XPDR1")));
137         FluentFuture<Optional<Node>> muxCFuture = dataBroker.newReadOnlyTransaction()
138             .read(LogicalDatastoreType.CONFIGURATION, muxCIID);
139         KeyedInstanceIdentifier<Node, NodeKey> switchIID = InstanceIdentifier.create(Networks.class)
140             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
141                 .class, new NetworkKey(new NetworkId("otn-topology")))
142             .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2")));
143         FluentFuture<Optional<Node>> switchFuture = dataBroker.newReadOnlyTransaction()
144             .read(LogicalDatastoreType.CONFIGURATION, switchIID);
145
146         otnMuxA = muxAFuture.get().orElseThrow();
147         otnMuxC = muxCFuture.get().orElseThrow();
148         otnSwitch = switchFuture.get().orElseThrow();
149
150         KeyedInstanceIdentifier<Node, NodeKey> tpdrIID = InstanceIdentifier.create(Networks.class)
151             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
152                 .class, new NetworkKey(new NetworkId("otn-topology")))
153             .child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1")));
154         FluentFuture<Optional<Node>> tpdrFuture = dataBroker.newReadOnlyTransaction()
155             .read(LogicalDatastoreType.CONFIGURATION, tpdrIID);
156         tpdr100G = tpdrFuture.get().orElseThrow();
157
158         InstanceIdentifier<Network1> linksIID = InstanceIdentifier.create(Networks.class)
159             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
160                 .class, new NetworkKey(new NetworkId("otn-topology")))
161             .augmentation(Network1.class);
162         FluentFuture<Optional<Network1>> linksFuture = dataBroker.newReadOnlyTransaction()
163             .read(LogicalDatastoreType.CONFIGURATION, linksIID);
164         otnLinks = linksFuture.get().orElseThrow().getLink();
165
166         topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
167             Charset.forName("UTF-8"))).toString());
168         networkTransactionService = new NetworkTransactionImpl(getDataBroker());
169         tapiLink = new TapiLinkImpl(networkTransactionService);
170         LOG.info("TEST SETUP READY");
171     }
172
173     @Test
174     void convertNodeWhenNoStates() {
175         Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", null, null);
176         List<String> networkPortList = new ArrayList<>();
177         for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
178             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
179                 networkPortList.add(tp.getTpId().getValue());
180             }
181         }
182         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
183         tapiFactory.convertNode(tpdr, networkPortList);
184
185         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
186             .toString());
187         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
188             .getTapiNodes().get(new
189                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
190         Uuid networkNepUuid = new Uuid(
191             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
192                 .toString());
193         OwnedNodeEdgePoint nepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(networkNepUuid));
194         assertNull(nepN.getAdministrativeState(), "Administrative State should not be present");
195         assertNull(nepN.getOperationalState(), "Operational State should not be present");
196
197     }
198
199     @Test
200     void convertNodeWhenBadStates1() {
201         Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.OutOfService,
202             State.OutOfService);
203         List<String> networkPortList = new ArrayList<>();
204         for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
205             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
206                 networkPortList.add(tp.getTpId().getValue());
207             }
208         }
209         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
210         tapiFactory.convertNode(tpdr, networkPortList);
211
212         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
213             .toString());
214         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
215             .getTapiNodes().get(new
216                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
217         Uuid networkNepUuid = new Uuid(
218             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
219                 .toString());
220         OwnedNodeEdgePoint nepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(networkNepUuid));
221         assertEquals(AdministrativeState.LOCKED, nepN.getAdministrativeState(),
222             "Administrative State should be Locked");
223         assertEquals(OperationalState.DISABLED, nepN.getOperationalState(), "Operational State should be Disabled");
224     }
225
226     @Test
227     void convertNodeWhenBadStates2() {
228         Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.Maintenance,
229             State.Degraded);
230         List<String> networkPortList = new ArrayList<>();
231         for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
232             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
233                 networkPortList.add(tp.getTpId().getValue());
234             }
235         }
236         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
237         tapiFactory.convertNode(tpdr, networkPortList);
238
239         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
240             .toString());
241         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
242             .getTapiNodes().get(new
243                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
244         Uuid networkNepUuid = new Uuid(
245             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
246                 .toString());
247         OwnedNodeEdgePoint nepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(networkNepUuid));
248         assertEquals(AdministrativeState.LOCKED, nepN.getAdministrativeState(),
249             "Administrative State should be Locked");
250         assertEquals(OperationalState.DISABLED, nepN.getOperationalState(), "Operational State should be Disabled");
251     }
252
253     @Test
254     void convertOtnLinkWhenNoState() {
255         HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
256             .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
257         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
258             link = changeOtnLinkState(otnLinks.get(new LinkKey(
259                 new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))), null, null);
260         otnLinksAlt.replace(link.key(), link);
261
262         List<String> networkPortListA = new ArrayList<>();
263         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
264             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
265                 networkPortListA.add(tp.getTpId().getValue());
266             }
267         }
268         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
269         ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
270         tapiFactory.convertNode(otnMuxA, networkPortListA);
271         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
272         List<String> networkPortListC = new ArrayList<>();
273         for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
274             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
275                 networkPortListC.add(tp.getTpId().getValue());
276             }
277         }
278         tapiFactory.convertNode(otnMuxC, networkPortListC);
279         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
280         tapiAbsFactory.convertLinks(otnLinksAlt);
281
282         List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
283             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
284             .collect(Collectors.toList());
285         assertNull(tapiLinks.get(1).getAdministrativeState(), "Administrative State should not be present");
286         assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
287             "Administrative state should be UNLOCKED");
288         assertNull(tapiLinks.get(1).getOperationalState(), "Operational State should not be present");
289         assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
290             "Operational state should be ENABLED");
291     }
292
293     @Test
294     void convertOtnLinkWhenNoStateOnOppositeLink() {
295         HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
296             .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
297         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
298             link = changeOtnLinkState(otnLinks.get(new LinkKey(
299                 new LinkId("ODTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1"))), null, null);
300         otnLinksAlt.replace(link.key(), link);
301
302         List<String> networkPortListA = new ArrayList<>();
303         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
304             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
305                 networkPortListA.add(tp.getTpId().getValue());
306             }
307         }
308         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
309         ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
310         tapiFactory.convertNode(otnMuxA, networkPortListA);
311         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
312         List<String> networkPortListC = new ArrayList<>();
313         for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
314             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
315                 networkPortListC.add(tp.getTpId().getValue());
316             }
317         }
318         tapiFactory.convertNode(otnMuxC, networkPortListC);
319         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
320         tapiAbsFactory.convertLinks(otnLinksAlt);
321
322         List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
323             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
324             .collect(Collectors.toList());
325         assertNull(tapiLinks.get(1).getAdministrativeState(), "Administrative State should not be present");
326         assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
327             "Administrative state should be UNLOCKED");
328         assertNull(tapiLinks.get(1).getOperationalState(), "Operational State should not be present");
329         assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
330             "Operational state should be ENABLED");
331     }
332
333     @Test
334     void convertOtnLinkWhenBadState1() {
335         HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
336             .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
337         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
338             link = changeOtnLinkState(otnLinks.get(new LinkKey(
339                 new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))),
340                 AdminStates.OutOfService, State.OutOfService);
341         otnLinksAlt.replace(link.key(), link);
342         List<String> networkPortListA = new ArrayList<>();
343         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
344             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
345                 networkPortListA.add(tp.getTpId().getValue());
346             }
347         }
348         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
349         ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
350         tapiFactory.convertNode(otnMuxA, networkPortListA);
351         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
352         List<String> networkPortListC = new ArrayList<>();
353         for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
354             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
355                 networkPortListC.add(tp.getTpId().getValue());
356             }
357         }
358         tapiFactory.convertNode(otnMuxC, networkPortListC);
359         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
360         tapiAbsFactory.convertLinks(otnLinksAlt);
361
362         List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
363             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
364             .collect(Collectors.toList());
365         LOG.info("TapiLinks are as follow : {}", tapiLinks.toString());
366         assertEquals(AdministrativeState.LOCKED, tapiLinks.get(1).getAdministrativeState(),
367             "Administrative state should be LOCKED");
368         assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
369             "Administrative state should be UNLOCKED");
370         assertEquals(OperationalState.DISABLED, tapiLinks.get(1).getOperationalState(),
371             "Operational state should be DISABLED");
372         assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
373             "Operational state should be ENABLED");
374     }
375
376     @Test
377     void convertOtnLinkWhenBadState2() {
378         HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
379             .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
380         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
381             link = changeOtnLinkState(otnLinks.get(new LinkKey(
382                 new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))),
383                 AdminStates.Maintenance, State.Degraded);
384         otnLinksAlt.replace(link.key(), link);
385         List<String> networkPortListA = new ArrayList<>();
386         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
387             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
388                 networkPortListA.add(tp.getTpId().getValue());
389             }
390         }
391         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
392         ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
393         tapiFactory.convertNode(otnMuxA, networkPortListA);
394         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
395         List<String> networkPortListC = new ArrayList<>();
396         for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
397             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
398                 networkPortListC.add(tp.getTpId().getValue());
399             }
400         }
401         tapiFactory.convertNode(otnMuxC, networkPortListC);
402         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
403         tapiAbsFactory.convertLinks(otnLinksAlt);
404
405         List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
406             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
407             .collect(Collectors.toList());
408         assertEquals(AdministrativeState.LOCKED, tapiLinks.get(1).getAdministrativeState(),
409             "Administrative state should be LOCKED");
410         assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
411             "Administrative state should be UNLOCKED");
412         assertEquals(OperationalState.DISABLED, tapiLinks.get(1).getOperationalState(),
413             "Operational state should be DISABLED");
414         assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
415             "Operational state should be ENABLED");
416     }
417
418     @Test
419     void convertOtnLinkWhenBadStateOnOppositeLink() {
420         HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
421             .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
422         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
423             link = changeOtnLinkState(otnLinks.get(new LinkKey(
424                 new LinkId("ODTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1"))),
425                 AdminStates.OutOfService, State.OutOfService);
426         otnLinksAlt.replace(link.key(), link);
427         List<String> networkPortListA = new ArrayList<>();
428         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
429             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
430                 networkPortListA.add(tp.getTpId().getValue());
431             }
432         }
433         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
434         ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
435         tapiFactory.convertNode(otnMuxA, networkPortListA);
436         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
437         List<String> networkPortListC = new ArrayList<>();
438         for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
439             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
440                 networkPortListC.add(tp.getTpId().getValue());
441             }
442         }
443         tapiFactory.convertNode(otnMuxC, networkPortListC);
444         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
445         tapiAbsFactory.convertLinks(otnLinksAlt);
446
447         List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
448             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
449             .collect(Collectors.toList());
450         assertEquals(AdministrativeState.LOCKED, tapiLinks.get(1).getAdministrativeState(),
451             "Administrative state should be LOCKED");
452         assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
453             "Administrative state should be UNLOCKED");
454         assertEquals(OperationalState.DISABLED, tapiLinks.get(1).getOperationalState(),
455             "Operational state should be DISABLED");
456         assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
457             "Operational state should be ENABLED");
458     }
459
460     @Test
461     void convertNodeForTransponder100G() {
462         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
463         List<String> networkPortList = new ArrayList<>();
464         for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
465             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
466                 networkPortList.add(tp.getTpId().getValue());
467             }
468         }
469         tapiFactory.convertNode(tpdr100G, networkPortList);
470         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
471             = tapiFactory.getTapiNodes().values().stream()
472             .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
473             .collect(Collectors.toList());
474
475         assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
476         assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 (no more transitional links)");
477
478         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
479             .toString());
480         checkDsrNode(tapiNodes.get(getNodeRank("SPDR-SA1", tapiNodes)), dsrNodeUuid, "tpdr", "XPDR-A1-XPDR1+XPONDER");
481     }
482
483     @Test
484     void convertNodeForOtnMuxponder() {
485         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
486         List<String> networkPortList = new ArrayList<>();
487         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
488             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
489                 networkPortList.add(tp.getTpId().getValue());
490             }
491         }
492         tapiFactory.convertNode(otnMuxA, networkPortList);
493         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
494             = tapiFactory.getTapiNodes().values().stream()
495             .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
496             .collect(Collectors.toList());
497
498         assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR & ODU merged");
499         assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0, no more transitional links");
500         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
501             .toString());
502         checkDsrNode(tapiNodes.get(getNodeRank("SPDR-SA1", tapiNodes)), dsrNodeUuid, "mux", "SPDR-SA1-XPDR1+XPONDER");
503     }
504
505     @Test
506     void convertNodeForOtnSwitch() {
507         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
508         List<String> networkPortList = new ArrayList<>();
509         for (TerminationPoint tp : otnSwitch.augmentation(Node1.class).getTerminationPoint().values()) {
510             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
511                 networkPortList.add(tp.getTpId().getValue());
512             }
513         }
514         tapiFactory.convertNode(otnSwitch, networkPortList);
515         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
516             = tapiFactory.getTapiNodes().values().stream()
517             .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
518             .collect(Collectors.toList());
519
520         assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR/ODU merged)");
521         assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
522
523         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+XPONDER".getBytes(Charset.forName("UTF-8")))
524             .toString());
525         checkDsrNode(tapiNodes.get(getNodeRank("SPDR-SA1", tapiNodes)), dsrNodeUuid, "switch",
526             "SPDR-SA1-XPDR2+XPONDER");
527     }
528
529     @Test
530     void convertOtnLink() {
531         List<String> networkPortListA = new ArrayList<>();
532         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
533             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
534                 networkPortListA.add(tp.getTpId().getValue());
535             }
536         }
537         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
538         ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
539         tapiFactory.convertNode(otnMuxA, networkPortListA);
540         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
541         List<String> networkPortListC = new ArrayList<>();
542         for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
543             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
544                 networkPortListC.add(tp.getTpId().getValue());
545             }
546         }
547         tapiFactory.convertNode(otnMuxC, networkPortListC);
548         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
549
550         tapiAbsFactory.convertLinks(otnLinks);
551         assertEquals(2, tapiAbsFactory.getTapiLinks().size(), "Link list size should be 2 : no transitional link");
552
553         Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
554             .toString());
555         Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
556             .toString());
557         Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
558             .toString());
559         Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
560             .toString());
561         Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1"
562             .getBytes(Charset.forName("UTF-8"))).toString());
563         Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
564             .getBytes(Charset.forName("UTF-8"))).toString());
565         Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
566             .getBytes(Charset.forName("UTF-8"))).toString());
567         Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
568             .getBytes(Charset.forName("UTF-8"))).toString());
569         Uuid link1Uuid =
570             new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
571                 .getBytes(Charset.forName("UTF-8"))).toString());
572         Uuid link2Uuid =
573             new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
574                 .getBytes(Charset.forName("UTF-8"))).toString());
575
576         List<Link> links = tapiAbsFactory.getTapiLinks().values().stream()
577             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
578             .collect(Collectors.toList());
579         LOG.info("Node3 {}, Node4 = {},", node3Uuid.toString(), node4Uuid.toString());
580         checkOtnLink(links.get(1), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link1Uuid,
581             "SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1");
582         checkOtnLink(links.get(0), node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link2Uuid,
583             "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1");
584         LOG.info("The link we check  has name {}", links.get(0).getName().toString());
585     }
586
587     @Test
588     void convertRoadmInfrastructureWhenNoXponderAttached() {
589         ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
590         tapiAbsFactory.convertRoadmInfrastructure();
591
592         assertEquals(1, tapiAbsFactory.getTapiNodes().size(), "Node list size should be 1");
593         assertEquals(0, tapiAbsFactory.getTapiLinks().size(), "Link list size should be empty");
594         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
595             = tapiAbsFactory.getTapiNodes().values().stream().collect(Collectors.toList());
596         Uuid photNodeUuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
597             .toString());
598         checkOtsiNode(tapiNodes.get(0), photNodeUuid, "infra", "ROADM-infra");
599     }
600
601     @Test
602     void convertRoadmInfrastructureWhenOtnMuxAttached() {
603         ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
604         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
605         List<String> networkPortListA = new ArrayList<>();
606         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
607             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
608                 networkPortListA.add(tp.getTpId().getValue());
609             }
610         }
611         tapiFactory.convertNode(otnMuxA, networkPortListA);
612         tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
613         tapiAbsFactory.convertRoadmInfrastructure();
614         LOG.info("ERRORLINK List of link = {}", tapiAbsFactory.getTapiLinks().toString());
615         assertEquals(2, tapiAbsFactory.getTapiNodes().size(),
616             "Node list size should be 2");
617         assertEquals(1, tapiAbsFactory.getTapiLinks().size(), "Link list size should be 1");
618
619         Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey,
620             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeMap =
621             tapiFactory.getTapiNodes();
622         nodeMap.putAll(tapiAbsFactory.getTapiNodes());
623         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
624             = nodeMap.values().stream()
625             .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
626             .collect(Collectors.toList());
627
628         Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
629             .toString());
630         checkOtsiNode(tapiNodes.get(getNodeRank("ROADM", tapiNodes)), otsiNodeUuid, "infra", "ROADM-infra");
631
632         List<Link> links = tapiAbsFactory.getTapiLinks().values().stream()
633             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
634             .collect(Collectors.toList());
635         Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
636             .toString());
637         Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
638             .toString());
639         Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
640             .getBytes(Charset.forName("UTF-8"))).toString());
641         Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("roadm node+nep+1")
642             .getBytes(Charset.forName("UTF-8"))).toString());
643         String str1 = "SPDR-SA1-XPDR1+XPONDER--SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1 and ROADM-infra-"
644             + "-NodeEdgePoint_1";
645         Uuid linkUuid =
646             new Uuid(UUID.nameUUIDFromBytes(str1.getBytes(Charset.forName("UTF-8"))).toString());
647         LOG.info("LinksCheck 0 = {} ", links.get(0).getName().toString());
648         checkOmsLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid, str1);
649     }
650
651     private void checkDsrNode(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
652                               Uuid nodeUuid, String dsrNodeType, String nodeId) {
653         assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
654         assertEquals(nodeId, node.getName().get(new NameKey("dsr/odu node name")).getValue(), "incorrect node name");
655         assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
656             "administrative state should be UNLOCKED");
657         assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
658         assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
659         assertThat("one value-name should be 'dsr/odu node name'",
660             new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
661         assertEquals(4, node.getLayerProtocolName().size(),
662             "dsr node should manage 4 protocol layers : dsr, odu, DIGITALOTN and photonic");
663         assertThat("dsr node should manage 3 protocol layers : dsr, odu and photonic",
664             node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU,
665                 LayerProtocolName.PHOTONICMEDIA));
666         List<OwnedNodeEdgePoint> nepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
667             .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint_N")))
668             .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
669             .collect(Collectors.toList());
670         List<OwnedNodeEdgePoint> nepsC;
671         switch (dsrNodeType) {
672             case "switch":
673                 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
674                     .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
675                     .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
676                     .collect(Collectors.toList());
677                 assertEquals(4, nepsN.size(), "Switch-DSR node should have 4 NEPs network");
678                 assertEquals(4, nepsC.size(), "Switch-DSR node should have 4 NEPs client");
679                 OwnedNodeEdgePoint nep1 = nepsC.get(2);
680                 Uuid client4NepUuid = new Uuid(
681                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+DSR+XPDR2-CLIENT4")
682                         .getBytes(Charset.forName("UTF-8"))).toString());
683                 checkNepClient100GSwitch(nep1, client4NepUuid, "XPDR2-CLIENT4", "NodeEdgePoint_C",
684                     otnSwitch.getNodeId().getValue(), TapiStringConstants.DSR);
685                 OwnedNodeEdgePoint nep2 = nepsN.get(3);
686                 Uuid networkNepUuid = new Uuid(
687                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iODU+XPDR2-NETWORK1")
688                         .getBytes(Charset.forName("UTF-8"))).toString());
689                 checkNepNetworkODU4(nep2, networkNepUuid, "XPDR2-NETWORK1", "iNodeEdgePoint_N",
690                     otnSwitch.getNodeId().getValue(), TapiStringConstants.I_ODU);
691                 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
692                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
693                     .collect(Collectors.toList());
694                 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
695                 break;
696             case "mux":
697                 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
698                     .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
699                     .sorted((nep3, nep4) -> nep3.getUuid().getValue().compareTo(nep4.getUuid().getValue()))
700                     .collect(Collectors.toList());
701                 assertEquals(1, nepsN.size(), "Mux-DSR node should have 1 NEP network");
702                 assertEquals(4, nepsC.size(), "Mux-DSR node should have 4 NEPs client");
703                 OwnedNodeEdgePoint nep3 = nepsC.get(2);
704                 Uuid client3NepUuid = new Uuid(
705                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+DSR+XPDR1-CLIENT3")
706                         .getBytes(Charset.forName("UTF-8"))).toString());
707                 checkNepClient10G(nep3, client3NepUuid, "XPDR1-CLIENT3", "NodeEdgePoint_C",
708                     otnMuxA.getNodeId().getValue(), TapiStringConstants.DSR);
709
710                 OwnedNodeEdgePoint nep4 = nepsN.get(0);
711                 Uuid networkNepUuid2 = new Uuid(
712                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iODU+XPDR1-NETWORK1")
713                         .getBytes(Charset.forName("UTF-8"))).toString());
714                 checkNepNetworkODU4(nep4, networkNepUuid2, "XPDR1-NETWORK1", "iNodeEdgePoint_N",
715                     otnMuxA.getNodeId().getValue(), TapiStringConstants.I_ODU);
716                 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
717                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
718                     .collect(Collectors.toList());
719                 checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, networkNepUuid2, nodeUuid);
720                 break;
721             case "tpdr":
722                 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
723                     .filter(n -> n.getName().containsKey(new NameKey("100G-tpdr")))
724                     .sorted((nep5, nep6) -> nep5.getUuid().getValue().compareTo(nep6.getUuid().getValue()))
725                     .collect(Collectors.toList());
726                 assertEquals(2, nepsN.size(), "Tpdr-DSR node should have 2 NEPs network");
727                 assertEquals(2, nepsC.size(), "Tpdr-DSR node should have 2 NEPs client");
728                 OwnedNodeEdgePoint nep5 = nepsC.get(0);
729                 Uuid client1NepUuid = new Uuid(
730                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+DSR+XPDR1-CLIENT1")
731                         .getBytes(Charset.forName("UTF-8"))).toString());
732                 checkNepClient100GTpdr(nep5, client1NepUuid, "XPDR1-CLIENT1", "100G-tpdr",
733                     tpdr100G.getNodeId().getValue(), TapiStringConstants.DSR);
734
735                 OwnedNodeEdgePoint nep6 = nepsN.get(1);
736                 Uuid networkNepUuid3 = new Uuid(
737                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iODU+XPDR1-NETWORK1")
738                         .getBytes(Charset.forName("UTF-8"))).toString());
739                 checkNepNetworkODU4(nep6, networkNepUuid3, "XPDR1-NETWORK1", "iNodeEdgePoint_N",
740                     tpdr100G.getNodeId().getValue(), TapiStringConstants.I_ODU);
741                 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
742                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
743                     .collect(Collectors.toList());
744                 checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, networkNepUuid3, nodeUuid);
745                 break;
746             default:
747                 fail();
748                 break;
749         }
750     }
751
752     private void checkOtsiNode(
753         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
754         Uuid nodeUuid, String otsiNodeType, String nodeId) {
755         assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
756         assertEquals(nodeId, node.getName().get(new NameKey("otsi node name")).getValue(), "incorrect node name");
757         assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
758             "administrative state should be UNLOCKED");
759         assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
760         assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
761         assertThat("one value-name should be 'dsr/odu node name'",
762             new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("otsi node name")));
763         assertEquals(1, node.getLayerProtocolName().size(),
764             "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
765         assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
766             "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
767         List<OwnedNodeEdgePoint> nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
768             .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
769             .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
770             .collect(Collectors.toList());
771         List<OwnedNodeEdgePoint> nepsE = node.nonnullOwnedNodeEdgePoint().values().stream()
772             .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint")))
773             .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
774             .collect(Collectors.toList());
775         switch (otsiNodeType) {
776             case "switch":
777                 assertEquals(4, nepsE.size(), "Switch-OTSi node should have 4 eNEPs");
778                 assertEquals(4, nepsI.size(), "Switch-OTSi node should have 4 iNEPs");
779                 OwnedNodeEdgePoint nep1 = nepsI.get(1);
780                 Uuid inepUuid = new Uuid(
781                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iOTSi+XPDR2-NETWORK2")
782                         .getBytes(Charset.forName("UTF-8"))).toString());
783                 checkNepOtsiNode(nep1, inepUuid, "XPDR2-NETWORK2", "iNodeEdgePoint",
784                     otnSwitch.getNodeId().getValue(), TapiStringConstants.I_OTSI);
785                 OwnedNodeEdgePoint nep2 = nepsE.get(0);
786                 Uuid enepUuid = new Uuid(
787                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2")
788                         .getBytes(Charset.forName("UTF-8"))).toString());
789                 checkNepOtsiNode(nep2, enepUuid, "XPDR2-NETWORK2", "eNodeEdgePoint",
790                     otnSwitch.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA_OTS);
791                 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
792                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
793                     .collect(Collectors.toList());
794                 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
795                 break;
796             case "mux":
797                 assertEquals(1, nepsE.size(), "Mux-OTSi node should have 1 eNEP");
798                 assertEquals(1, nepsI.size(), "Mux-OTSi node should have 1 iNEPs");
799                 OwnedNodeEdgePoint nep3 = nepsE.get(0);
800                 Uuid enepUuid2 = new Uuid(
801                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
802                         .getBytes(Charset.forName("UTF-8"))).toString());
803                 checkNepOtsiNode(nep3, enepUuid2, "XPDR1-NETWORK1", "eNodeEdgePoint",
804                     otnMuxA.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA_OTS);
805                 OwnedNodeEdgePoint nep4 = nepsI.get(0);
806                 Uuid inepUuid2 = new Uuid(
807                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iOTSi+XPDR1-NETWORK1")
808                         .getBytes(Charset.forName("UTF-8"))).toString());
809                 checkNepOtsiNode(nep4, inepUuid2, "XPDR1-NETWORK1", "iNodeEdgePoint",
810                     otnMuxA.getNodeId().getValue(), TapiStringConstants.I_OTSI);
811                 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
812                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
813                     .collect(Collectors.toList());
814                 checkNodeRuleGroupForMuxOTSi(nrgList2, enepUuid2, inepUuid2, nodeUuid);
815                 break;
816             case "tpdr":
817                 assertEquals(2, nepsE.size(), "Tpdr-OTSi node should have 2 eNEPs");
818                 assertEquals(2, nepsI.size(), "Tpdr-OTSi node should have 2 iNEPs");
819                 OwnedNodeEdgePoint nep5 = nepsE.get(0);
820                 Uuid enepUuid3 = new Uuid(
821                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
822                         .getBytes(Charset.forName("UTF-8"))).toString());
823                 checkNepOtsiNode(nep5, enepUuid3, "XPDR1-NETWORK1", "eNodeEdgePoint",
824                     tpdr100G.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA_OTS);
825                 OwnedNodeEdgePoint nep6 = nepsI.get(0);
826                 Uuid inepUuid3 = new Uuid(
827                     UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iOTSi+XPDR1-NETWORK1")
828                         .getBytes(Charset.forName("UTF-8"))).toString());
829                 checkNepOtsiNode(nep6, inepUuid3, "XPDR1-NETWORK1", "iNodeEdgePoint",
830                     tpdr100G.getNodeId().getValue(), TapiStringConstants.I_OTSI);
831                 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
832                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
833                     .collect(Collectors.toList());
834                 checkNodeRuleGroupForTpdrOTSi(nrgList3, enepUuid3, inepUuid3, nodeUuid);
835                 break;
836             default:
837                 Iterator<OwnedNodeEdgePoint> nepIterator = node.nonnullOwnedNodeEdgePoint().values().iterator();
838                 int count = 1;
839                 while (nepIterator.hasNext()) {
840                     OwnedNodeEdgePoint nep = nepIterator.next();
841                     Uuid nepUuid = new Uuid(
842                         UUID.nameUUIDFromBytes((String.join("+", "roadm node", "nep", String.valueOf(count)))
843                             .getBytes(Charset.forName("UTF-8"))).toString());
844                     checkNepOtsiRdmNode(nep, nepUuid, new StringBuilder("NodeEdgePoint_").append(count).toString(),
845                         "NodeEdgePoint name");
846                     count++;
847                 }
848                 List<NodeRuleGroup> nrgList4 = node.nonnullNodeRuleGroup().values().stream()
849                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
850                     .collect(Collectors.toList());
851                 checkNodeRuleGroupForRdmInfra(nrgList4, count - 1);
852                 break;
853         }
854     }
855
856     private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
857                                    String nodeId, String extension) {
858         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
859         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
860         Name name = nameList.get(0);
861         assertEquals(String.join("+", nodeId, extension, portName), name.getValue(),
862             "value of client nep should be '" + portName + "'");
863         assertEquals(nepName, name.getValueName(),
864             "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
865         List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
866         List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
867                 .getSupportedCepLayerProtocolQualifierInstances();
868         for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
869             lpql.add(entry.getLayerProtocolQualifier());
870         }
871         assertEquals(3, lpql.size(), "Client nep should support 3 kind of cep");
872         assertThat("client nep should support 3 kind of cep", lpql,
873             hasItems(ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, DIGITALSIGNALTYPE10GigELAN.VALUE));
874         assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR(ETH) protocol ");
875         checkCommonPartOfNep(nep, false);
876         checkSIP(nep, portName, nodeId, extension);
877     }
878
879     private void checkNepNetworkODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
880                                      String nodeId, String extension) {
881         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
882         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
883         Name name = nameList.get(0);
884         assertEquals(String.join("+", nodeId, extension, portName), name.getValue(),
885             "value of network nep should be '" + portName + "'");
886         assertEquals(nepName, name.getValueName(),
887             "value-name of network nep for '" + portName + "' should be '" + nepName + "'");
888         List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
889         List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
890                 .getSupportedCepLayerProtocolQualifierInstances();
891         for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
892             lpql.add(entry.getLayerProtocolQualifier());
893         }
894         assertEquals(1, lpql.size(), "Network nep should support 1 kind of cep");
895         assertThat("network nep should support 1 kind of cep", lpql, hasItem(ODUTYPEODU4.VALUE));
896         assertEquals(LayerProtocolName.ODU, nep.getLayerProtocolName(), "network nep should be of ODU protocol type");
897         checkCommonPartOfNep(nep, false);
898         checkSIP(nep, portName, nodeId, extension);
899     }
900
901     private void checkNodeRuleGroupForTpdrDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
902                                               Uuid nodeUuid) {
903         assertEquals(4, nrgList.size(), "transponder DSR should contain 4 node rule group (2*DSR/I_ODU+2*E_ODU/I_ODU)");
904         for (NodeRuleGroup nodeRuleGroup : nrgList) {
905             assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
906                 "each node-rule-group should contain 2 NEP for transponder DSR");
907         }
908         List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
909         assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
910             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
911             either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
912         assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
913             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
914             either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
915         assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
916             "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
917         assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
918             "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
919         List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
920         assertEquals(1, rule.size(), "node-rule-group nb 1 should contain a single rule");
921         assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
922         assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
923             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
924         assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().iterator().next(),
925             "the rule type should be 'FORWARDING'");
926     }
927
928     private void checkNodeRuleGroupForMuxDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
929                                              Uuid nodeUuid) {
930         assertEquals(8, nrgList.size(), "muxponder DSR should contain 8 node rule group (4*DSR/I_ODU + 4*E_ODU/I_ODU)");
931         for (NodeRuleGroup nodeRuleGroup : nrgList) {
932             assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
933                 "each node-rule-group should contain 2 NEP for muxponder DSR");
934         }
935         List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
936         assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
937             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
938             either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
939         assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
940             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
941             either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
942         assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
943             "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
944         assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
945             "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
946         List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
947         assertEquals(1, rule.size(), "node-rule-group nb 2 should contain a single rule");
948         assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
949         assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
950             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
951         assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().iterator().next(),
952             "the rule type should be 'FORWARDING'");
953     }
954
955     private void checkNodeRuleGroupForSwitchDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
956                                                 Uuid nodeUuid) {
957         assertEquals(2, nrgList.size(), "Switch-DSR should contain 2 node rule groups (DSR/I_ODU + E_ODU/I_ODU)");
958         assertEquals(8, nrgList.get(0).getNodeEdgePoint().size(), "Switch-DSR node-rule-group should contain 8 NEP");
959         List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
960             .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
961                 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
962             .collect(Collectors.toList());
963         assertEquals(networkNepUuid, nrg.get(6).getNodeEdgePointUuid(),
964             "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
965         assertEquals(clientNepUuid, nrg.get(5).getNodeEdgePointUuid(),
966             "in the sorted node-rule-group, nep number 6 should be XPDR2-CLIENT4");
967         assertEquals(nodeUuid, nrg.get(4).getNodeUuid(),
968             "any item of the node-rule-group should have the same nodeUuid");
969         assertEquals(nodeUuid, nrg.get(3).getNodeUuid(),
970             "any item of the node-rule-group should have the same nodeUuid");
971         @Nullable
972         List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
973         assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
974         assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
975         assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
976             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
977         assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
978             "the rule type should be 'FORWARDING'");
979     }
980
981     private void checkNodeRuleGroupForRdmInfra(List<NodeRuleGroup> nrgList, int nbNeps) {
982         assertEquals(1, nrgList.size(), "RDM infra node - OTSi should contain a single node rule groups");
983         if (nbNeps > 0) {
984             List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
985             assertEquals(nbNeps, nodeEdgePointList.size(),
986                 "RDM infra node -rule-group should contain " + nbNeps + " NEP");
987         } else {
988             assertNull(nrgList.get(0).getNodeEdgePoint(), "RDM infra node -rule-group should contain no NEP");
989         }
990         List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
991         assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
992         assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
993         assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
994             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
995         assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
996             "the rule type should be 'FORWARDING'");
997     }
998
999     private void checkNodeRuleGroupForTpdrOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1000                                                Uuid nodeUuid) {
1001         assertEquals(2, nrgList.size(), "Tpdr-OTSi should contain two node rule groups");
1002         List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1003         assertEquals(2, nodeEdgePointList.size(), "Tpdr-OTSi node-rule-group should contain 2 NEP");
1004         assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1005             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1006             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1007         assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1008             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1009             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1010         assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
1011             "any item of the node-rule-group should have the same nodeUuid");
1012         assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
1013             "any item of the node-rule-group should have the same nodeUuid");
1014         List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1015         assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1016         assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1017         assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
1018             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1019         assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
1020             "the rule type should be 'FORWARDING'");
1021     }
1022
1023     private void checkNodeRuleGroupForMuxOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1024                                               Uuid nodeUuid) {
1025         assertEquals(1, nrgList.size(), "Mux-OTSi should contain a single node rule group");
1026         List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1027         assertEquals(2, nodeEdgePointList.size(), "Mux-OTSi node-rule-group should contain 2 NEP");
1028         assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1029             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1030             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1031         assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1032             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1033             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1034         assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
1035             "any item of the node-rule-group should have the same nodeUuid");
1036         assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
1037             "any item of the node-rule-group should have the same nodeUuid");
1038         List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1039         assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1040         assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1041         assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
1042             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1043         assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
1044             "the rule type should be 'FORWARDING'");
1045     }
1046
1047     private void checkNodeRuleGroupForSwitchOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1048                                                  Uuid nodeUuid) {
1049         assertEquals(4, nrgList.size(), "Switch-OTSi should contain 4 node rule group");
1050         for (NodeRuleGroup nodeRuleGroup : nrgList) {
1051             assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
1052                 "each node-rule-group should contain 2 NEP for Switch-OTSi");
1053         }
1054         List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
1055         assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1056             nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
1057             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1058         assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1059             nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
1060             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1061         List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1062         assertEquals(nodeUuid, nodeEdgePointList0.get(0).getNodeUuid(),
1063             "any item of the node-rule-group should have the same nodeUuid");
1064         assertEquals(nodeUuid, nodeEdgePointList0.get(1).getNodeUuid(),
1065             "any item of the node-rule-group should have the same nodeUuid");
1066         List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1067         assertEquals(1, ruleList0.size(), "node-rule-group should contain a single rule");
1068         assertEquals("forward", ruleList0.get(0).getLocalId(),"local-id of the rule should be 'forward'");
1069         assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList0.get(0).getForwardingRule(),
1070             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1071         assertEquals(RuleType.FORWARDING, ruleList0.get(0).getRuleType().iterator().next(),
1072             "the rule type should be 'FORWARDING'");
1073     }
1074
1075     private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1076                                           String nodeId, String extension) {
1077         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1078         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1079         assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
1080             "value of client nep should be '" + portName + "'");
1081         assertEquals(nepName, nameList.get(0).getValueName(),
1082             "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
1083         List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
1084         List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
1085                 .getSupportedCepLayerProtocolQualifierInstances();
1086         for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
1087             lpql.add(entry.getLayerProtocolQualifier());
1088         }
1089         assertEquals(2, lpql.size(), "Client nep should support 2 kind of cep");
1090         assertThat("client nep should support 2 kind of cep", lpql,
1091             hasItems(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE));
1092         assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR(ETH) protocol");
1093         checkCommonPartOfNep(nep, false);
1094         checkSIP(nep, portName, nodeId, extension);
1095     }
1096
1097     private void checkNepClient100GTpdr(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1098                                         String nodeId, String extension) {
1099         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1100         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1101         assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
1102             "value of client nep should be '" + portName + "'");
1103         assertEquals(nepName, nameList.get(0).getValueName(),
1104             "value-name of client nep for '" + portName + "' should be 100G-tpdr'");
1105         List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
1106         List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
1107                 .getSupportedCepLayerProtocolQualifierInstances();
1108         for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
1109             lpql.add(entry.getLayerProtocolQualifier());
1110         }
1111         assertEquals(1, lpql.size(), "Client nep should support 1 kind of cep");
1112         assertThat("client nep should support 2 kind of cep", lpql, hasItems(DIGITALSIGNALTYPE100GigE.VALUE));
1113         assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR(ETH) protocol");
1114         checkCommonPartOfNep(nep, false);
1115         checkSIP(nep, portName, nodeId, extension);
1116     }
1117
1118     private void checkNepOtsiNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1119                                   String nodeId, String extension) {
1120         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1121         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1122         assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
1123             "value of OTSi nep should be '" + portName + "'");
1124         assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
1125         List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
1126         List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
1127                 .getSupportedCepLayerProtocolQualifierInstances();
1128         for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
1129             lpql.add(entry.getLayerProtocolQualifier());
1130         }
1131         assertEquals(2, lpql.size(), "OTSi nep should support 2 kind of cep");
1132         assertThat("OTSi nep should support 2 kind of cep", lpql,
1133             hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE));
1134         assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1135             "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1136         assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "OTSi nep should support one SIP");
1137         checkCommonPartOfNep(nep, false);
1138         checkSIP(nep, portName, nodeId, extension);
1139     }
1140
1141     private void checkSIP(OwnedNodeEdgePoint nep, String portName, String nodeId, String extension) {
1142         Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeId, extension, portName))
1143             .getBytes(Charset.forName("UTF-8"))).toString());
1144         assertEquals(
1145             sipUuid,
1146             nep.getMappedServiceInterfacePoint().get(new MappedServiceInterfacePointKey(sipUuid))
1147                 .getServiceInterfacePointUuid(),
1148             "service-interface-point-uuid of network nep for '" + portName + "' should be '"
1149                 + String.join("+", "SIP", portName) + "'");
1150     }
1151
1152     private void checkNepOtsiRdmNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
1153         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1154         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1155         assertEquals(portName, nameList.get(0).getValue(), "value of OTSi nep should be '" + portName + "'");
1156         assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
1157         List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
1158         List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
1159                 .getSupportedCepLayerProtocolQualifierInstances();
1160         for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
1161             lpql.add(entry.getLayerProtocolQualifier());
1162         }
1163         assertEquals(1, lpql.size(), "OTSi nep of RDM infra node should support only 1 kind of cep");
1164         assertThat("OTSi nep should support OTS cep", lpql, hasItems(PHOTONICLAYERQUALIFIEROTS.VALUE));
1165         assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1166             "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1167         assertEquals(0, nep.nonnullMappedServiceInterfacePoint().size(), "OTSi nep of RDM infra should support no SIP");
1168         checkCommonPartOfNep(nep, true);
1169     }
1170
1171     private void checkCommonPartOfNep(OwnedNodeEdgePoint nep, boolean isRdm) {
1172         assertEquals(Direction.BIDIRECTIONAL, nep.getDirection(),
1173             "link port direction should be DIRECTIONAL");
1174         assertEquals(AdministrativeState.UNLOCKED, nep.getAdministrativeState(),
1175             "administrative state should be UNLOCKED");
1176 //      TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1177 //        assertEquals(TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState(),
1178 //            "termination state should be TERMINATED BIDIRECTIONAL");
1179         assertEquals(LifecycleState.INSTALLED, nep.getLifecycleState(),
1180             "life-cycle state should be INSTALLED");
1181         if (!isRdm) {
1182             assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "client nep should support 1 SIP");
1183         }
1184 //      TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1185 //        assertEquals(TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection(),
1186 //            "termination direction should be BIDIRECTIONAL");
1187         assertEquals(OperationalState.ENABLED, nep.getOperationalState(),
1188             "operational state of client nep should be ENABLED");
1189         assertEquals(PortRole.SYMMETRIC, nep.getLinkPortRole(), "link-port-role of client nep should be SYMMETRIC");
1190     }
1191
1192     private void checkOtnLink(Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid,
1193                               String linkName) {
1194         assertEquals(linkName, link.getName().get(new NameKey("otn link name")).getValue(), "bad name for the link");
1195         assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1196         assertEquals(CAPACITYUNITGBPS.VALUE, link.getAvailableCapacity().getTotalSize().getUnit(),
1197             "Available capacity unit should be MBPS");
1198         String prefix = linkName.split("-")[0];
1199         if ("OTU4".equals(prefix)) {
1200             assertEquals(Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue(),
1201                 "Available capacity -total size value should be 0");
1202         } else if ("ODTU4".equals(prefix)) {
1203             assertEquals(Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue(),
1204                 "Available capacity -total size value should be 100 000");
1205         }
1206         assertEquals(CAPACITYUNITGBPS.VALUE, link.getTotalPotentialCapacity().getTotalSize().getUnit(),
1207             "Total capacity unit should be GBPS");
1208         assertEquals(Decimal64.valueOf("100"), link.getTotalPotentialCapacity().getTotalSize().getValue(),
1209             "Total capacity -total size value should be 100");
1210         if ("OTU4".equals(prefix)) {
1211             assertEquals(
1212                 LayerProtocolName.PHOTONICMEDIA.getName(),
1213                 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1214                 "otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1215         } else if ("ODTU4".equals(prefix)) {
1216             assertEquals(
1217                 LayerProtocolName.ODU.getName(),
1218                 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1219                 "otn link should be between 2 nodes of protocol layers ODU");
1220         }
1221         assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
1222         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1223             .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1224         LOG.info("OUTPUT: Node1UUID = {}, Node2UU2D = {},", node1Uuid.toString(), node2Uuid.toString());
1225         LOG.info("NEPLIST = {}", nodeEdgePointList.toString());
1226         assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1227             "topology uuid should be the same for the two termination point of the link");
1228         assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1229             "topology uuid should be the same for the two termination point of the link");
1230         assertThat("otn links should terminate on two distinct nodes",
1231             nodeEdgePointList.get(0).getNodeUuid().getValue(),
1232             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1233         assertThat("otn links should terminate on two distinct nodes",
1234             nodeEdgePointList.get(1).getNodeUuid().getValue(),
1235             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1236         assertThat("otn links should terminate on two distinct tps",
1237             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1238             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1239         assertThat("otn links should terminate on two distinct tps",
1240             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1241             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1242         assertEquals(OperationalState.ENABLED, link.getOperationalState(), "operational state should be ENABLED");
1243         assertEquals(AdministrativeState.UNLOCKED, link.getAdministrativeState(),
1244             "administrative state should be UNLOCKED");
1245     }
1246
1247     private void checkOmsLink(Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid,
1248                               String linkName) {
1249         assertEquals(linkName, link.getName().get(new NameKey("OTS link name")).getValue(), "bad name for the link");
1250         assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1251         assertEquals(
1252             LayerProtocolName.PHOTONICMEDIA.getName(),
1253             link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1254             "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1255         assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
1256         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1257             .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1258         assertEquals(2, nodeEdgePointList.size(), "oms link should be between 2 neps");
1259         assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1260             "topology uuid should be the same for the two termination point of the link");
1261         assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1262             "topology uuid should be the same for the two termination point of the link");
1263         assertThat("oms links should terminate on two distinct nodes",
1264             nodeEdgePointList.get(0).getNodeUuid().getValue(),
1265             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1266         assertThat("oms links should terminate on two distinct nodes",
1267             nodeEdgePointList.get(1).getNodeUuid().getValue(),
1268             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1269         assertThat("oms links should terminate on two distinct tps",
1270             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1271             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1272         assertThat("oms links should terminate on two distinct tps",
1273             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1274             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1275     }
1276
1277     private Node changeTerminationPointState(Node initialNode, String tpid, AdminStates admin, State oper) {
1278         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder tpdr1Bldr
1279             = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder(
1280             initialNode.augmentation(Node1.class));
1281         Map<TerminationPointKey, TerminationPoint> tps = new HashMap<>(tpdr1Bldr.getTerminationPoint());
1282         TerminationPointBuilder tpBldr = new TerminationPointBuilder(
1283             tps.get(new TerminationPointKey(new TpId(tpid))));
1284         TerminationPoint1Builder tp1Bldr = new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class));
1285         tp1Bldr.setAdministrativeState(admin)
1286             .setOperationalState(oper);
1287         tpBldr.addAugmentation(tp1Bldr.build());
1288         tps.replace(tpBldr.key(), tpBldr.build());
1289         tpdr1Bldr.setTerminationPoint(tps);
1290         return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.build()).build();
1291     }
1292
1293     private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
1294             .Link changeOtnLinkState(
1295             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
1296             .Link initiallink, AdminStates admin, State oper) {
1297
1298         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
1299             .LinkBuilder linkBldr = new
1300             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
1301             .LinkBuilder(initiallink);
1302         Link1Builder link1Bldr = new Link1Builder(linkBldr.augmentation(Link1.class));
1303         link1Bldr.setAdministrativeState(admin)
1304             .setOperationalState(oper);
1305         linkBldr.addAugmentation(link1Bldr.build());
1306         return linkBldr.build();
1307     }
1308
1309     private int getNodeRank(String searchedChar,
1310         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeList) {
1311         int foundAtRank = 0;
1312         int rank = 0;
1313         for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node: nodeList) {
1314             for (Map.Entry<NameKey, Name> entry: node.getName().entrySet()) {
1315                 if (entry.getValue().getValue().contains(searchedChar)) {
1316                     foundAtRank = rank;
1317                 }
1318             }
1319             rank++;
1320         }
1321         LOG.info("searched Char {} found at rank {}", searchedChar, foundAtRank);
1322         return foundAtRank;
1323     }
1324 }