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