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