Turn NetworkTransactionImpl into a component
[transportpce.git] / tapi / src / test / java / org / opendaylight / transportpce / tapi / topology / ConvertORTopoToTapiTopoTest.java
index 961bd593b68b3e66456475db74f653f3eb74312f..ed2e52638de989f1f09d2bdb59f1f9bb043b3b73 100644 (file)
@@ -35,19 +35,18 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.InstanceIdentifiers;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.common.network.RequestProcessor;
 import org.opendaylight.transportpce.tapi.TapiStringConstants;
 import org.opendaylight.transportpce.tapi.utils.TapiLink;
 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1Builder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1Builder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmTpType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
@@ -162,8 +161,7 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
 
         topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
             Charset.forName("UTF-8"))).toString());
-        networkTransactionService = new NetworkTransactionImpl(
-            new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
+        networkTransactionService = new NetworkTransactionImpl(getDataBroker());
         tapiLink = new TapiLink(networkTransactionService);
         LOG.info("TEST SETUP READY");
     }
@@ -718,8 +716,8 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
             AdministrativeState.UNLOCKED, node.getAdministrativeState());
         assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, node.getLifecycleState());
         assertEquals("operational state should be ENABLED", OperationalState.ENABLED, node.getOperationalState());
-        assertEquals("value-name should be 'dsr/odu node name'",
-            "dsr/odu node name", node.nonnullName().values().stream().findFirst().get().getValueName());
+        assertThat("one value-name should be 'dsr/odu node name'",
+            new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
         assertEquals("dsr node should manage 2 protocol layers : dsr and odu",
             2, node.getLayerProtocolName().size());
         assertThat("dsr node should manage 2 protocol layers : dsr and odu",
@@ -819,12 +817,13 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
             AdministrativeState.UNLOCKED, node.getAdministrativeState());
         assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, node.getLifecycleState());
         assertEquals("operational state should be ENABLED", OperationalState.ENABLED, node.getOperationalState());
-        assertEquals("value-name should be 'dsr/odu node name'",
-            "otsi node name", node.nonnullName().values().stream().findFirst().get().getValueName());
+        assertThat("one value-name should be 'dsr/odu node name'",
+            new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("otsi node name")));
         assertEquals("otsi node should manage a single protocol layer : PHOTONIC_MEDIA",
             1, node.getLayerProtocolName().size());
         assertEquals("otsi node should manage a single protocol layer : PHOTONIC_MEDIA",
-            LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().get(0));
+            LayerProtocolName.PHOTONICMEDIA,
+            node.getLayerProtocolName().stream().findFirst().get());
         List<OwnedNodeEdgePoint> nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
             .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
             .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
@@ -927,7 +926,7 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
             3, nep.getSupportedCepLayerProtocolQualifier().size());
         assertThat("client nep should support 3 kind of cep",
             nep.getSupportedCepLayerProtocolQualifier(),
-            hasItems(ODUTYPEODU2.class, ODUTYPEODU2E.class, DIGITALSIGNALTYPE10GigELAN.class));
+            hasItems(ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, DIGITALSIGNALTYPE10GigELAN.VALUE));
         assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
         checkCommonPartOfNep(nep, false);
         checkSIP(nep, portName, nodeId, extension);
@@ -946,7 +945,7 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
             1, nep.getSupportedCepLayerProtocolQualifier().size());
         assertThat("network nep should support 1 kind of cep",
             nep.getSupportedCepLayerProtocolQualifier(),
-            hasItem(ODUTYPEODU4.class));
+            hasItem(ODUTYPEODU4.VALUE));
         assertEquals("network nep should be of ODU protocol type", LayerProtocolName.ODU, nep.getLayerProtocolName());
         checkCommonPartOfNep(nep, false);
         checkSIP(nep, portName, nodeId, extension);
@@ -1145,7 +1144,7 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
             2, nep.getSupportedCepLayerProtocolQualifier().size());
         assertThat("client nep should support 2 kind of cep",
             nep.getSupportedCepLayerProtocolQualifier(),
-            hasItems(ODUTYPEODU4.class, DIGITALSIGNALTYPE100GigE.class));
+            hasItems(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE));
         assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
         checkCommonPartOfNep(nep, false);
         checkSIP(nep, portName, nodeId, extension);
@@ -1163,7 +1162,7 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
             1, nep.getSupportedCepLayerProtocolQualifier().size());
         assertThat("client nep should support 2 kind of cep",
             nep.getSupportedCepLayerProtocolQualifier(),
-            hasItems(DIGITALSIGNALTYPE100GigE.class));
+            hasItems(DIGITALSIGNALTYPE100GigE.VALUE));
         assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
         checkCommonPartOfNep(nep, false);
         checkSIP(nep, portName, nodeId, extension);
@@ -1181,7 +1180,7 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
             2, nep.getSupportedCepLayerProtocolQualifier().size());
         assertThat("OTSi nep should support 2 kind of cep",
             nep.getSupportedCepLayerProtocolQualifier(),
-            hasItems(PHOTONICLAYERQUALIFIEROMS.class, PHOTONICLAYERQUALIFIEROTSi.class));
+            hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE));
         assertEquals("OTSi nep should be of PHOTONIC_MEDIA protocol type",
             LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName());
         assertEquals("OTSi nep should support one SIP", 1, nep.getMappedServiceInterfacePoint().size());
@@ -1208,7 +1207,7 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
             1, nep.getSupportedCepLayerProtocolQualifier().size());
         assertThat("OTSi nep should support 2 kind of cep",
             nep.getSupportedCepLayerProtocolQualifier(),
-            hasItems(PHOTONICLAYERQUALIFIEROMS.class));
+            hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE));
         assertEquals("OTSi nep should be of PHOTONIC_MEDIA protocol type",
             LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName());
         assertEquals("OTSi nep of RDM infra should support no SIP", 0, nep.nonnullMappedServiceInterfacePoint().size());
@@ -1292,10 +1291,12 @@ public class ConvertORTopoToTapiTopoTest 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("otn tapi link should be BIDIRECTIONAL",
             ForwardingDirection.BIDIRECTIONAL, link.getDirection());
@@ -1328,7 +1329,8 @@ public class ConvertORTopoToTapiTopoTest extends AbstractTest {
         assertEquals("bad name for the link", linkName, link.getName().get(new NameKey("OMS link name")).getValue());
         assertEquals("bad uuid for link", linkUuid, link.getUuid());
         assertEquals("oms 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());
         assertEquals("otn tapi link should be BIDIRECTIONAL",
             ForwardingDirection.BIDIRECTIONAL, link.getDirection());
         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210