+ Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
+ ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
+ rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, serviceDataStoreOperations);
+ serviceDataStoreOperations.createService(serviceCreateInput);
+ ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
+ result.addListener(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_OK, result.get().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(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
+ throws ExecutionException, InterruptedException {
+ 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(ServiceDataUtils.buildServiceFeasibilityCheckInput());
+ result.addListener(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_OK, result.get().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(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ }
+
+
+ @Test
+ public void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
+ //action -> service reconfigure
+ ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
+ rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
+ serviceReconfigureInput);
+
+ result.addListener(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ }
+
+ @Test
+ public void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ // 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(getNewDataBroker(), pathComputationService,
+ rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, serviceDataStoreOperations);
+ serviceDataStoreOperations.createService(serviceCreateInput);
+
+ //service reconfigure test action
+ //ServiceReconfigureInput is created with the same service information that is created before
+ ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
+ serviceReconfigureInput);
+ result.addListener(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ }
+
+ @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(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ }
+
+
+ @Test
+ public void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
+ //action -> service restore
+ ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
+ rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
+ serviceRestorationInput);
+
+ result.addListener(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ }
+
+ @Test
+ public void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ // 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(getNewDataBroker(), pathComputationService,
+ rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, serviceDataStoreOperations);
+ serviceDataStoreOperations.createService(serviceCreateInput);
+
+ //service Restoration test action
+ //ServiceRestorationInput is created with the same service information that is created before
+ ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
+ serviceRestorationInput);
+ result.addListener(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ }
+
+ @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(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
+ //action -> service reconfigure
+ ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
+ rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, serviceDataStoreOperations);
+ ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(
+ serviceRerouteInput);
+
+ result.addListener(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ Mockito.when(pathComputationService.pathComputationRerouteRequest(any()))
+ .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
+ .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
+ .setResponseCode(ResponseCodes.RESPONSE_OK)
+ .build())
+ .build()));
+ Map<AToZKey, AToZ> atoz = Map.of(
+ new AToZKey("0"),
+ new AToZBuilder()
+ .setId("0")
+ .setResource(new ResourceBuilder()
+ .setResource(new TerminationPointBuilder()
+ .setTpNodeId("tpNodeIdC")
+ .setTpId("TpIdC1")
+ .build())
+ .setState(State.InService)
+ .build())
+ .build(),
+ new AToZKey("1"),
+ new AToZBuilder()
+ .setId("1")
+ .setResource(new ResourceBuilder()
+ .setResource(new TerminationPointBuilder()
+ .setTpNodeId("tpNodeIdD")
+ .setTpId("TpIdCD")
+ .build())
+ .setState(State.InService)
+ .build())
+ .build(), new AToZKey("2"),
+ new AToZBuilder()
+ .setId("2")
+ .setResource(new ResourceBuilder()
+ .setResource(new TerminationPointBuilder()
+ .setTpNodeId("tpNodeIdA")
+ .setTpId("TpIdA1")
+ .build())
+ .setState(State.InService)
+ .build())
+ .build()
+
+ );
+ serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
+ new PathComputationRequestOutputBuilder()
+ .setResponseParameters(new ResponseParametersBuilder()
+ .setPathDescription(new PathDescriptionBuilder()
+ .setAToZDirection(new AToZDirectionBuilder()
+ .setAToZ(atoz)
+ .setRate(Uint32.valueOf(1))
+ .build())
+ .setZToADirection(new ZToADirectionBuilder()
+ .setRate(Uint32.valueOf(1))
+ .build())
+ .build())
+ .build())
+ .build());
+
+ serviceDataStoreOperations.createService(serviceCreateInput);
+ ListenableFuture<RpcResult<ServiceRerouteOutput>> result = new ServicehandlerImpl(getNewDataBroker(),
+ pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl,
+ rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations)
+ .serviceReroute(serviceRerouteInput);
+ result.addListener(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @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(() -> 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 {
+ ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
+ rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, serviceDataStoreOperations);
+ ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(
+ ServiceDataUtils.buildTempServiceDeleteInput());
+ result.addListener(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
+
+ //create temp service to delete in the temp delete action
+ ServicehandlerImpl servicehandlerImpl =
+ new ServicehandlerImpl(getNewDataBroker(), 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(() -> endSignal.countDown(), executorService);
+
+ endSignal.await();
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());