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.jupiter.api.Assertions.assertEquals;
16 import static org.junit.jupiter.api.Assertions.assertNull;
17 import static org.junit.jupiter.api.Assertions.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.jupiter.api.BeforeAll;
32 import org.junit.jupiter.api.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.TapiLinkImpl;
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.rev230526.Link1;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1Builder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.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.rev230526.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 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().orElseThrow();
144 otnMuxC = muxCFuture.get().orElseThrow();
145 otnSwitch = switchFuture.get().orElseThrow();
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().orElseThrow();
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().orElseThrow().getLink();
163 topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
164 Charset.forName("UTF-8"))).toString());
165 networkTransactionService = new NetworkTransactionImpl(getDataBroker());
166 tapiLink = new TapiLinkImpl(networkTransactionService);
167 LOG.info("TEST SETUP READY");
171 void convertNodeWhenNoStates() {
172 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", null, null);
173 List<String> networkPortList = new ArrayList<>();
174 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
175 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
176 networkPortList.add(tp.getTpId().getValue());
179 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
180 tapiFactory.convertNode(tpdr, networkPortList);
182 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
184 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node dsrNode = tapiFactory
185 .getTapiNodes().get(new
186 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(dsrNodeUuid));
187 Uuid networkNepUuid = new Uuid(
188 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
190 OwnedNodeEdgePoint nepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(networkNepUuid));
191 assertNull(nepN.getAdministrativeState(), "Administrative State should not be present");
192 assertNull(nepN.getOperationalState(), "Operational State should not be present");
194 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
196 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node otsiNode = tapiFactory
197 .getTapiNodes().get(new
198 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(otsiNodeUuid));
199 Uuid enepUuid = new Uuid(
200 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
202 Uuid inepUuid = new Uuid(
203 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
205 OwnedNodeEdgePoint enep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enepUuid));
206 assertNull(enep.getAdministrativeState(), "Administrative State should not be present");
207 assertNull(enep.getOperationalState(), "Operational State should not be present");
209 OwnedNodeEdgePoint inep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inepUuid));
210 assertNull(inep.getAdministrativeState(), "Administrative State should not be present");
211 assertNull(inep.getOperationalState(), "Operational State should not be present");
215 void convertNodeWhenBadStates1() {
216 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.OutOfService,
218 List<String> networkPortList = new ArrayList<>();
219 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
220 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
221 networkPortList.add(tp.getTpId().getValue());
224 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
225 tapiFactory.convertNode(tpdr, networkPortList);
227 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
229 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node dsrNode = tapiFactory
230 .getTapiNodes().get(new
231 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(dsrNodeUuid));
232 Uuid networkNepUuid = new Uuid(
233 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
235 OwnedNodeEdgePoint nepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(networkNepUuid));
236 assertEquals(AdministrativeState.LOCKED, nepN.getAdministrativeState(),
237 "Administrative State should be Locked");
238 assertEquals(OperationalState.DISABLED, nepN.getOperationalState(), "Operational State should be Disabled");
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(AdministrativeState.LOCKED, enep.getAdministrativeState(),
253 "Administrative State should be Locked");
254 assertEquals(OperationalState.DISABLED, enep.getOperationalState(), "Operational State should be Disabled");
256 OwnedNodeEdgePoint inep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inepUuid));
257 assertEquals(AdministrativeState.LOCKED, inep.getAdministrativeState(),
258 "Administrative State should be Locked");
259 assertEquals(OperationalState.DISABLED, inep.getOperationalState(), "Operational State should be Disabled");
263 void convertNodeWhenBadStates2() {
264 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.Maintenance,
266 List<String> networkPortList = new ArrayList<>();
267 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
268 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
269 networkPortList.add(tp.getTpId().getValue());
272 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
273 tapiFactory.convertNode(tpdr, networkPortList);
275 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
277 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node dsrNode = tapiFactory
278 .getTapiNodes().get(new
279 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(dsrNodeUuid));
280 Uuid networkNepUuid = new Uuid(
281 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
283 OwnedNodeEdgePoint nepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(networkNepUuid));
284 assertEquals(AdministrativeState.LOCKED, nepN.getAdministrativeState(),
285 "Administrative State should be Locked");
286 assertEquals(OperationalState.DISABLED, nepN.getOperationalState(), "Operational State should be Disabled");
288 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
290 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node otsiNode = tapiFactory
291 .getTapiNodes().get(new
292 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(otsiNodeUuid));
293 Uuid enepUuid = new Uuid(
294 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
296 Uuid inepUuid = new Uuid(
297 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
299 OwnedNodeEdgePoint enep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enepUuid));
300 assertEquals(AdministrativeState.LOCKED, enep.getAdministrativeState(),
301 "Administrative State should be Locked");
302 assertEquals(OperationalState.DISABLED, enep.getOperationalState(), "Operational State should be Disabled");
304 OwnedNodeEdgePoint inep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inepUuid));
305 assertEquals(AdministrativeState.LOCKED, inep.getAdministrativeState(),
306 "Administrative State should be Locked");
307 assertEquals(OperationalState.DISABLED, inep.getOperationalState(), "Operational State should be Disabled");
311 void convertOtnLinkWhenNoState() {
312 HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
313 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
314 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
315 link = changeOtnLinkState(otnLinks.get(new LinkKey(
316 new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))), null, null);
317 otnLinksAlt.replace(link.key(), link);
319 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
320 List<String> networkPortListA = new ArrayList<>();
321 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
322 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
323 networkPortListA.add(tp.getTpId().getValue());
326 tapiFactory.convertNode(otnMuxA, networkPortListA);
327 List<String> networkPortListC = new ArrayList<>();
328 for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
329 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
330 networkPortListC.add(tp.getTpId().getValue());
333 tapiFactory.convertNode(otnMuxC, networkPortListC);
334 tapiFactory.convertLinks(otnLinksAlt);
336 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
337 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
338 .collect(Collectors.toList());
339 assertNull(tapiLinks.get(3).getAdministrativeState(), "Administrative State should not be present");
340 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
341 "Administrative state should be UNLOCKED");
342 assertNull(tapiLinks.get(3).getOperationalState(), "Operational State should not be present");
343 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
344 "Operational state should be ENABLED");
348 void convertOtnLinkWhenNoStateOnOppositeLink() {
349 HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
350 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
351 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
352 link = changeOtnLinkState(otnLinks.get(new LinkKey(
353 new LinkId("ODTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1"))), null, null);
354 otnLinksAlt.replace(link.key(), link);
356 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
357 List<String> networkPortListA = new ArrayList<>();
358 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
359 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
360 networkPortListA.add(tp.getTpId().getValue());
363 tapiFactory.convertNode(otnMuxA, networkPortListA);
364 List<String> networkPortListC = new ArrayList<>();
365 for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
366 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
367 networkPortListC.add(tp.getTpId().getValue());
370 tapiFactory.convertNode(otnMuxC, networkPortListC);
371 tapiFactory.convertLinks(otnLinksAlt);
373 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
374 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
375 .collect(Collectors.toList());
376 assertNull(tapiLinks.get(3).getAdministrativeState(), "Administrative State should not be present");
377 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
378 "Administrative state should be UNLOCKED");
379 assertNull(tapiLinks.get(3).getOperationalState(), "Operational State should not be present");
380 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
381 "Operational state should be ENABLED");
385 void convertOtnLinkWhenBadState1() {
386 HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
387 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
388 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
389 link = changeOtnLinkState(otnLinks.get(new LinkKey(
390 new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))),
391 AdminStates.OutOfService, State.OutOfService);
392 otnLinksAlt.replace(link.key(), link);
394 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
395 List<String> networkPortListA = new ArrayList<>();
396 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
397 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
398 networkPortListA.add(tp.getTpId().getValue());
401 tapiFactory.convertNode(otnMuxA, networkPortListA);
402 List<String> networkPortListC = new ArrayList<>();
403 for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
404 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
405 networkPortListC.add(tp.getTpId().getValue());
408 tapiFactory.convertNode(otnMuxC, networkPortListC);
409 tapiFactory.convertLinks(otnLinksAlt);
411 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
412 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
413 .collect(Collectors.toList());
414 assertEquals(AdministrativeState.LOCKED, tapiLinks.get(3).getAdministrativeState(),
415 "Administrative state should be LOCKED");
416 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
417 "Administrative state should be UNLOCKED");
418 assertEquals(OperationalState.DISABLED, tapiLinks.get(3).getOperationalState(),
419 "Operational state should be DISABLED");
420 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
421 "Operational state should be ENABLED");
425 void convertOtnLinkWhenBadState2() {
426 HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
427 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
428 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
429 link = changeOtnLinkState(otnLinks.get(new LinkKey(
430 new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))),
431 AdminStates.Maintenance, State.Degraded);
432 otnLinksAlt.replace(link.key(), link);
434 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
435 List<String> networkPortListA = new ArrayList<>();
436 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
437 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
438 networkPortListA.add(tp.getTpId().getValue());
441 tapiFactory.convertNode(otnMuxA, networkPortListA);
442 List<String> networkPortListC = new ArrayList<>();
443 for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
444 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
445 networkPortListC.add(tp.getTpId().getValue());
448 tapiFactory.convertNode(otnMuxC, networkPortListC);
449 tapiFactory.convertLinks(otnLinksAlt);
451 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
452 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
453 .collect(Collectors.toList());
454 assertEquals(AdministrativeState.LOCKED, tapiLinks.get(3).getAdministrativeState(),
455 "Administrative state should be LOCKED");
456 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
457 "Administrative state should be UNLOCKED");
458 assertEquals(OperationalState.DISABLED, tapiLinks.get(3).getOperationalState(),
459 "Operational state should be DISABLED");
460 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
461 "Operational state should be ENABLED");
465 void convertOtnLinkWhenBadStateOnOppositeLink() {
466 HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
467 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
468 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
469 link = changeOtnLinkState(otnLinks.get(new LinkKey(
470 new LinkId("ODTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1"))),
471 AdminStates.OutOfService, State.OutOfService);
472 otnLinksAlt.replace(link.key(), link);
474 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
475 List<String> networkPortListA = new ArrayList<>();
476 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
477 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
478 networkPortListA.add(tp.getTpId().getValue());
481 tapiFactory.convertNode(otnMuxA, networkPortListA);
482 List<String> networkPortListC = new ArrayList<>();
483 for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
484 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
485 networkPortListC.add(tp.getTpId().getValue());
488 tapiFactory.convertNode(otnMuxC, networkPortListC);
489 tapiFactory.convertLinks(otnLinksAlt);
491 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
492 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
493 .collect(Collectors.toList());
494 assertEquals(AdministrativeState.LOCKED, tapiLinks.get(3).getAdministrativeState(),
495 "Administrative state should be LOCKED");
496 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
497 "Administrative state should be UNLOCKED");
498 assertEquals(OperationalState.DISABLED, tapiLinks.get(3).getOperationalState(),
499 "Operational state should be DISABLED");
500 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
501 "Operational state should be ENABLED");
505 void convertNodeForTransponder100G() {
506 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
507 List<String> networkPortList = new ArrayList<>();
508 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
509 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
510 networkPortList.add(tp.getTpId().getValue());
513 tapiFactory.convertNode(tpdr100G, networkPortList);
514 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
515 = tapiFactory.getTapiNodes().values().stream()
516 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
517 .collect(Collectors.toList());
519 assertEquals(2, tapiFactory.getTapiNodes().size(), "Node list size should be 2");
520 assertEquals(2, tapiFactory.getTapiLinks().size(), "Link list size should be 2");
522 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
524 checkDsrNode(tapiNodes.get(1), dsrNodeUuid, "tpdr", "XPDR-A1-XPDR1+DSR");
525 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
527 checkOtsiNode(tapiNodes.get(0), otsiNodeUuid, "tpdr", "XPDR-A1-XPDR1+OTSi");
529 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
530 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
531 .collect(Collectors.toList());
532 checkTransitionalLink(tapiLinks.get(1), dsrNodeUuid, otsiNodeUuid,
533 "XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1", "XPDR-A1-XPDR1+iOTSi+XPDR1-NETWORK1", "XPDR-A1-XPDR1");
537 void convertNodeForOtnMuxponder() {
538 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
539 List<String> networkPortList = new ArrayList<>();
540 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
541 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
542 networkPortList.add(tp.getTpId().getValue());
545 tapiFactory.convertNode(otnMuxA, networkPortList);
546 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
547 = tapiFactory.getTapiNodes().values().stream()
548 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
549 .collect(Collectors.toList());
551 assertEquals(2, tapiFactory.getTapiNodes().size(), "Node list size should be 2");
552 assertEquals(1, tapiFactory.getTapiLinks().size(), "Link list size should be 1");
553 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
555 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "mux", "SPDR-SA1-XPDR1+DSR");
556 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
558 checkOtsiNode(tapiNodes.get(1), otsiNodeUuid, "mux", "SPDR-SA1-XPDR1+OTSi");
560 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
561 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
562 .collect(Collectors.toList());
563 checkTransitionalLink(tapiLinks.get(0), dsrNodeUuid, otsiNodeUuid,
564 "SPDR-SA1-XPDR1+iODU+XPDR1-NETWORK1", "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1", "SPDR-SA1-XPDR1");
568 void convertNodeForOtnSwitch() {
569 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
570 List<String> networkPortList = new ArrayList<>();
571 for (TerminationPoint tp : otnSwitch.augmentation(Node1.class).getTerminationPoint().values()) {
572 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
573 networkPortList.add(tp.getTpId().getValue());
576 tapiFactory.convertNode(otnSwitch, networkPortList);
577 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
578 = tapiFactory.getTapiNodes().values().stream()
579 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
580 .collect(Collectors.toList());
582 assertEquals(2, tapiFactory.getTapiNodes().size(), "Node list size should be 2");
583 assertEquals(4, tapiFactory.getTapiLinks().size(), "Link list size should be 4");
585 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+DSR".getBytes(Charset.forName("UTF-8")))
587 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "switch", "SPDR-SA1-XPDR2+DSR");
588 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+OTSi".getBytes(Charset.forName("UTF-8")))
590 checkOtsiNode(tapiNodes.get(1), otsiNodeUuid, "switch", "SPDR-SA1-XPDR2+OTSi");
592 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
593 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
594 .collect(Collectors.toList());
595 checkTransitionalLink(tapiLinks.get(2), dsrNodeUuid, otsiNodeUuid,
596 "SPDR-SA1-XPDR2+iODU+XPDR2-NETWORK4", "SPDR-SA1-XPDR2+iOTSi+XPDR2-NETWORK4", "SPDR-SA1-XPDR2");
600 void convertOtnLink() {
601 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
602 List<String> networkPortListA = new ArrayList<>();
603 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
604 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
605 networkPortListA.add(tp.getTpId().getValue());
608 tapiFactory.convertNode(otnMuxA, networkPortListA);
609 List<String> networkPortListC = new ArrayList<>();
610 for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
611 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
612 networkPortListC.add(tp.getTpId().getValue());
615 tapiFactory.convertNode(otnMuxC, networkPortListC);
616 tapiFactory.convertLinks(otnLinks);
617 assertEquals(4, tapiFactory.getTapiLinks().size(), "Link list size should be 4");
619 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
621 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
623 Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
625 Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
627 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1"
628 .getBytes(Charset.forName("UTF-8"))).toString());
629 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
630 .getBytes(Charset.forName("UTF-8"))).toString());
631 Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
632 .getBytes(Charset.forName("UTF-8"))).toString());
633 Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
634 .getBytes(Charset.forName("UTF-8"))).toString());
636 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
637 .getBytes(Charset.forName("UTF-8"))).toString());
639 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
640 .getBytes(Charset.forName("UTF-8"))).toString());
642 List<Link> links = tapiFactory.getTapiLinks().values().stream()
643 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
644 .collect(Collectors.toList());
645 checkOtnLink(links.get(3), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link1Uuid,
646 "SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1");
647 checkOtnLink(links.get(2), node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link2Uuid,
648 "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1");
652 void convertRoadmInfrastructureWhenNoXponderAttached() {
653 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
654 tapiFactory.convertRoadmInfrastructure();
656 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1");
657 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be empty");
658 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
659 = tapiFactory.getTapiNodes().values().stream().collect(Collectors.toList());
660 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
662 checkOtsiNode(tapiNodes.get(0), otsiNodeUuid, "infra", "ROADM-infra");
666 void convertRoadmInfrastructureWhenOtnMuxAttached() {
667 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
668 List<String> networkPortListA = new ArrayList<>();
669 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
670 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
671 networkPortListA.add(tp.getTpId().getValue());
674 tapiFactory.convertNode(otnMuxA, networkPortListA);
675 tapiFactory.convertRoadmInfrastructure();
677 assertEquals(3, tapiFactory.getTapiNodes().size(), "Node list size should be 3");
678 assertEquals(2, tapiFactory.getTapiLinks().size(), "Link list size should be 2");
679 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
680 = tapiFactory.getTapiNodes().values().stream()
681 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
682 .collect(Collectors.toList());
683 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
685 checkOtsiNode(tapiNodes.get(2), otsiNodeUuid, "infra", "ROADM-infra");
687 List<Link> links = tapiFactory.getTapiLinks().values().stream()
688 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
689 .collect(Collectors.toList());
690 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
692 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
694 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eOTSi+XPDR1-NETWORK1"
695 .getBytes(Charset.forName("UTF-8"))).toString());
696 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("roadm node+nep+1")
697 .getBytes(Charset.forName("UTF-8"))).toString());
699 new Uuid(UUID.nameUUIDFromBytes(
700 "SPDR-SA1-XPDR1+OTSi--SPDR-SA1-XPDR1+eOTSi+XPDR1-NETWORK1 and ROADM-infra--NodeEdgePoint_1"
701 .getBytes(Charset.forName("UTF-8"))).toString());
702 checkOmsLink(links.get(1), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
703 "SPDR-SA1-XPDR1+OTSi--SPDR-SA1-XPDR1+eOTSi+XPDR1-NETWORK1 and ROADM-infra--NodeEdgePoint_1");
706 private void checkDsrNode(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node,
707 Uuid nodeUuid, String dsrNodeType, String nodeId) {
708 assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
709 assertEquals(nodeId, node.getName().get(new NameKey("dsr/odu node name")).getValue(), "incorrect node name");
710 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
711 "administrative state should be UNLOCKED");
712 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
713 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
714 assertThat("one value-name should be 'dsr/odu node name'",
715 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
716 assertEquals(2, node.getLayerProtocolName().size(),
717 "dsr node should manage 2 protocol layers : dsr and odu");
718 assertThat("dsr node should manage 2 protocol layers : dsr and odu",
719 node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
720 List<OwnedNodeEdgePoint> nepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
721 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint_N")))
722 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
723 .collect(Collectors.toList());
724 List<OwnedNodeEdgePoint> nepsC;
725 switch (dsrNodeType) {
727 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
728 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
729 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
730 .collect(Collectors.toList());
731 assertEquals(4, nepsN.size(), "Switch-DSR node should have 4 NEPs network");
732 assertEquals(4, nepsC.size(), "Switch-DSR node should have 4 NEPs client");
733 OwnedNodeEdgePoint nep1 = nepsC.get(2);
734 Uuid client4NepUuid = new Uuid(
735 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+DSR+XPDR2-CLIENT4")
736 .getBytes(Charset.forName("UTF-8"))).toString());
737 checkNepClient100GSwitch(nep1, client4NepUuid, "XPDR2-CLIENT4", "NodeEdgePoint_C",
738 otnSwitch.getNodeId().getValue(), TapiStringConstants.DSR);
739 OwnedNodeEdgePoint nep2 = nepsN.get(3);
740 Uuid networkNepUuid = new Uuid(
741 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iODU+XPDR2-NETWORK1")
742 .getBytes(Charset.forName("UTF-8"))).toString());
743 checkNepNetworkODU4(nep2, networkNepUuid, "XPDR2-NETWORK1", "iNodeEdgePoint_N",
744 otnSwitch.getNodeId().getValue(), TapiStringConstants.I_ODU);
745 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
746 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
747 .collect(Collectors.toList());
748 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
751 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
752 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
753 .sorted((nep3, nep4) -> nep3.getUuid().getValue().compareTo(nep4.getUuid().getValue()))
754 .collect(Collectors.toList());
755 assertEquals(1, nepsN.size(), "Mux-DSR node should have 1 NEP network");
756 assertEquals(4, nepsC.size(), "Mux-DSR node should have 4 NEPs client");
757 OwnedNodeEdgePoint nep3 = nepsC.get(2);
758 Uuid client3NepUuid = new Uuid(
759 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+DSR+XPDR1-CLIENT3")
760 .getBytes(Charset.forName("UTF-8"))).toString());
761 checkNepClient10G(nep3, client3NepUuid, "XPDR1-CLIENT3", "NodeEdgePoint_C",
762 otnMuxA.getNodeId().getValue(), TapiStringConstants.DSR);
764 OwnedNodeEdgePoint nep4 = nepsN.get(0);
765 Uuid networkNepUuid2 = new Uuid(
766 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iODU+XPDR1-NETWORK1")
767 .getBytes(Charset.forName("UTF-8"))).toString());
768 checkNepNetworkODU4(nep4, networkNepUuid2, "XPDR1-NETWORK1", "iNodeEdgePoint_N",
769 otnMuxA.getNodeId().getValue(), TapiStringConstants.I_ODU);
770 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
771 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
772 .collect(Collectors.toList());
773 checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, networkNepUuid2, nodeUuid);
776 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
777 .filter(n -> n.getName().containsKey(new NameKey("100G-tpdr")))
778 .sorted((nep5, nep6) -> nep5.getUuid().getValue().compareTo(nep6.getUuid().getValue()))
779 .collect(Collectors.toList());
780 assertEquals(2, nepsN.size(), "Tpdr-DSR node should have 2 NEPs network");
781 assertEquals(2, nepsC.size(), "Tpdr-DSR node should have 2 NEPs client");
782 OwnedNodeEdgePoint nep5 = nepsC.get(0);
783 Uuid client1NepUuid = new Uuid(
784 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+DSR+XPDR1-CLIENT1")
785 .getBytes(Charset.forName("UTF-8"))).toString());
786 checkNepClient100GTpdr(nep5, client1NepUuid, "XPDR1-CLIENT1", "100G-tpdr",
787 tpdr100G.getNodeId().getValue(), TapiStringConstants.DSR);
789 OwnedNodeEdgePoint nep6 = nepsN.get(1);
790 Uuid networkNepUuid3 = new Uuid(
791 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iODU+XPDR1-NETWORK1")
792 .getBytes(Charset.forName("UTF-8"))).toString());
793 checkNepNetworkODU4(nep6, networkNepUuid3, "XPDR1-NETWORK1", "iNodeEdgePoint_N",
794 tpdr100G.getNodeId().getValue(), TapiStringConstants.I_ODU);
795 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
796 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
797 .collect(Collectors.toList());
798 checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, networkNepUuid3, nodeUuid);
806 private void checkOtsiNode(
807 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node,
808 Uuid nodeUuid, String otsiNodeType, String nodeId) {
809 assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
810 assertEquals(nodeId, node.getName().get(new NameKey("otsi node name")).getValue(), "incorrect node name");
811 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
812 "administrative state should be UNLOCKED");
813 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
814 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
815 assertThat("one value-name should be 'dsr/odu node name'",
816 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("otsi node name")));
817 assertEquals(1, node.getLayerProtocolName().size(),
818 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
819 assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
820 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
821 List<OwnedNodeEdgePoint> nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
822 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
823 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
824 .collect(Collectors.toList());
825 List<OwnedNodeEdgePoint> nepsE = node.nonnullOwnedNodeEdgePoint().values().stream()
826 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint")))
827 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
828 .collect(Collectors.toList());
829 switch (otsiNodeType) {
831 assertEquals(4, nepsE.size(), "Switch-OTSi node should have 4 eNEPs");
832 assertEquals(4, nepsI.size(), "Switch-OTSi node should have 4 iNEPs");
833 OwnedNodeEdgePoint nep1 = nepsI.get(1);
834 Uuid inepUuid = new Uuid(
835 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iOTSi+XPDR2-NETWORK2")
836 .getBytes(Charset.forName("UTF-8"))).toString());
837 checkNepOtsiNode(nep1, inepUuid, "XPDR2-NETWORK2", "iNodeEdgePoint",
838 otnSwitch.getNodeId().getValue(), TapiStringConstants.I_OTSI);
839 OwnedNodeEdgePoint nep2 = nepsE.get(0);
840 Uuid enepUuid = new Uuid(
841 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+eOTSi+XPDR2-NETWORK2")
842 .getBytes(Charset.forName("UTF-8"))).toString());
843 checkNepOtsiNode(nep2, enepUuid, "XPDR2-NETWORK2", "eNodeEdgePoint",
844 otnSwitch.getNodeId().getValue(), TapiStringConstants.E_OTSI);
845 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
846 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
847 .collect(Collectors.toList());
848 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
851 assertEquals(1, nepsE.size(), "Mux-OTSi node should have 1 eNEP");
852 assertEquals(1, nepsI.size(), "Mux-OTSi node should have 1 iNEPs");
853 OwnedNodeEdgePoint nep3 = nepsE.get(0);
854 Uuid enepUuid2 = new Uuid(
855 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+eOTSi+XPDR1-NETWORK1")
856 .getBytes(Charset.forName("UTF-8"))).toString());
857 checkNepOtsiNode(nep3, enepUuid2, "XPDR1-NETWORK1", "eNodeEdgePoint",
858 otnMuxA.getNodeId().getValue(), TapiStringConstants.E_OTSI);
859 OwnedNodeEdgePoint nep4 = nepsI.get(0);
860 Uuid inepUuid2 = new Uuid(
861 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iOTSi+XPDR1-NETWORK1")
862 .getBytes(Charset.forName("UTF-8"))).toString());
863 checkNepOtsiNode(nep4, inepUuid2, "XPDR1-NETWORK1", "iNodeEdgePoint",
864 otnMuxA.getNodeId().getValue(), TapiStringConstants.I_OTSI);
865 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
866 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
867 .collect(Collectors.toList());
868 checkNodeRuleGroupForMuxOTSi(nrgList2, enepUuid2, inepUuid2, nodeUuid);
871 assertEquals(2, nepsE.size(), "Tpdr-OTSi node should have 2 eNEPs");
872 assertEquals(2, nepsI.size(), "Tpdr-OTSi node should have 2 iNEPs");
873 OwnedNodeEdgePoint nep5 = nepsE.get(0);
874 Uuid enepUuid3 = new Uuid(
875 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+eOTSi+XPDR1-NETWORK1")
876 .getBytes(Charset.forName("UTF-8"))).toString());
877 checkNepOtsiNode(nep5, enepUuid3, "XPDR1-NETWORK1", "eNodeEdgePoint",
878 tpdr100G.getNodeId().getValue(), TapiStringConstants.E_OTSI);
879 OwnedNodeEdgePoint nep6 = nepsI.get(0);
880 Uuid inepUuid3 = new Uuid(
881 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iOTSi+XPDR1-NETWORK1")
882 .getBytes(Charset.forName("UTF-8"))).toString());
883 checkNepOtsiNode(nep6, inepUuid3, "XPDR1-NETWORK1", "iNodeEdgePoint",
884 tpdr100G.getNodeId().getValue(), TapiStringConstants.I_OTSI);
885 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
886 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
887 .collect(Collectors.toList());
888 checkNodeRuleGroupForTpdrOTSi(nrgList3, enepUuid3, inepUuid3, nodeUuid);
891 Iterator<OwnedNodeEdgePoint> nepIterator = node.nonnullOwnedNodeEdgePoint().values().iterator();
893 while (nepIterator.hasNext()) {
894 OwnedNodeEdgePoint nep = nepIterator.next();
895 Uuid nepUuid = new Uuid(
896 UUID.nameUUIDFromBytes((String.join("+", "roadm node", "nep", String.valueOf(count)))
897 .getBytes(Charset.forName("UTF-8"))).toString());
898 checkNepOtsiRdmNode(nep, nepUuid, new StringBuilder("NodeEdgePoint_").append(count).toString(),
899 "NodeEdgePoint name");
902 List<NodeRuleGroup> nrgList4 = node.nonnullNodeRuleGroup().values().stream()
903 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
904 .collect(Collectors.toList());
905 checkNodeRuleGroupForRdmInfra(nrgList4, count - 1);
910 private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
911 String nodeId, String extension) {
912 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
913 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
914 Name name = nameList.get(0);
915 assertEquals(String.join("+", nodeId, extension, portName), name.getValue(),
916 "value of client nep should be '" + portName + "'");
917 assertEquals(nepName, name.getValueName(),
918 "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
919 assertEquals(3, nep.getSupportedCepLayerProtocolQualifier().size(),
920 "Client nep should support 3 kind of cep");
921 assertThat("client nep should support 3 kind of cep",
922 nep.getSupportedCepLayerProtocolQualifier(),
923 hasItems(ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, DIGITALSIGNALTYPE10GigELAN.VALUE));
924 assertEquals(LayerProtocolName.ETH, nep.getLayerProtocolName(), "client nep should be of ETH protocol type");
925 checkCommonPartOfNep(nep, false);
926 checkSIP(nep, portName, nodeId, extension);
929 private void checkNepNetworkODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
930 String nodeId, String extension) {
931 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
932 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
933 Name name = nameList.get(0);
934 assertEquals(String.join("+", nodeId, extension, portName), name.getValue(),
935 "value of network nep should be '" + portName + "'");
936 assertEquals(nepName, name.getValueName(),
937 "value-name of network nep for '" + portName + "' should be '" + nepName + "'");
938 assertEquals(1, nep.getSupportedCepLayerProtocolQualifier().size(),
939 "Network nep should support 1 kind of cep");
940 assertThat("network nep should support 1 kind of cep",
941 nep.getSupportedCepLayerProtocolQualifier(),
942 hasItem(ODUTYPEODU4.VALUE));
943 assertEquals(LayerProtocolName.ODU, nep.getLayerProtocolName(), "network nep should be of ODU protocol type");
944 checkCommonPartOfNep(nep, false);
945 checkSIP(nep, portName, nodeId, extension);
948 private void checkNodeRuleGroupForTpdrDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
950 assertEquals(2, nrgList.size(), "transponder DSR should contain 2 node rule group");
951 for (NodeRuleGroup nodeRuleGroup : nrgList) {
952 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
953 "each node-rule-group should contain 2 NEP for transponder DSR");
955 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
956 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
957 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
958 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
959 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
960 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
961 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
962 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
963 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
964 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
965 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
966 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
967 assertEquals(1, rule.size(), "node-rule-group nb 1 should contain a single rule");
968 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
969 assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, rule.get(0).getForwardingRule(),
970 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
971 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
974 private void checkNodeRuleGroupForMuxDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
976 assertEquals(4, nrgList.size(), "muxponder DSR should contain 4 node rule group");
977 for (NodeRuleGroup nodeRuleGroup : nrgList) {
978 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
979 "each node-rule-group should contain 2 NEP for muxponder DSR");
981 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
982 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
983 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
984 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
985 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
986 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
987 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
988 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
989 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
990 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
991 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
992 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
993 assertEquals(1, rule.size(), "node-rule-group nb 2 should contain a single rule");
994 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
995 assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, rule.get(0).getForwardingRule(),
996 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
997 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1000 private void checkNodeRuleGroupForSwitchDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
1002 assertEquals(1, nrgList.size(), "Switch-DSR should contain a single node rule group");
1003 assertEquals(8, nrgList.get(0).getNodeEdgePoint().size(), "Switch-DSR node-rule-group should contain 8 NEP");
1004 List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
1005 .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
1006 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
1007 .collect(Collectors.toList());
1008 assertEquals(networkNepUuid, nrg.get(6).getNodeEdgePointUuid(),
1009 "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
1010 assertEquals(clientNepUuid, nrg.get(5).getNodeEdgePointUuid(),
1011 "in the sorted node-rule-group, nep number 6 should be XPDR2-CLIENT4");
1012 assertEquals(nodeUuid, nrg.get(4).getNodeUuid(),
1013 "any item of the node-rule-group should have the same nodeUuid");
1014 assertEquals(nodeUuid, nrg.get(3).getNodeUuid(),
1015 "any item of the node-rule-group should have the same nodeUuid");
1017 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1018 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1019 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1020 assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule(),
1021 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1022 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1025 private void checkNodeRuleGroupForRdmInfra(List<NodeRuleGroup> nrgList, int nbNeps) {
1026 assertEquals(1, nrgList.size(), "RDM infra node - OTSi should contain a single node rule groups");
1028 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1029 assertEquals(nbNeps, nodeEdgePointList.size(),
1030 "RDM infra node -rule-group should contain " + nbNeps + " NEP");
1032 assertNull(nrgList.get(0).getNodeEdgePoint(), "RDM infra node -rule-group should contain no NEP");
1034 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1035 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1036 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1037 assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule(),
1038 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1039 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1042 private void checkNodeRuleGroupForTpdrOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1044 assertEquals(2, nrgList.size(), "Tpdr-OTSi should contain two node rule groups");
1045 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1046 assertEquals(2, nodeEdgePointList.size(), "Tpdr-OTSi node-rule-group should contain 2 NEP");
1047 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1048 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1049 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1050 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1051 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1052 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1053 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
1054 "any item of the node-rule-group should have the same nodeUuid");
1055 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
1056 "any item of the node-rule-group should have the same nodeUuid");
1057 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1058 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1059 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1060 assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule(),
1061 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1062 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1065 private void checkNodeRuleGroupForMuxOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1067 assertEquals(1, nrgList.size(), "Mux-OTSi should contain a single node rule group");
1068 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1069 assertEquals(2, nodeEdgePointList.size(), "Mux-OTSi node-rule-group should contain 2 NEP");
1070 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1071 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1072 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1073 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1074 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1075 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1076 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
1077 "any item of the node-rule-group should have the same nodeUuid");
1078 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
1079 "any item of the node-rule-group should have the same nodeUuid");
1080 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1081 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1082 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1083 assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule(),
1084 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1085 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1088 private void checkNodeRuleGroupForSwitchOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1090 assertEquals(4, nrgList.size(), "Switch-OTSi should contain 4 node rule group");
1091 for (NodeRuleGroup nodeRuleGroup : nrgList) {
1092 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
1093 "each node-rule-group should contain 2 NEP for Switch-OTSi");
1095 List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
1096 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1097 nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
1098 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1099 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1100 nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
1101 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1102 List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1103 assertEquals(nodeUuid, nodeEdgePointList0.get(0).getNodeUuid(),
1104 "any item of the node-rule-group should have the same nodeUuid");
1105 assertEquals(nodeUuid, nodeEdgePointList0.get(1).getNodeUuid(),
1106 "any item of the node-rule-group should have the same nodeUuid");
1107 List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1108 assertEquals(1, ruleList0.size(), "node-rule-group should contain a single rule");
1109 assertEquals("forward", ruleList0.get(0).getLocalId(),"local-id of the rule should be 'forward'");
1110 assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList0.get(0).getForwardingRule(),
1111 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1112 assertEquals(RuleType.FORWARDING, ruleList0.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1115 private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1116 String nodeId, String extension) {
1117 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1118 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1119 assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
1120 "value of client nep should be '" + portName + "'");
1121 assertEquals(nepName, nameList.get(0).getValueName(),
1122 "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
1123 assertEquals(2, nep.getSupportedCepLayerProtocolQualifier().size(), "Client nep should support 2 kind of cep");
1124 assertThat("client nep should support 2 kind of cep",
1125 nep.getSupportedCepLayerProtocolQualifier(),
1126 hasItems(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE));
1127 assertEquals(LayerProtocolName.ETH, nep.getLayerProtocolName(), "client nep should be of ETH protocol type");
1128 checkCommonPartOfNep(nep, false);
1129 checkSIP(nep, portName, nodeId, extension);
1132 private void checkNepClient100GTpdr(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1133 String nodeId, String extension) {
1134 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1135 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1136 assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
1137 "value of client nep should be '" + portName + "'");
1138 assertEquals(nepName, nameList.get(0).getValueName(),
1139 "value-name of client nep for '" + portName + "' should be 100G-tpdr'");
1140 assertEquals(1, nep.getSupportedCepLayerProtocolQualifier().size(), "Client nep should support 1 kind of cep");
1141 assertThat("client nep should support 2 kind of cep",
1142 nep.getSupportedCepLayerProtocolQualifier(),
1143 hasItems(DIGITALSIGNALTYPE100GigE.VALUE));
1144 assertEquals(LayerProtocolName.ETH, nep.getLayerProtocolName(), "client nep should be of ETH protocol type");
1145 checkCommonPartOfNep(nep, false);
1146 checkSIP(nep, portName, nodeId, extension);
1149 private void checkNepOtsiNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1150 String nodeId, String extension) {
1151 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1152 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1153 assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
1154 "value of OTSi nep should be '" + portName + "'");
1155 assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
1156 assertEquals(2, nep.getSupportedCepLayerProtocolQualifier().size(), "OTSi nep should support 2 kind of cep");
1157 assertThat("OTSi nep should support 2 kind of cep",
1158 nep.getSupportedCepLayerProtocolQualifier(),
1159 hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE));
1160 assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1161 "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1162 assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "OTSi nep should support one SIP");
1163 checkCommonPartOfNep(nep, false);
1164 checkSIP(nep, portName, nodeId, extension);
1167 private void checkSIP(OwnedNodeEdgePoint nep, String portName, String nodeId, String extension) {
1168 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeId, extension, portName))
1169 .getBytes(Charset.forName("UTF-8"))).toString());
1172 nep.getMappedServiceInterfacePoint().get(new MappedServiceInterfacePointKey(sipUuid))
1173 .getServiceInterfacePointUuid(),
1174 "service-interface-point-uuid of network nep for '" + portName + "' should be '"
1175 + String.join("+", "SIP", portName) + "'");
1178 private void checkNepOtsiRdmNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
1179 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1180 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1181 assertEquals(portName, nameList.get(0).getValue(), "value of OTSi nep should be '" + portName + "'");
1182 assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
1183 assertEquals(1, nep.getSupportedCepLayerProtocolQualifier().size(),
1184 "OTSi nep of RDM infra node should support only 1 kind of cep");
1185 assertThat("OTSi nep should support 2 kind of cep",
1186 nep.getSupportedCepLayerProtocolQualifier(),
1187 hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE));
1188 assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1189 "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1190 assertEquals(0, nep.nonnullMappedServiceInterfacePoint().size(), "OTSi nep of RDM infra should support no SIP");
1191 checkCommonPartOfNep(nep, true);
1194 private void checkCommonPartOfNep(OwnedNodeEdgePoint nep, boolean isRdm) {
1195 assertEquals(PortDirection.BIDIRECTIONAL, nep.getLinkPortDirection(),
1196 "link port direction should be DIRECTIONAL");
1197 assertEquals(AdministrativeState.UNLOCKED, nep.getAdministrativeState(),
1198 "administrative state should be UNLOCKED");
1199 assertEquals(TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState(),
1200 "termination state should be TERMINATED BIDIRECTIONAL");
1201 assertEquals(LifecycleState.INSTALLED, nep.getLifecycleState(),
1202 "life-cycle state should be INSTALLED");
1204 assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "client nep should support 1 SIP");
1206 assertEquals(TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection(),
1207 "termination direction should be BIDIRECTIONAL");
1208 assertEquals(OperationalState.ENABLED, nep.getOperationalState(),
1209 "operational state of client nep should be ENABLED");
1210 assertEquals(PortRole.SYMMETRIC, nep.getLinkPortRole(), "link-port-role of client nep should be SYMMETRIC");
1213 private void checkTransitionalLink(Link link, Uuid node1Uuid, Uuid node2Uuid, String tp1, String tp2,
1214 String ietfNodeId) {
1215 Uuid linkUuid = new Uuid(UUID.nameUUIDFromBytes((tp1 + "to" + tp2)
1216 .getBytes(Charset.forName("UTF-8"))).toString());
1217 assertEquals(linkUuid, link.getUuid(), "bad uuid for link between DSR node " + tp1 + " and iOTSI port " + tp2);
1218 assertEquals(CapacityUnit.GBPS, link.getAvailableCapacity().getTotalSize().getUnit(),
1219 "Available capacity unit should be GBPS");
1220 assertEquals(Uint64.valueOf(100), link.getAvailableCapacity().getTotalSize().getValue(),
1221 "Available capacity -total size value should be 100");
1222 assertEquals(2, link.getTransitionedLayerProtocolName().size(),
1223 "transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA");
1224 assertThat("transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA",
1225 link.getTransitionedLayerProtocolName(),
1226 hasItems(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()));
1227 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
1228 "transitional link should be BIDIRECTIONAL");
1229 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
1230 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1231 assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1232 "topology uuid should be the same for the two termination point of the link");
1233 assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1234 "topology uuid should be the same for the two termination point of the link");
1235 assertThat("transitional links should terminate on DSR node and Photonic node",
1236 nodeEdgePointList.get(0).getNodeUuid().getValue(),
1237 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1238 assertThat("transitional links should terminate on DSR node and Photonic node",
1239 nodeEdgePointList.get(1).getNodeUuid().getValue(),
1240 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1241 Uuid nep1Uuid = new Uuid(UUID.nameUUIDFromBytes(tp1.getBytes(Charset.forName("UTF-8"))).toString());
1242 Uuid nep2Uuid = new Uuid(UUID.nameUUIDFromBytes(tp2.getBytes(Charset.forName("UTF-8"))).toString());
1243 assertThat("transitional links should terminate on " + tp1 + " and " + tp2 + " neps",
1244 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1245 either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));
1246 assertThat("transitional links should terminate on DSR node and Photonic node",
1247 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1248 either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));
1251 private void checkOtnLink(Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid,
1253 assertEquals(linkName, link.getName().get(new NameKey("otn link name")).getValue(), "bad name for the link");
1254 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1255 assertEquals(CapacityUnit.GBPS, link.getAvailableCapacity().getTotalSize().getUnit(),
1256 "Available capacity unit should be MBPS");
1257 String prefix = linkName.split("-")[0];
1258 if ("OTU4".equals(prefix)) {
1259 assertEquals(Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue(),
1260 "Available capacity -total size value should be 0");
1261 } else if ("ODTU4".equals(prefix)) {
1262 assertEquals(Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue(),
1263 "Available capacity -total size value should be 100 000");
1265 assertEquals(CapacityUnit.GBPS, link.getTotalPotentialCapacity().getTotalSize().getUnit(),
1266 "Total capacity unit should be GBPS");
1267 assertEquals(Uint64.valueOf(100), link.getTotalPotentialCapacity().getTotalSize().getValue(),
1268 "Total capacity -total size value should be 100");
1269 if ("OTU4".equals(prefix)) {
1271 LayerProtocolName.PHOTONICMEDIA.getName(),
1272 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1273 "otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1274 } else if ("ODTU4".equals(prefix)) {
1276 LayerProtocolName.ODU.getName(),
1277 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1278 "otn link should be between 2 nodes of protocol layers ODU");
1280 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
1281 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
1282 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1283 assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1284 "topology uuid should be the same for the two termination point of the link");
1285 assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1286 "topology uuid should be the same for the two termination point of the link");
1287 assertThat("otn links should terminate on two distinct nodes",
1288 nodeEdgePointList.get(0).getNodeUuid().getValue(),
1289 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1290 assertThat("otn links should terminate on two distinct nodes",
1291 nodeEdgePointList.get(1).getNodeUuid().getValue(),
1292 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1293 assertThat("otn links should terminate on two distinct tps",
1294 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1295 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1296 assertThat("otn links should terminate on two distinct tps",
1297 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1298 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1299 assertEquals(OperationalState.ENABLED, link.getOperationalState(), "operational state should be ENABLED");
1300 assertEquals(AdministrativeState.UNLOCKED, link.getAdministrativeState(),
1301 "administrative state should be UNLOCKED");
1304 private void checkOmsLink(Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid,
1306 assertEquals(linkName, link.getName().get(new NameKey("OMS link name")).getValue(), "bad name for the link");
1307 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1309 LayerProtocolName.PHOTONICMEDIA.getName(),
1310 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1311 "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1312 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
1313 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
1314 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1315 assertEquals(2, nodeEdgePointList.size(), "oms link should be between 2 neps");
1316 assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1317 "topology uuid should be the same for the two termination point of the link");
1318 assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1319 "topology uuid should be the same for the two termination point of the link");
1320 assertThat("oms links should terminate on two distinct nodes",
1321 nodeEdgePointList.get(0).getNodeUuid().getValue(),
1322 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1323 assertThat("oms links should terminate on two distinct nodes",
1324 nodeEdgePointList.get(1).getNodeUuid().getValue(),
1325 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1326 assertThat("oms links should terminate on two distinct tps",
1327 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1328 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1329 assertThat("oms links should terminate on two distinct tps",
1330 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1331 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1334 private Node changeTerminationPointState(Node initialNode, String tpid, AdminStates admin, State oper) {
1335 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder tpdr1Bldr
1336 = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder(
1337 initialNode.augmentation(Node1.class));
1338 Map<TerminationPointKey, TerminationPoint> tps = new HashMap<>(tpdr1Bldr.getTerminationPoint());
1339 TerminationPointBuilder tpBldr = new TerminationPointBuilder(
1340 tps.get(new TerminationPointKey(new TpId(tpid))));
1341 TerminationPoint1Builder tp1Bldr = new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class));
1342 tp1Bldr.setAdministrativeState(admin)
1343 .setOperationalState(oper);
1344 tpBldr.addAugmentation(tp1Bldr.build());
1345 tps.replace(tpBldr.key(), tpBldr.build());
1346 tpdr1Bldr.setTerminationPoint(tps);
1347 return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.build()).build();
1350 private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
1351 .Link changeOtnLinkState(
1352 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
1353 .Link initiallink, AdminStates admin, State oper) {
1355 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
1356 .LinkBuilder linkBldr = new
1357 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
1358 .LinkBuilder(initiallink);
1359 Link1Builder link1Bldr = new Link1Builder(linkBldr.augmentation(Link1.class));
1360 link1Bldr.setAdministrativeState(admin)
1361 .setOperationalState(oper);
1362 linkBldr.addAugmentation(link1Bldr.build());
1363 return linkBldr.build();