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