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