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