Migration to TAPI 2.4 Step3
[transportpce.git] / tapi / src / test / java / org / opendaylight / transportpce / tapi / topology / TapiTopologyImplTest.java
1 /*
2  * Copyright © 2019 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.tapi.topology;
9
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.CoreMatchers.either;
12 import static org.hamcrest.MatcherAssert.assertThat;
13 import static org.junit.jupiter.api.Assertions.assertEquals;
14 import static org.junit.jupiter.api.Assertions.assertNotNull;
15
16 import com.google.common.util.concurrent.ListenableFuture;
17 import com.google.common.util.concurrent.ListeningExecutorService;
18 import com.google.common.util.concurrent.MoreExecutors;
19 import java.nio.charset.Charset;
20 import java.nio.charset.StandardCharsets;
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.UUID;
26 import java.util.concurrent.CountDownLatch;
27 import java.util.concurrent.ExecutionException;
28 import java.util.concurrent.Executors;
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.transportpce.common.InstanceIdentifiers;
34 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
35 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
36 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
37 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
38 import org.opendaylight.transportpce.tapi.TapiStringConstants;
39 import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
40 import org.opendaylight.transportpce.tapi.utils.TapiContext;
41 import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
42 import org.opendaylight.transportpce.tapi.utils.TapiLink;
43 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
44 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
45 import org.opendaylight.transportpce.test.AbstractTest;
46 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsInput;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsOutput;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointListInput;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointListOutput;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.list.output.Sip;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.list.output.SipKey;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetailsInput;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetailsOutput;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsInput;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsOutput;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsInput;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsOutput;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyDetailsInput;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyDetailsOutput;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Node;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.topology.details.output.Topology;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkKey;
79 import org.opendaylight.yangtools.yang.common.Decimal64;
80 import org.opendaylight.yangtools.yang.common.RpcResult;
81 import org.opendaylight.yangtools.yang.common.Uint64;
82 import org.slf4j.Logger;
83 import org.slf4j.LoggerFactory;
84
85 public class TapiTopologyImplTest extends AbstractTest {
86     private static final Logger LOG = LoggerFactory.getLogger(TapiTopologyImplTest.class);
87
88     private static ListeningExecutorService executorService;
89     private static CountDownLatch endSignal;
90     private static final int NUM_THREADS = 3;
91     private static NetworkTransactionService networkTransactionService;
92     private static TapiContext tapiContext;
93     private static TopologyUtils topologyUtils;
94     private static ConnectivityUtils connectivityUtils;
95     private static ServiceDataStoreOperations serviceDataStoreOperations;
96     private static TapiInitialORMapping tapiInitialORMapping;
97     private static TapiLink tapiLink;
98
99     @BeforeAll
100     static void setUp() throws InterruptedException, ExecutionException {
101         executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
102         endSignal = new CountDownLatch(1);
103         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
104             TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
105         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
106             TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
107         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
108             TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
109         TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
110             TapiTopologyDataUtils.PORTMAPPING_FILE);
111         networkTransactionService = new NetworkTransactionImpl(getDataBroker());
112         tapiLink = new TapiLinkImpl(networkTransactionService);
113         serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker());
114         tapiContext = new TapiContext(networkTransactionService);
115         topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(),
116             tapiLink);
117         connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext,
118             networkTransactionService);
119         tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
120             tapiContext, serviceDataStoreOperations);
121         tapiInitialORMapping.performTopoInitialMapping();
122         LOG.info("setup done");
123     }
124
125     @Test
126     void getTopologyDetailsForTransponder100GTopologyWhenSuccessful()
127             throws ExecutionException, InterruptedException {
128         Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(
129             Charset.forName("UTF-8"))).toString());
130         LOG.info("TPDR100GUuid = {}", topologyUuid);
131         GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
132         TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
133         ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
134         LOG.info("RESULT of getTopoDetailsTopo/name = {}", result.get().getResult().getTopology().getName().toString());
135         result.addListener(new Runnable() {
136             @Override
137             public void run() {
138                 endSignal.countDown();
139             }
140         }, executorService);
141         endSignal.await();
142         RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
143         @Nullable
144         Topology topology = rpcResult.getResult().getTopology();
145         assertNotNull(topology, "Topology should not be null");
146         Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(StandardCharsets.UTF_8))
147             .toString());
148         assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
149         assertEquals(1, topology.getNode().size(), "Node list size should be 1");
150         Name nodeName = topology.getNode().values().stream().findFirst().orElseThrow().getName()
151             .get(new NameKey("Tpdr100g node name"));
152         assertEquals("Tpdr100g over WDM node", nodeName.getValue(), "Node name should be 'Tpdr100g over WDM node'");
153         Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeName.getValue().getBytes(StandardCharsets.UTF_8))
154             .toString());
155         assertEquals(nodeUuid, topology.getNode().values().stream().findFirst().orElseThrow().getUuid(),
156             "incorrect node uuid");
157         long nb = topology.getNode().values().stream().findFirst().orElseThrow().getOwnedNodeEdgePoint().size();
158         assertEquals(2, nb, "'Transponder 100GE' node should have 2 neps");
159         List<NodeRuleGroup> nrgList = topology.getNode().values().stream().findFirst().orElseThrow()
160             .nonnullNodeRuleGroup().values().stream()
161             .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
162             .collect(Collectors.toList());
163         assertEquals(1, nrgList.size(), "'Transponder 100GE' node should contain a single node rule groups");
164         List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
165         assertEquals(nb, nodeEdgePointList.size(), "'Transponder 100GE' node -rule-group should contain 2 NEPs");
166         List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
167         assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
168         assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
169         assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
170             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
171         assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
172             "the rule type should be 'FORWARDING'");
173     }
174
175     @Test
176     void getTopologyDetailsForOtnTopologyWithOtnLinksWhenSuccessful()
177             throws ExecutionException, InterruptedException {
178         Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
179             Charset.forName("UTF-8"))).toString());
180         LOG.info("T0MultilayerUuid = {}", topologyUuid);
181         GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
182         TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
183         ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
184         result.addListener(new Runnable() {
185             @Override
186             public void run() {
187                 endSignal.countDown();
188             }
189         }, executorService);
190         endSignal.await();
191         RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
192         @Nullable
193         Topology topology = rpcResult.getResult().getTopology();
194         assertNotNull(topology, "Topology should not be null");
195         for (Map.Entry<
196             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey,
197             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> entry :
198                 topology.getNode().entrySet()) {
199             LOG.debug("NODESDETECTED = {}",entry.getValue().getName().toString());
200         }
201         assertEquals(7, topology.getNode().size(), "Node list size should be 7");
202         long nb1 = topology.getNode().values().stream()
203             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
204             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
205                 .equals("XPDR-A1-XPDR1+XPONDER"))
206             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
207                 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
208             .count();
209         assertEquals(1, nb1, "XPDR-A1-XPDR1 should only have one client nep");
210         long nb2 = topology.getNode().values().stream()
211             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
212             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
213                 .equals("SPDR-SA1-XPDR1+XPONDER"))
214             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
215                 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
216             .count();
217         assertEquals(4, nb2, "SPDR-SA1-XPDR1 (mux) should have 4 client neps");
218         long nb3 = topology.getNode().values().stream()
219             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
220             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
221                 .equals("SPDR-SA1-XPDR1+XPONDER"))
222             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
223                 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
224             .count();
225         assertEquals(1, nb3, "SPDR-SA1-XPDR1 (mux) should have a single network nep");
226         long nb4 = topology.getNode().values().stream()
227             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
228             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
229                 .equals("SPDR-SA1-XPDR2+XPONDER"))
230             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
231                 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
232             .count();
233         assertEquals(4, nb4, "SPDR-SA1-XPDR2 (switch) should have 4 client neps");
234         long nb5 = topology.getNode().values().stream()
235             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
236             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
237                 .equals("SPDR-SA1-XPDR2+XPONDER"))
238             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
239                 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
240             .count();
241         assertEquals(2, nb5, "SPDR-SA1-XPDR2 (switch) should have 2 network neps");
242         long nb7 = topology.getNode().values().stream()
243             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
244                 && node.getLayerProtocolName().contains(LayerProtocolName.DSR))
245             .filter(node -> node.getName().get(new NameKey("otsi node name")).getValue()
246                 .equals("XPDR-A1-XPDR1+XPONDER"))
247             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
248                 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
249             .count();
250         assertEquals(1, nb7, "XPDR-A1-XPDR1 should only have 1 OTSI network nep");
251         long nb8 = topology.getNode().values().stream()
252             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
253                 && node.getLayerProtocolName().contains(LayerProtocolName.DSR))
254             .filter(node -> node.getName().get(new NameKey("otsi node name")).getValue()
255                 .equals("SPDR-SA1-XPDR1+XPONDER"))
256             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
257                 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
258             .count();
259         assertEquals(1, nb8, "SPDR-SA1-XPDR1 (mux) should have a single OTSI network nep");
260         long nb9 = topology.getNode().values().stream()
261             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
262                 && node.getLayerProtocolName().contains(LayerProtocolName.DSR))
263             .filter(node -> node.getName().get(new NameKey("otsi node name")).getValue()
264                 .equals("SPDR-SA1-XPDR2+XPONDER"))
265             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
266                 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
267             .count();
268         assertEquals(2, nb9, "SPDR-SA1-XPDR2 (switch) should have 2 OTSI network nep");
269
270         assertEquals(10, topology.getLink().size(), "Link list size should be 10, no more transitionnal links");
271         Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes()).toString());
272         assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
273         assertEquals(
274             "T0 - Multi-layer topology",
275             topology.nonnullName().values().stream().findFirst().orElseThrow().getValue(),
276             "topology name should be T0 - Multi-layer topology");
277
278         long nbDsrOduNodes = topology.nonnullNode().values().stream()
279             .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
280         long nbPhotonicNodes = topology.nonnullNode().values().stream()
281             .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
282         assertEquals(6, nbDsrOduNodes, "Node list should contain 6 DSR-ODU nodes");
283         assertEquals(7, nbPhotonicNodes, "Node list should contain 7 Photonics node");
284         long nbOtsLinks = topology.getLink().values().stream()
285             .filter(l -> l.getName().containsKey(new NameKey("OTS link name"))).count();
286         long nbOtnLinks = topology.getLink().values().stream()
287             .filter(l -> l.getName().containsKey(new NameKey("otn link name"))).count();
288         assertEquals(8, nbOtsLinks, "Link list should contain 8 OTS links");
289         assertEquals(2, nbOtnLinks, "Link list should contain 2 OTN links");
290
291         Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
292             .toString());
293         Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
294             .toString());
295         Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
296             .toString());
297         Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
298             .toString());
299         Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1"
300             .getBytes(StandardCharsets.UTF_8)).toString());
301         Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
302             .getBytes(StandardCharsets.UTF_8)).toString());
303         Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
304             .getBytes(StandardCharsets.UTF_8)).toString());
305         Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
306             .getBytes(StandardCharsets.UTF_8)).toString());
307         Uuid link1Uuid =
308             new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
309                 .getBytes(StandardCharsets.UTF_8)).toString());
310         Uuid link2Uuid =
311             new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
312                 .getBytes(StandardCharsets.UTF_8)).toString());
313
314         List<Link> links = topology.nonnullLink().values().stream()
315             .filter(l -> l.getName().containsKey(new NameKey("otn link name")))
316             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
317             .collect(Collectors.toList());
318         checkOtnLink(links.get(0), topoUuid, node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link1Uuid,
319             "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1");
320         checkOtnLink(links.get(1), topoUuid, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link2Uuid,
321             "SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1");
322
323     }
324
325     @Test
326     void getTopologyDetailsForFullTapiTopologyWithLinksWhenSuccessful()
327             throws ExecutionException, InterruptedException {
328         Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
329             Charset.forName("UTF-8"))).toString());
330         LOG.info("T0FullMultilayerUuid = {}", topologyUuid);
331         GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
332         TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
333         ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
334         result.addListener(new Runnable() {
335             @Override
336             public void run() {
337                 endSignal.countDown();
338             }
339         }, executorService);
340         endSignal.await();
341         RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
342         @Nullable
343         Topology topology = rpcResult.getResult().getTopology();
344         assertNotNull(topology, "Topology should not be null");
345         // 2 Nodes per Xpdr/Spdr node (DSR-ODU & PHOT) + 3 Node per Roadm
346         assertEquals(10, topology.getNode().size(), "Node list size should be 10");
347         List<Map<NameKey, Name>> nodeNames = topology.getNode().values().stream()
348             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
349             .map(Node::getName).collect(Collectors.toList());
350         LOG.info("TopologyNodes = {}", nodeNames.toString());
351         Node nodeTsp = topology.getNode().values().stream()
352             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
353             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
354                 .equals("XPDR-A1-XPDR1+XPONDER"))
355             .findAny().orElseThrow();
356         LOG.debug("XPDRA1 NEPs = {}", nodeTsp.getOwnedNodeEdgePoint().toString());
357         long nb1 = topology.getNode().values().stream()
358             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
359             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
360                 .equals("XPDR-A1-XPDR1+XPONDER"))
361             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
362                 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
363             .count();
364         // 2 client ports in configuration -> removed the checkTp so we have 2 NEPs
365         assertEquals(2, nb1, "XPDR-A1-XPDR1+XPONDER should only have two client neps");
366         long inb1 = topology.getNode().values().stream()
367             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
368             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
369                 .equals("XPDR-A1-XPDR1+XPONDER"))
370             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
371                 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
372             .count();
373         assertEquals(2, inb1, "XPDR-A1-XPDR1+XPONDER should only have two internal network neps");
374         long enb1 = topology.getNode().values().stream()
375             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
376             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
377                 .equals("XPDR-A1-XPDR1+XPONDER"))
378             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
379                 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
380             .count();
381         assertEquals(2, enb1, "XPDR-A1-XPDR1+XPONDER should only have two external network neps");
382         long nb2 = topology.getNode().values().stream()
383             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
384             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
385                 .equals("SPDR-SA1-XPDR1+XPONDER"))
386             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
387                 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
388             .count();
389         assertEquals(4, nb2, "SPDR-SA1-XPDR1+XPONDER (mux) should have 4 client neps");
390         long inb3 = topology.getNode().values().stream()
391             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
392             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
393                 .equals("SPDR-SA1-XPDR1+XPONDER"))
394             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
395                 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
396             .count();
397         assertEquals(1, inb3, "SPDR-SA1-XPDR1+XPONDER (mux) should have a single internal network nep");
398         long enb3 = topology.getNode().values().stream()
399             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
400             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
401                 .equals("SPDR-SA1-XPDR1+XPONDER"))
402             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
403                 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
404             .count();
405         assertEquals(4, enb3, "SPDR-SA1-XPDR1+XPONDER (mux) should have 4 external network nep");
406         long nb4 = topology.getNode().values().stream()
407             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
408             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
409                 .equals("SPDR-SA1-XPDR2+XPONDER"))
410             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
411                 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
412             .count();
413         assertEquals(4, nb4, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 client neps");
414         long inb5 = topology.getNode().values().stream()
415             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
416             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
417                 .equals("SPDR-SA1-XPDR2+XPONDER"))
418             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
419                 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
420             .count();
421         assertEquals(4, inb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 internal network neps");
422         long enb5 = topology.getNode().values().stream()
423             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
424             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
425                 .equals("SPDR-SA1-XPDR1+XPONDER"))
426             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
427                 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
428             .count();
429         assertEquals(4, enb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 external network neps");
430
431         inb1 = topology.getNode().values().stream()
432             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
433             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
434                 .equals("XPDR-A1-XPDR1+XPONDER"))
435             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
436                 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
437             .count();
438         assertEquals(2, inb1, "XPDR-A1-XPDR1+XPONDER should only have two external network neps");
439         enb1 = topology.getNode().values().stream()
440             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
441             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
442                 .equals("XPDR-A1-XPDR1+XPONDER"))
443             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
444                 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
445             .count();
446         assertEquals(2, enb1, "XPDR-A1-XPDR1+XPONDER should only have two photonic network neps");
447         inb3 = topology.getNode().values().stream()
448             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
449             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
450                 .equals("SPDR-SA1-XPDR1+XPONDER"))
451             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
452                 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
453             .count();
454         assertEquals(1, inb3, "SPDR-SA1-XPDR1+XPONDER (mux) should have a single external network nep");
455         inb5 = topology.getNode().values().stream()
456             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
457             .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
458                 .equals("SPDR-SA1-XPDR2+XPONDER"))
459             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
460                 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
461             .count();
462         assertEquals(4, inb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 external network neps");
463         Node nodeRoadm = topology.getNode().values().stream()
464             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
465                 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
466             .filter(node -> node.getName().get(new NameKey("roadm node name")).getValue()
467                 .equals("ROADM-A1+PHOTONIC_MEDIA"))
468             .findAny().orElseThrow();
469         long inb6 = topology.getNode().values().stream()
470             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
471                 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
472             .filter(node -> node.getName().get(new NameKey("roadm node name")).getValue()
473                 .equals("ROADM-A1+PHOTONIC_MEDIA"))
474             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
475                 .filter(nep -> nep.getName().values().stream().findAny().orElseThrow().getValue().contains("DEG")))
476             .count();
477         assertEquals(4, inb6, "ROADM-A1+PHOTONIC_MEDIA (DEGREE) should have 4 network neps");
478         long enb6 = topology.getNode().values().stream()
479             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
480                 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
481             .filter(node -> node.getName().get(new NameKey("roadm node name")).getValue()
482                 .equals("ROADM-A1+PHOTONIC_MEDIA"))
483             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
484                 .filter(nep -> nep.getName().values().stream().findAny().orElseThrow().getValue().contains("SRG")))
485             .count();
486         assertEquals(8, enb6, "ROADM-A1+PHOTONIC_MEDIA (SRG) should have 8 network neps (OTS)");
487
488         // Links in openroadm topology which include Roadm-to-Roadm and Xpdr-to-Roadm (ortopo / 2)
489         // + transitional links -> 0 per network port of Xpdr + OTN links / 2
490         List<String> linkList = new ArrayList<>();
491         for (Map.Entry<LinkKey, Link> entry : topology.getLink().entrySet()) {
492             linkList.add(entry.getValue().getName().entrySet().iterator().next().getValue().toString());
493         }
494         assertEquals(9, topology.getLink().size(), "Link list size should be 8 XPDR To SRG and 1 DEG2A-DEG1C");
495         Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Full Multi-layer topology".getBytes()).toString());
496         assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
497         assertEquals(
498             "T0 - Full Multi-layer topology",
499             topology.nonnullName().values().stream().findFirst().orElseThrow().getValue(),
500             "topology name should be T0 - Full Multi-layer topology");
501
502         long nbDsrOduNodes = topology.nonnullNode().values().stream()
503             .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
504         long nbPhotonicNodes = topology.nonnullNode().values().stream()
505             .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
506         // In DSR/ODU we create one node per Xpdr (no filtering out)
507         assertEquals(8, nbDsrOduNodes, "Node list should contain 8 DSR-ODU nodes");
508         // We need to add the Roadms as Photonic nodes. Instead of 1 node as roadm infra we have 2 roadm nodes
509         assertEquals(8, nbPhotonicNodes, "Node list should contain 8 Photonics nodes");
510         // Roadm-to-Roadm
511         long nbOmsLinks = topology.getLink().values().stream()
512             .filter(l -> l.getName().containsKey(new NameKey("OMS link name"))).count();
513         // Xpdr-to-Roadm
514         long nbOmsLinks1 = topology.getLink().values().stream()
515             .filter(l -> l.getName().containsKey(new NameKey("XPDR-RDM link name"))).count();
516         // 1 OMS per ROADM-to-ROADM link + Existing XPDR-tp-ROADM link in openroadm topology
517         assertEquals(9, nbOmsLinks + nbOmsLinks1, "Link list should contain 9 OMS links");
518     }
519
520     @Test
521     void getNodeAndNepsDetailsWhenSuccessful()
522             throws ExecutionException, InterruptedException {
523         Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
524             Charset.forName("UTF-8"))).toString());
525         GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
526         TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
527         ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
528         result.addListener(new Runnable() {
529             @Override
530             public void run() {
531                 endSignal.countDown();
532             }
533         }, executorService);
534         endSignal.await();
535         RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
536         @Nullable
537         Topology topology = rpcResult.getResult().getTopology();
538         for (Node node:topology.getNode().values()) {
539             //String nodeName = node.getName().values().stream().findFirst().orElseThrow().getValue();
540             Uuid nodeUuid = node.getUuid();
541             GetNodeDetailsInput input1 = TapiTopologyDataUtils.buildGetNodeDetailsInput(topologyUuid, nodeUuid);
542             ListenableFuture<RpcResult<GetNodeDetailsOutput>> result1 = tapiTopoImpl.getNodeDetails(input1);
543             result.addListener(new Runnable() {
544                 @Override
545                 public void run() {
546                     endSignal.countDown();
547                 }
548             }, executorService);
549             endSignal.await();
550             RpcResult<GetNodeDetailsOutput> rpcResult1 = result1.get();
551             @Nullable
552             Node node1 = rpcResult1.getResult().getNode();
553             assertNotNull(node1, "Node should not be null");
554             for (OwnedNodeEdgePoint onep:node1.getOwnedNodeEdgePoint().values()) {
555                 //String onepName = onep.getName().values().stream().findFirst().orElseThrow().getValue();
556                 Uuid onepUuid = onep.getUuid();
557                 GetNodeEdgePointDetailsInput input2 = TapiTopologyDataUtils.buildGetNodeEdgePointDetailsInput(
558                     topologyUuid, nodeUuid, onepUuid);
559                 ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> result2
560                     = tapiTopoImpl.getNodeEdgePointDetails(input2);
561                 result.addListener(new Runnable() {
562                     @Override
563                     public void run() {
564                         endSignal.countDown();
565                     }
566                 }, executorService);
567                 endSignal.await();
568                 RpcResult<GetNodeEdgePointDetailsOutput> rpcResult2 = result2.get();
569                 org.opendaylight.yang.gen.v1
570                     .urn.onf.otcc.yang.tapi.topology.rev221121.get.node.edge.point.details.output.NodeEdgePoint
571                     onep1 = rpcResult2.getResult().getNodeEdgePoint();
572                 assertNotNull(onep1, "Node Edge Point should not be null");
573             }
574         }
575     }
576
577     @Test
578     void getLinkDetailsWhenSuccessful()
579             throws ExecutionException, InterruptedException {
580         Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
581             Charset.forName("UTF-8"))).toString());
582         GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
583         TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
584         ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
585         result.addListener(new Runnable() {
586             @Override
587             public void run() {
588                 endSignal.countDown();
589             }
590         }, executorService);
591         endSignal.await();
592         RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
593         @Nullable
594         Topology topology = rpcResult.getResult().getTopology();
595         for (Link link:topology.getLink().values()) {
596             //String linkName = link.getName().values().stream().findFirst().orElseThrow().getValue();
597             Uuid linkUuid = link.getUuid();
598             GetLinkDetailsInput input1 = TapiTopologyDataUtils.buildGetLinkDetailsInput(
599                 topologyUuid, linkUuid);
600             ListenableFuture<RpcResult<GetLinkDetailsOutput>> result1 = tapiTopoImpl.getLinkDetails(input1);
601             result.addListener(new Runnable() {
602                 @Override
603                 public void run() {
604                     endSignal.countDown();
605                 }
606             }, executorService);
607             endSignal.await();
608             RpcResult<GetLinkDetailsOutput> rpcResult1 = result1.get();
609             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.link.details.output.Link link1
610                 = rpcResult1.getResult().getLink();
611             assertNotNull(link1, "Link should not be null");
612         }
613     }
614
615     @Test
616     void getSipDetailsWhenSuccessful()
617             throws ExecutionException, InterruptedException {
618         GetServiceInterfacePointListInput input = TapiTopologyDataUtils.buildServiceInterfacePointListInput();
619         TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
620         ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>> result = tapiTopoImpl
621             .getServiceInterfacePointList(input);
622         result.addListener(new Runnable() {
623             @Override
624             public void run() {
625                 endSignal.countDown();
626             }
627         }, executorService);
628         endSignal.await();
629         RpcResult<GetServiceInterfacePointListOutput> rpcResult = result.get();
630         Map<SipKey, Sip> sipMap = rpcResult.getResult().getSip();
631         for (Sip sip:sipMap.values()) {
632             Uuid sipUuid = sip.getUuid();
633             GetServiceInterfacePointDetailsInput input1 = TapiTopologyDataUtils
634                 .buildGetServiceInterfacePointDetailsInput(sipUuid);
635             ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> result1
636                 = tapiTopoImpl.getServiceInterfacePointDetails(input1);
637             result.addListener(new Runnable() {
638                 @Override
639                 public void run() {
640                     endSignal.countDown();
641                 }
642             }, executorService);
643             endSignal.await();
644             RpcResult<GetServiceInterfacePointDetailsOutput> rpcResult1 = result1.get();
645             org.opendaylight.yang.gen.v1
646                 .urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.Sip sip1
647                 = rpcResult1.getResult().getSip();
648             assertNotNull(sip1, "Sip should not be null");
649         }
650     }
651
652     private void checkOtnLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid,
653             Uuid linkUuid, String linkName) {
654         assertEquals(linkName, link.getName().get(new NameKey("otn link name")).getValue(), "bad name for the link");
655         assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
656         assertEquals(CAPACITYUNITGBPS.VALUE, link.getAvailableCapacity().getTotalSize().getUnit(),
657             "Available capacity unit should be MBPS");
658         String prefix = linkName.split("-")[0];
659         if ("OTU4".equals(prefix)) {
660             assertEquals(Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue(),
661                 "Available capacity -total size value should be 0");
662         } else if ("ODTU4".equals(prefix)) {
663             assertEquals(Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue(),
664                 "Available capacity -total size value should be 100 000");
665         }
666         assertEquals(CAPACITYUNITGBPS.VALUE, link.getTotalPotentialCapacity().getTotalSize().getUnit(),
667             "Total capacity unit should be GBPS");
668         assertEquals(Decimal64.valueOf("100"), link.getTotalPotentialCapacity().getTotalSize().getValue(),
669             "Total capacity -total size value should be 100");
670         if ("OTU4".equals(prefix)) {
671             assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
672                 LayerProtocolName.PHOTONICMEDIA.getName(),
673                 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName());
674         } else if ("ODTU4".equals(prefix)) {
675             assertEquals("otn link should be between 2 nodes of protocol layers ODU",
676                 LayerProtocolName.ODU.getName(),
677                 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName());
678         }
679         assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
680             "transitional link should be BIDIRECTIONAL");
681         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
682             .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
683         assertEquals(topoUuid, nodeEdgePointList.get(0).getTopologyUuid(),
684             "topology uuid should be the same for the two termination point of the link");
685         assertEquals(topoUuid, nodeEdgePointList.get(1).getTopologyUuid(),
686             "topology uuid should be the same for the two termination point of the link");
687         assertThat("otn links should terminate on two distinct nodes",
688             nodeEdgePointList.get(0).getNodeUuid().getValue(),
689             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
690         assertThat("otn links should terminate on two distinct nodes",
691             nodeEdgePointList.get(1).getNodeUuid().getValue(),
692             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
693         assertThat("otn links should terminate on two distinct tps",
694             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
695             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
696         assertThat("otn links should terminate on two distinct tps",
697             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
698             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
699         assertEquals(OperationalState.ENABLED, link.getOperationalState(), "operational state should be ENABLED");
700         assertEquals(AdministrativeState.UNLOCKED, link.getAdministrativeState(),
701             "administrative state should be UNLOCKED");
702     }
703 }