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