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 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;
@ExtendWith(MockitoExtension.class)
public class ServicehandlerImplTest extends AbstractTest {
+ @Mock
+ private RpcProviderService rpcProviderService;
@Mock
private PathComputationService pathComputationService;
@Mock
pathDescription = ServiceDataUtils.createPathDescription(0,1,0,1);
}
+ @Test
+ void testRpcRegistration() {
+ new ServicehandlerImpl(rpcProviderService,
+ pathComputationService, rendererServiceOperations, notificationPublishService,
+ pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, catalogDataStoreOperations);
+ verify(rpcProviderService, times(1)).registerRpcImplementations(any());
+ }
+
@Test
void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<ServiceCreateOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
.setServiceName(serviceCreateInput.getServiceName())
.build()));
ListenableFuture<RpcResult<ServiceCreateOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDSOperations, catalogDataStoreOperations)
void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
ListenableFuture<RpcResult<ServiceCreateOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
@Test
void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
@Test
void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
serviceDataStoreOperations.createService(serviceCreateInput);
ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
@Test
void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
- ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
+ ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(rpcProviderService, pathComputationService,
rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
throws ExecutionException, InterruptedException {
when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
@Test
void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
//action -> service reconfigure
ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
//service reconfigure test action
//ServiceReconfigureInput is created with the same service information that is created before
ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
@Test
void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
//action -> service restore
ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
//service Restoration test action
//ServiceRestorationInput is created with the same service information that is created before
ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
@Test
void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
//action -> service reconfigure
ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
.build());
serviceDataStoreOperations.createService(serviceCreateInput);
ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
@Test
void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
@Test
void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
serviceDataStoreOperations.createTempService(createInput, pathDescription);
ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
@Test
void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
.setCommonId("bad_commonId")
.build()));
ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDSOperations, catalogDataStoreOperations)
throws ExecutionException, InterruptedException {
when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)
public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
- new ServicehandlerImpl(
+ new ServicehandlerImpl(rpcProviderService,
pathComputationService, rendererServiceOperations, notificationPublishService,
pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
serviceDataStoreOperations, catalogDataStoreOperations)