Adapt TransportPCE code to Sulfur
[transportpce.git] / tapi / src / test / java / org / opendaylight / transportpce / tapi / connectivity / TapiConnectivityImplTest.java
index 013abb37646c1dcfad153bbda66dec480f5c08c4..66b1348250052033d9dc4b7830221b0670d35040 100644 (file)
@@ -43,18 +43,19 @@ import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
 import org.opendaylight.transportpce.tapi.utils.TapiConnectivityDataUtils;
 import org.opendaylight.transportpce.tapi.utils.TapiContext;
 import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
+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.service.rev190531.OrgOpenroadmServiceService;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceInput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceOutput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.DeleteConnectivityServiceInput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.DeleteConnectivityServiceInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.DeleteConnectivityServiceOutput;
-import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -95,10 +96,10 @@ public class TapiConnectivityImplTest extends AbstractTest {
     public static ConnectivityUtils connectivityUtils;
     public static TapiInitialORMapping tapiInitialORMapping;
     public static NetworkTransactionService networkTransactionService;
+    public static TapiLink tapilink;
     private ListeningExecutorService executorService;
     private CountDownLatch endSignal;
     private static final int NUM_THREADS = 5;
-    private boolean callbackRan;
 
     @Before
     public void setUp() throws InterruptedException, ExecutionException {
@@ -114,15 +115,17 @@ public class TapiConnectivityImplTest extends AbstractTest {
         TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
             TapiTopologyDataUtils.PORTMAPPING_FILE);
 
-        callbackRan = false;
         MockitoAnnotations.openMocks(this);
 
         networkTransactionService = new NetworkTransactionImpl(
             new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
+        tapilink = new TapiLink(networkTransactionService);
         serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker());
         tapiContext = new TapiContext(networkTransactionService);
-        topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker());
-        connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext);
+        topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(),
+            tapilink);
+        connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext,
+            networkTransactionService);
         tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
             tapiContext, serviceDataStoreOperations);
         tapiInitialORMapping.performTopoInitialMapping();
@@ -136,14 +139,13 @@ public class TapiConnectivityImplTest extends AbstractTest {
             networkModelListenerImpl, serviceDataStoreOperations);
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl, tapiserviceHandlerListenerImpl);
+            tapipceListenerImpl, tapirendererListenerImpl);
 
         ListenableFuture<RpcResult<CreateConnectivityServiceOutput>> result =
             tapiConnectivity.createConnectivityService(new CreateConnectivityServiceInputBuilder().build());
         result.addListener(new Runnable() {
             @Override
             public void run() {
-                callbackRan = true;
                 endSignal.countDown();
             }
         }, executorService);
@@ -151,8 +153,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
         endSignal.await();
 
         RpcResult<CreateConnectivityServiceOutput> rpcResult = result.get();
-        Assert.assertEquals(
-            RpcError.ErrorType.RPC, rpcResult.getErrors().get(0).getErrorType());
+        Assert.assertEquals(ErrorType.RPC, rpcResult.getErrors().get(0).getErrorType());
     }
 
     @Test
@@ -166,13 +167,12 @@ public class TapiConnectivityImplTest extends AbstractTest {
         Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl, tapiserviceHandlerListenerImpl);
+            tapipceListenerImpl, tapirendererListenerImpl);
         ListenableFuture<RpcResult<CreateConnectivityServiceOutput>> result =
             tapiConnectivity.createConnectivityService(input);
         result.addListener(new Runnable() {
             @Override
             public void run() {
-                callbackRan = true;
                 endSignal.countDown();
             }
         }, executorService);
@@ -190,14 +190,13 @@ public class TapiConnectivityImplTest extends AbstractTest {
             networkModelListenerImpl, serviceDataStoreOperations);
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl, tapiserviceHandlerListenerImpl);
+            tapipceListenerImpl, tapirendererListenerImpl);
 
         ListenableFuture<RpcResult<DeleteConnectivityServiceOutput>> result =
             tapiConnectivity.deleteConnectivityService(new DeleteConnectivityServiceInputBuilder().build());
         result.addListener(new Runnable() {
             @Override
             public void run() {
-                callbackRan = true;
                 endSignal.countDown();
             }
         }, executorService);
@@ -205,8 +204,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
         endSignal.await();
 
         RpcResult<DeleteConnectivityServiceOutput> rpcResult = result.get();
-        Assert.assertEquals(
-            RpcError.ErrorType.RPC, rpcResult.getErrors().get(0).getErrorType());
+        Assert.assertEquals(ErrorType.RPC, rpcResult.getErrors().get(0).getErrorType());
     }
 
     @Test
@@ -217,13 +215,12 @@ public class TapiConnectivityImplTest extends AbstractTest {
             networkModelListenerImpl, serviceDataStoreOperations);
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl, tapiserviceHandlerListenerImpl);
+            tapipceListenerImpl, tapirendererListenerImpl);
         ListenableFuture<RpcResult<DeleteConnectivityServiceOutput>> result =
             tapiConnectivity.deleteConnectivityService(input);
         result.addListener(new Runnable() {
             @Override
             public void run() {
-                callbackRan = true;
                 endSignal.countDown();
             }
         }, executorService);
@@ -231,8 +228,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
         endSignal.await();
 
         RpcResult<DeleteConnectivityServiceOutput> rpcResult = result.get();
-        Assert.assertEquals(
-            RpcError.ErrorType.RPC, rpcResult.getErrors().get(0).getErrorType());
+        Assert.assertEquals(ErrorType.RPC, rpcResult.getErrors().get(0).getErrorType());
     }
 
     @Test
@@ -244,7 +240,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
             networkModelListenerImpl, serviceDataStoreOperations);
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl, tapiserviceHandlerListenerImpl);
+            tapipceListenerImpl, tapirendererListenerImpl);
 
         ServiceCreateInput createInput = TapiConnectivityDataUtils.buildServiceCreateInput();
         serviceDataStoreOperations.createService(createInput);
@@ -256,7 +252,6 @@ public class TapiConnectivityImplTest extends AbstractTest {
         result.addListener(new Runnable() {
             @Override
             public void run() {
-                callbackRan = true;
                 endSignal.countDown();
             }
         }, executorService);