import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
+import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
import org.opendaylight.transportpce.pce.service.PathComputationService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
import org.opendaylight.transportpce.servicehandler.ServiceInput;
-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.catalog.CatalogDataStoreOperations;
+import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperationsImpl;
+import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener;
+import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
+import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
+import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
+import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
+import org.opendaylight.transportpce.servicehandler.utils.CatalogDataUtils;
import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.ResourceBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPointBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.delete.input.ServiceDeleteReqInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.ServicesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@ExtendWith(MockitoExtension.class)
public class ServicehandlerImplTest extends AbstractTest {
-
+ @Mock
+ private RpcProviderService rpcProviderService;
@Mock
private PathComputationService pathComputationService;
@Mock
@Mock
private NotificationPublishService notificationPublishService;
@Mock
- private PceListenerImpl pceListenerImpl;
+ private PceListener pceListenerImpl;
@Mock
- private RendererListenerImpl rendererListenerImpl;
+ private RendererListener rendererListenerImpl;
@Mock
- private NetworkModelListenerImpl networkModelListenerImpl;
+ private NetworkListener networkModelListenerImpl;
+ @Mock
+ private PathDescription pathDescription;
private ServiceDataStoreOperations serviceDataStoreOperations;
+ private CatalogDataStoreOperations catalogDataStoreOperations;
private ServiceCreateInput serviceCreateInput;
private ServiceDeleteInput serviceDeleteInput;
private ServiceReconfigureInput serviceReconfigureInput;
private ListeningExecutorService executorService;
private CountDownLatch endSignal;
private static final int NUM_THREADS = 5;
+ private PCEServiceWrapper pceServiceWrapper;
+ private RendererServiceWrapper rendererServiceWrapper;
@BeforeEach
void setUp() {
executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
endSignal = new CountDownLatch(1);
this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
+ this.catalogDataStoreOperations =
+ new CatalogDataStoreOperationsImpl(new NetworkTransactionImpl(getDataBroker()));
serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
+ pathDescription = ServiceDataUtils.createPathDescription(0,1,0,1);
+ pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
+ this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
}
+ @Test
+ void testRpcRegistration() {
+ new ServicehandlerImpl(rpcProviderService, serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, catalogDataStoreOperations, pathComputationService, rendererServiceOperations,
+ notificationPublishService);
+ verify(rpcProviderService, times(1)).registerRpcImplementations(any());
+ }
+
+// @Test
+// void testNotImplementedRpc() throws InterruptedException, ExecutionException {
+// ListenableFuture<RpcResult<ServiceSrlgGetOutput>> result = new ServicehandlerImpl(rpcProviderService,
+// serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+// catalogDataStoreOperations, pathComputationService, rendererServiceOperations,
+// notificationPublishService)
+// .serviceSrlgGet(new ServiceSrlgGetInputBuilder().build());
+//
+// result.addListener(() -> endSignal.countDown(), executorService);
+// endSignal.await();
+// assertNotNull(result.get());
+// assertFalse(result.get().isSuccessful());
+// assertNull(result.get().getResult());
+// assertEquals(ErrorType.RPC, result.get().getErrors().get(0).getErrorType());
+// assertEquals(ErrorSeverity.ERROR, result.get().getErrors().get(0).getSeverity());
+// assertEquals(ErrorTag.OPERATION_NOT_SUPPORTED, result.get().getErrors().get(0).getTag());
+// assertEquals("RPC not implemented yet", result.get().getErrors().get(0).getMessage());
+// }
+
@Test
void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
- rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
- ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl
- .serviceCreate(new ServiceCreateInputBuilder().build());
+ ListenableFuture<RpcResult<ServiceCreateOutput>> result =
+ new ServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
+ .invoke(new ServiceCreateInputBuilder().build());
result.addListener(() -> endSignal.countDown(), executorService);
endSignal.await();
assertEquals(
}
@Test
- void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException,
- InterruptedException {
+ void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
.thenReturn(Optional.of(
new ServicesBuilder()
.setServiceName(serviceCreateInput.getServiceName())
.build()));
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
- rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDSOperations);
- ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
+ ListenableFuture<RpcResult<ServiceCreateOutput>> result =
+ new ServiceCreateImpl(serviceDSOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
+ .invoke(serviceCreateInput);
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
assertEquals(
ResponseCodes.RESPONSE_FAILED,
}
@Test
- void createServiceShouldBeSuccessfulWhenPerformPCESuccessful()
- throws ExecutionException, InterruptedException {
+ void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
- rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
- ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
+ ListenableFuture<RpcResult<ServiceCreateOutput>> result =
+ new ServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
+ .invoke(serviceCreateInput);
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
assertEquals(
ResponseCodes.RESPONSE_OK,
@Test
void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
- rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
- ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(
- new ServiceDeleteInputBuilder()
- .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
- .setServiceName("")
- .build())
- .build());
+ ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
+ new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
+ .invoke(new ServiceDeleteInputBuilder()
+ .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
+ .setServiceName("")
+ .build())
+ .build());
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
assertEquals(
ResponseCodes.RESPONSE_FAILED,
@Test
void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
- ServicehandlerImpl servicehandlerImpl =
- new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
- serviceDataStoreOperations);
- ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
+ ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
+ new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
+ .invoke(serviceDeleteInput);
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
assertEquals(
ResponseCodes.RESPONSE_FAILED,
@Test
void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
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);
+ ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
+ new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
+ .invoke(serviceDeleteInput);
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
assertEquals(
ResponseCodes.RESPONSE_OK,
result.get().getResult().getConfigurationResponseCommon().getResponseCode());
}
-
@Test
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());
+ new ServiceFeasibilityCheckImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, pceServiceWrapper)
+ .invoke(new ServiceFeasibilityCheckInputBuilder().build());
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
assertEquals(
ResponseCodes.RESPONSE_FAILED,
void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
throws ExecutionException, InterruptedException {
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());
+ new ServiceFeasibilityCheckImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, pceServiceWrapper)
+ .invoke(ServiceDataUtils.buildServiceFeasibilityCheckInput());
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
assertEquals(
ResponseCodes.RESPONSE_OK,
@Test
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());
+ new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, rendererServiceWrapper)
+ .invoke(new ServiceReconfigureInputBuilder().setServiceName("").build());
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
}
@Test
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);
-
+ ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
+ new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, rendererServiceWrapper)
+ .invoke(serviceReconfigureInput);
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
}
// serviceReconfigure is calling service delete method in renderer
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);
+ ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
+ new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, rendererServiceWrapper)
+ .invoke(serviceReconfigureInput);
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
}
@Test
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());
+ ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
+ new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, rendererServiceWrapper)
+ .invoke(new ServiceRestorationInputBuilder()
+ .setServiceName("")
+ .build());
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
}
-
@Test
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);
-
+ ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
+ new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, rendererServiceWrapper)
+ .invoke(serviceRestorationInput);
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
}
// serviceRestoration is calling service delete method in renderer
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);
+ 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 {
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
- rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
- servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
+ 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
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
- rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
- ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl
- .serviceReroute(serviceRerouteInput);
-
+ 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());
.build())
.build())
.build());
-
serviceDataStoreOperations.createService(serviceCreateInput);
- ListenableFuture<RpcResult<ServiceRerouteOutput>> result = new ServicehandlerImpl(getNewDataBroker(),
- pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl,
- rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations)
- .serviceReroute(serviceRerouteInput);
+ 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 {
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
- rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
- servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder().setCommonId("").build());
+ 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,
@Test
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());
+ ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
+ new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
+ rendererServiceWrapper)
+ .invoke(ServiceDataUtils.buildTempServiceDeleteInput());
result.addListener(() -> endSignal.countDown(), executorService);
-
endSignal.await();
assertEquals(
ResponseCodes.RESPONSE_FAILED,
@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
- 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);
+ 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,
@Test
void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
- rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
- servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
+ 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()));
-
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
- rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
-
- ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(
- ServiceDataUtils.buildTempServiceCreateInput());
+ 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());
}
-}
\ No newline at end of file
+
+ @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());
+ }
+}