+ @Test
+ void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ // serviceRestoration is calling service delete method in renderer
+ when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
+ //create service to restore
+ serviceDataStoreOperations.createService(serviceCreateInput);
+ //service Restoration test action
+ //ServiceRestorationInput is created with the same service information that is created before
+ ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
+ new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, rendererServiceWrapper)
+ .invoke(serviceRestorationInput);
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ }
+
+ @Test
+ void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
+ ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
+ new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
+ .invoke(new ServiceRerouteInputBuilder()
+ .setServiceName("")
+ .build());
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ assertEquals(
+ ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
+ //action -> service reconfigure
+ ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
+ new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
+ .invoke(serviceRerouteInput);
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ assertEquals(
+ ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ 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 ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
+ .invoke(serviceRerouteInput);
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ assertEquals(
+ ResponseCodes.RESPONSE_OK,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
+ ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
+ new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ rendererServiceWrapper)
+ .invoke(new TempServiceDeleteInputBuilder()
+ .setCommonId("")
+ .build());
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
+ assertEquals(
+ ResponseCodes.RESPONSE_FAILED,
+ rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
+ assertEquals(
+ LogMessages.SERVICE_NON_COMPLIANT,
+ rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
+ }
+
+ @Test
+ void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
+ ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
+ new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ rendererServiceWrapper)
+ .invoke(ServiceDataUtils.buildTempServiceDeleteInput());
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ assertEquals(
+ ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
+ when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
+ //create temp service to delete in the temp delete action
+ TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
+ serviceDataStoreOperations.createTempService(createInput, pathDescription);
+ ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
+ new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ rendererServiceWrapper)
+ .invoke(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ assertEquals(
+ ResponseCodes.RESPONSE_OK,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
+ ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
+ new TempServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, pceServiceWrapper)
+ .invoke(new TempServiceCreateInputBuilder().build());
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ assertEquals(
+ ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ void tempServiceCreateShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
+ final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
+ when(serviceDSOperations.getTempService(any()))
+ .thenReturn(Optional.of(
+ new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp.service.list
+ .ServicesBuilder()
+ .setCommonId("bad_commonId")
+ .build()));
+ ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
+ new TempServiceCreateImpl(serviceDSOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, pceServiceWrapper)
+ .invoke(ServiceDataUtils.buildTempServiceCreateInput());
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ assertEquals(
+ ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ assertEquals(
+ "Service 'Temp (commonId)' already exists in datastore",
+ result.get().getResult().getConfigurationResponseCommon().getResponseMessage());
+ }
+
+ @Test
+ void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
+ throws ExecutionException, InterruptedException {
+ when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
+ ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
+ new TempServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, pceServiceWrapper)
+ .invoke(ServiceDataUtils.buildTempServiceCreateInput());
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ assertEquals(
+ ResponseCodes.RESPONSE_OK,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
+ throws ExecutionException, InterruptedException {
+ ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
+ new AddOpenroadmOperationalModesToCatalogImpl(catalogDataStoreOperations)
+ .invoke(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
+ throws ExecutionException, InterruptedException {
+ ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
+ new AddSpecificOperationalModesToCatalogImpl(catalogDataStoreOperations)
+ .invoke(new AddSpecificOperationalModesToCatalogInputBuilder().build());
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_FAILED,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
+ throws ExecutionException, InterruptedException {
+ ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
+ new AddOpenroadmOperationalModesToCatalogImpl(catalogDataStoreOperations)
+ .invoke(CatalogDataUtils.buildAddORToCatalogInput());
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_OK,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
+ throws ExecutionException, InterruptedException {
+ ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
+ new AddSpecificOperationalModesToCatalogImpl(catalogDataStoreOperations)
+ .invoke(CatalogDataUtils.buildAddSpecificToCatalogInput());
+ Assert.assertEquals(
+ ResponseCodes.RESPONSE_OK,
+ result.get().getResult().getConfigurationResponseCommon().getResponseCode());