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