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