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