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