X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=servicehandler%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fservicehandler%2Fimpl%2FServicehandlerImplTest.java;h=f023384dbdbf5a3e1d839207b107b31030c1d19c;hb=61a429b5b722d038a03c56645b0b56907203c540;hp=a7e139c21f0129bfc992053247f5ed42f67d8a8b;hpb=2df235e965f3b4ff99f2e7bfc5a2911869c97c03;p=transportpce.git diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java index a7e139c21..f023384db 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java @@ -28,8 +28,10 @@ import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.transportpce.common.ResponseCodes; import org.opendaylight.transportpce.pce.service.PathComputationService; import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations; +import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl; import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl; import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl; +import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl; import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils; import org.opendaylight.transportpce.test.AbstractTest; @@ -78,30 +80,33 @@ public class ServicehandlerImplTest extends AbstractTest { @Mock private RendererListenerImpl rendererListenerImpl; + @Mock + private NetworkModelListenerImpl networkModelListenerImpl; + + private ServiceDataStoreOperations serviceDataStoreOperations; private ListeningExecutorService executorService; private CountDownLatch endSignal; private static final int NUM_THREADS = 5; - private boolean callbackRan; @Before public void setUp() { executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS)); endSignal = new CountDownLatch(1); - callbackRan = false; - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); + this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker()); } @Test public void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build()); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -120,12 +125,12 @@ public class ServicehandlerImplTest extends AbstractTest { Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any())); ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceCreate(input); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -141,14 +146,14 @@ public class ServicehandlerImplTest extends AbstractTest { public void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceDelete(new ServiceDeleteInputBuilder() .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("").build()).build()); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -165,12 +170,12 @@ public class ServicehandlerImplTest extends AbstractTest { ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput(); ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceDelete(input); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -188,8 +193,8 @@ public class ServicehandlerImplTest extends AbstractTest { Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any())); ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); - ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput(); serviceDataStoreOperations.createService(createInput); ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput(); @@ -197,7 +202,6 @@ public class ServicehandlerImplTest extends AbstractTest { result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -214,13 +218,13 @@ public class ServicehandlerImplTest extends AbstractTest { public void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build()); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -239,13 +243,13 @@ public class ServicehandlerImplTest extends AbstractTest { Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any())); ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceFeasibilityCheck(input); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -261,13 +265,13 @@ public class ServicehandlerImplTest extends AbstractTest { public void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build()); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -287,13 +291,13 @@ public class ServicehandlerImplTest extends AbstractTest { //action -> service reconfigure ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceReconfigure(input); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -316,8 +320,8 @@ public class ServicehandlerImplTest extends AbstractTest { //create service to reconfigure ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); - ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput(); serviceDataStoreOperations.createService(createInput); @@ -328,7 +332,6 @@ public class ServicehandlerImplTest extends AbstractTest { result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -344,13 +347,13 @@ public class ServicehandlerImplTest extends AbstractTest { public void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build()); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -370,13 +373,13 @@ public class ServicehandlerImplTest extends AbstractTest { //action -> service restore ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceRestoration(input); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -399,8 +402,8 @@ public class ServicehandlerImplTest extends AbstractTest { //create service to restore ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); - ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput(); serviceDataStoreOperations.createService(createInput); @@ -411,7 +414,6 @@ public class ServicehandlerImplTest extends AbstractTest { result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -427,13 +429,13 @@ public class ServicehandlerImplTest extends AbstractTest { public void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build()); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -452,13 +454,13 @@ public class ServicehandlerImplTest extends AbstractTest { //action -> service reconfigure ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceReroute(input); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -481,8 +483,8 @@ public class ServicehandlerImplTest extends AbstractTest { //create service to be rerouted later ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); - ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput(); serviceDataStoreOperations.createService(createInput); @@ -493,7 +495,6 @@ public class ServicehandlerImplTest extends AbstractTest { result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -509,14 +510,14 @@ public class ServicehandlerImplTest extends AbstractTest { public void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder() .setCommonId("").build()); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -536,12 +537,12 @@ public class ServicehandlerImplTest extends AbstractTest { TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(); ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.tempServiceDelete(input); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -561,8 +562,8 @@ public class ServicehandlerImplTest extends AbstractTest { //create temp service to delete in the temp delete action ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); - ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput(); serviceDataStoreOperations.createTempService(createInput); @@ -572,7 +573,6 @@ public class ServicehandlerImplTest extends AbstractTest { result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -588,13 +588,13 @@ public class ServicehandlerImplTest extends AbstractTest { public void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build()); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService); @@ -615,13 +615,13 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, - notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.tempServiceCreate(input); result.addListener(new Runnable() { @Override public void run() { - callbackRan = true; endSignal.countDown(); } }, executorService);