Adapt TransportPCE code to Sulfur
[transportpce.git] / tapi / src / test / java / org / opendaylight / transportpce / tapi / topology / TapiTopologyImplTest.java
index 9f9c0e2c787e3423abf550dc0a46980e9486cb3e..8e615cb4b8ddaa623c45a59be39be3fe4e395f35 100644 (file)
@@ -98,23 +98,24 @@ public class TapiTopologyImplTest extends AbstractTest {
         executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
         endSignal = new CountDownLatch(1);
         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
-                TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
+            TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
-                TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
+            TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
-                TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
+            TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
         TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
-                TapiTopologyDataUtils.PORTMAPPING_FILE);
+            TapiTopologyDataUtils.PORTMAPPING_FILE);
         networkTransactionService = new NetworkTransactionImpl(
-                new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
+            new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
         tapiLink = new TapiLink(networkTransactionService);
         serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker());
         tapiContext = new TapiContext(networkTransactionService);
         topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(),
             tapiLink);
-        connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext);
+        connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext,
+            networkTransactionService);
         tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
-                tapiContext, serviceDataStoreOperations);
+            tapiContext, serviceDataStoreOperations);
         tapiInitialORMapping.performTopoInitialMapping();
         LOG.info("setup done");
     }
@@ -186,37 +187,42 @@ public class TapiTopologyImplTest extends AbstractTest {
         assertEquals("Node list size should be 13", 13, topology.getNode().size());
         long nb1 = topology.getNode().values().stream()
             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
-            .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1"))
+            .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
+                .equals("XPDR-A1-XPDR1+DSR"))
             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
                 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
             .count();
         assertEquals("XPDR-A1-XPDR1 should only have one client nep", 1, nb1);
         long nb2 = topology.getNode().values().stream()
             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
-            .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1"))
+            .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
+                .equals("SPDR-SA1-XPDR1+DSR"))
             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
                 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
             .count();
         assertEquals("SPDR-SA1-XPDR1 (mux) should have 4 client neps", 4, nb2);
         long nb3 = topology.getNode().values().stream()
             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
-            .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1"))
+            .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
+                .equals("SPDR-SA1-XPDR1+DSR"))
             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
-                .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_N"))))
+                .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
             .count();
         assertEquals("SPDR-SA1-XPDR1 (mux) should have a single network nep", 1, nb3);
         long nb4 = topology.getNode().values().stream()
             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
-            .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2"))
+            .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
+                .equals("SPDR-SA1-XPDR2+DSR"))
             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
                 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
             .count();
         assertEquals("SPDR-SA1-XPDR2 (switch) should have 4 client neps", 4, nb4);
         long nb5 = topology.getNode().values().stream()
             .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
-            .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2"))
+            .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
+                .equals("SPDR-SA1-XPDR2+DSR"))
             .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
-                .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_N"))))
+                .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
             .count();
         assertEquals("SPDR-SA1-XPDR2 (switch) should have 2 network neps", 2, nb5);
         assertEquals("Link list size should be 18", 18, topology.getLink().size());
@@ -445,7 +451,7 @@ public class TapiTopologyImplTest extends AbstractTest {
 
         // Links in openroadm topology which include Roadm-to-Roadm and Xpdr-to-Roadm (ortopo / 2)
         // + transitional links -> 1 per network port of Xpdr + OTN links / 2
-        assertEquals("Link list size should be 27", 27, topology.getLink().size());
+        assertEquals("Link list size should be 25", 25, topology.getLink().size());
         Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Full Multi-layer topology".getBytes()).toString());
         assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
         assertEquals("topology name should be T0 - Full Multi-layer topology",
@@ -468,46 +474,10 @@ public class TapiTopologyImplTest extends AbstractTest {
         // Xpdr-to-Roadm
         long nbOmsLinks1 = topology.getLink().values().stream()
             .filter(l -> l.getName().containsKey(new NameKey("XPDR-RDM link name"))).count();
-        long nbOtnLinks = topology.getLink().values().stream()
-            .filter(l -> l.getName().containsKey(new NameKey("otn link name"))).count();
         // 1 transitional link per NETWORK port
         assertEquals("Link list should contain 16 transitional links", 16, nbTransititionalLinks);
         // 1 OMS per ROADM-to-ROADM link + Existing XPDR-tp-ROADM link in openroadm topology
         assertEquals("Link list should contain 9 OMS links", 9, nbOmsLinks + nbOmsLinks1);
-        // Should we consider OTN links as links or connections??
-        assertEquals("Link list should contain 2 OTN links", 2, nbOtnLinks);
-
-        Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(StandardCharsets.UTF_8))
-            .toString());
-        Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR".getBytes(StandardCharsets.UTF_8))
-            .toString());
-        Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(StandardCharsets.UTF_8))
-            .toString());
-        Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+OTSi".getBytes(StandardCharsets.UTF_8))
-            .toString());
-        Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1"
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
-            .getBytes(StandardCharsets.UTF_8)).toString());
-        Uuid link1Uuid =
-            new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
-                .getBytes(StandardCharsets.UTF_8)).toString());
-        Uuid link2Uuid =
-            new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
-                .getBytes(StandardCharsets.UTF_8)).toString());
-
-        List<Link> links = topology.nonnullLink().values().stream()
-            .filter(l -> l.getName().containsKey(new NameKey("otn link name")))
-            .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
-            .collect(Collectors.toList());
-        checkOtnLink(links.get(0), topoUuid, node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link1Uuid,
-            "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1");
-        checkOtnLink(links.get(1), topoUuid, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link2Uuid,
-            "SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1");
     }
 
     @Test
@@ -559,7 +529,7 @@ public class TapiTopologyImplTest extends AbstractTest {
                 RpcResult<GetNodeEdgePointDetailsOutput> rpcResult2 = result2.get();
                 org.opendaylight.yang.gen.v1
                     .urn.onf.otcc.yang.tapi.topology.rev181210.get.node.edge.point.details.output.NodeEdgePoint
-                        onep1 = rpcResult2.getResult().getNodeEdgePoint();
+                    onep1 = rpcResult2.getResult().getNodeEdgePoint();
                 assertNotNull("Node Edge Point should not be null", onep1);
             }
         }
@@ -633,7 +603,7 @@ public class TapiTopologyImplTest extends AbstractTest {
             RpcResult<GetServiceInterfacePointDetailsOutput> rpcResult1 = result1.get();
             org.opendaylight.yang.gen.v1
                 .urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.details.output.Sip sip1
-                    = rpcResult1.getResult().getSip();
+                = rpcResult1.getResult().getSip();
             assertNotNull("Sip should not be null", sip1);
         }
     }
@@ -658,10 +628,12 @@ public class TapiTopologyImplTest extends AbstractTest {
             Uint64.valueOf(100), link.getTotalPotentialCapacity().getTotalSize().getValue());
         if ("OTU4".equals(prefix)) {
             assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
-                LayerProtocolName.PHOTONICMEDIA.getName(), link.getLayerProtocolName().get(0).getName());
+                LayerProtocolName.PHOTONICMEDIA.getName(),
+                link.getLayerProtocolName().stream().findFirst().get().getName());
         } else if ("ODTU4".equals(prefix)) {
             assertEquals("otn link should be between 2 nodes of protocol layers ODU",
-                LayerProtocolName.ODU.getName(), link.getLayerProtocolName().get(0).getName());
+                LayerProtocolName.ODU.getName(),
+                link.getLayerProtocolName().stream().findFirst().get().getName());
         }
         assertEquals("transitional link should be BIDIRECTIONAL",
             ForwardingDirection.BIDIRECTIONAL, link.getDirection());