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