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