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