From: Ahmed Abbas Date: Mon, 24 Jun 2019 13:15:43 +0000 (+0200) Subject: UT for ServicehandlerImpl update X-Git-Tag: 0.4.0~54 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=2113e0dd676d84d008eb35964e453085dd889c33;p=transportpce.git UT for ServicehandlerImpl update UT for method serviceFeasibilityCheck Change-Id: I7e61e48410049289f4688e1deade4725e1e7b010 Signed-off-by: Ahmed Abbas --- 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 69cc71bd0..793402ac6 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 @@ -40,6 +40,9 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -190,4 +193,55 @@ public class ServicehandlerImplTest extends AbstractTest { Assert.assertEquals( ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode()); } + + + @Test + public void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { + ServicehandlerImpl servicehandlerImpl = + new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, + notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + ListenableFuture> result = + servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build()); + result.addListener(new Runnable() { + @Override + public void run() { + callbackRan = true; + endSignal.countDown(); + } + }, executorService); + + endSignal.await(); + + RpcResult rpcResult = result.get(); + Assert.assertEquals( + ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode()); + } + + @Test + public void serviceFeasibilityCheckShouldBeSuccessfulWhenPreformPCESuccessful() + throws ExecutionException, InterruptedException { + ServiceFeasibilityCheckInput input = ServiceDataUtils.buildServiceFeasibilityCheckInput(); + Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any())); + ServicehandlerImpl servicehandlerImpl = + new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, + notificationPublishService, pceListenerImpl, rendererListenerImpl, null); + ListenableFuture> result = + servicehandlerImpl.serviceFeasibilityCheck(input); + result.addListener(new Runnable() { + @Override + public void run() { + callbackRan = true; + endSignal.countDown(); + } + }, executorService); + + endSignal.await(); + + RpcResult rpcResult = result.get(); + Assert.assertEquals( + ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode()); + } + + + }