+ 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, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
+ servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceFeasibilityCheckOutput> 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, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
+ servicehandlerImpl.serviceFeasibilityCheck(input);
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceFeasibilityCheckOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
+ servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceReconfigureOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ RpcStatus.Failed, rpcResult.getResult().getStatus());
+ }
+
+
+ @Test
+ public void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
+ ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput();
+
+ //action -> service reconfigure
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(input);
+
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceReconfigureOutput> rpcResult = result.get();
+ //ServiceReconfigureOutput doesn't have ConfigurationResponseCommon but have RpcStatus directly
+ Assert.assertEquals(
+ RpcStatus.Failed, rpcResult.getResult().getStatus());
+ }
+
+ @Test
+ public void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ DataBroker dataBroker = getNewDataBroker();
+
+ //mocking
+ // serviceReconfigure is calling service delete method in renderer
+ Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
+ //create service to reconfigure
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
+ serviceDataStoreOperations.createService(createInput);
+
+ //service reconfigure test action
+ ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput();
+ //ServiceReconfigureInput is created with the same service information that is created before
+ ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(input);
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceReconfigureOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ RpcStatus.Successful, rpcResult.getResult().getStatus());
+ }
+
+ @Test
+ public void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
+ servicehandlerImpl.serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceRestorationOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ RpcStatus.Failed, rpcResult.getResult().getStatus());
+ }
+
+
+ @Test
+ public void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
+ ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
+
+ //action -> service restore
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(input);
+
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceRestorationOutput> rpcResult = result.get();
+ //ServiceRestorationOutput doesn't have ConfigurationResponseCommon but have RpcStatus directly
+ Assert.assertEquals(
+ RpcStatus.Failed, rpcResult.getResult().getStatus());
+ }
+
+ @Test
+ public void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ DataBroker dataBroker = getNewDataBroker();
+
+ //mocking
+ // serviceRestoration is calling service delete method in renderer
+ Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
+ //create service to restore
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
+ serviceDataStoreOperations.createService(createInput);
+
+ //service Restoration test action
+ ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
+ //ServiceRestorationInput is created with the same service information that is created before
+ ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(input);
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceRestorationOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ RpcStatus.Successful, rpcResult.getResult().getStatus());
+ }
+
+ @Test
+ public void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
+ servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceRerouteOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ RpcStatus.Failed, rpcResult.getResult().getStatus());
+ }
+
+ @Test
+ public void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
+ ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
+
+ //action -> service reconfigure
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(input);
+
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceRerouteOutput> rpcResult = result.get();
+ //ServiceRerouteOutput doesn't have ConfigurationResponseCommon but have RpcStatus directly
+ Assert.assertEquals(
+ RpcStatus.Failed, rpcResult.getResult().getStatus());
+ }
+
+ @Test
+ public void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ DataBroker dataBroker = getNewDataBroker();
+
+ //mocking
+ // serviceReroute is calling service delete method in renderer
+ Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
+ //create service to be rerouted later
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
+ serviceDataStoreOperations.createService(createInput);
+
+ //service reroute test action
+ ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
+ //ServiceRerouteInput is created with the same service information that is created before
+ ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(input);
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<ServiceRerouteOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ RpcStatus.Successful, rpcResult.getResult().getStatus());
+ }
+
+ @Test
+ public void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
+ servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder()
+ .setCommonId("").build());
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
+ Assert.assertEquals(
+ LogMessages.SERVICE_NON_COMPLIANT,
+ rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
+ }
+
+ @Test
+ public void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
+ TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput();
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ DataBroker dataBroker = getNewDataBroker();
+ Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
+
+ //create temp service to delete in the temp delete action
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations);
+ TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
+ serviceDataStoreOperations.createTempService(createInput);
+
+
+ TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId());
+ ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
+ result.addListener(new Runnable() {
+ @Override
+ public void run() {
+ endSignal.countDown();
+ }
+ }, executorService);
+
+ endSignal.await();
+
+ RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());