package org.opendaylight.transportpce.servicehandler.impl;
import static org.mockito.ArgumentMatchers.any;
+import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.pce.service.PathComputationService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
+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.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
import org.opendaylight.transportpce.test.AbstractTest;
@Mock
private RendererListenerImpl rendererListenerImpl;
+ @Mock
+ private NetworkModelListenerImpl networkModelListenerImpl;
+
+ private ServiceDataStoreOperations serviceDataStoreOperations;
private ListeningExecutorService executorService;
private CountDownLatch endSignal;
private static final int NUM_THREADS = 5;
executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
endSignal = new CountDownLatch(1);
callbackRan = false;
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
+ this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
}
@Test
public void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceCreateOutput>> result =
servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build());
result.addListener(new Runnable() {
Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(input);
result.addListener(new Runnable() {
@Override
public void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
- servicehandlerImpl.serviceDelete(new ServiceDeleteInputBuilder()
+ servicehandlerImpl.serviceDelete(new ServiceDeleteInputBuilder()
.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("").build()).build());
result.addListener(new Runnable() {
@Override
ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput();
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(input);
result.addListener(new Runnable() {
@Override
@Test
public void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
DataBroker dataBroker = getNewDataBroker();
- Mockito.when(rendererServiceOperations.serviceDelete(any())).thenReturn(Futures.immediateFuture(any()));
+ Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
- ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
serviceDataStoreOperations.createService(createInput);
ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput();
public void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
result.addListener(new Runnable() {
Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
servicehandlerImpl.serviceFeasibilityCheck(input);
result.addListener(new Runnable() {
public void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
result.addListener(new Runnable() {
//action -> service reconfigure
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(input);
result.addListener(new Runnable() {
//mocking
// serviceReconfigure is calling service delete method in renderer
- Mockito.when(rendererServiceOperations.serviceDelete(any())).thenReturn(Futures.immediateFuture(any()));
+ Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
//create service to reconfigure
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
- ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
serviceDataStoreOperations.createService(createInput);
public void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
servicehandlerImpl.serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
result.addListener(new Runnable() {
//action -> service restore
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(input);
result.addListener(new Runnable() {
//mocking
// serviceRestoration is calling service delete method in renderer
- Mockito.when(rendererServiceOperations.serviceDelete(any())).thenReturn(Futures.immediateFuture(any()));
+ Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
//create service to restore
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
- ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
serviceDataStoreOperations.createService(createInput);
public void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
result.addListener(new Runnable() {
//action -> service reconfigure
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(input);
result.addListener(new Runnable() {
//mocking
// serviceReroute is calling service delete method in renderer
- Mockito.when(rendererServiceOperations.serviceDelete(any())).thenReturn(Futures.immediateFuture(any()));
+ 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, null);
- ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
serviceDataStoreOperations.createService(createInput);
public void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder()
.setCommonId("").build());
Assert.assertEquals(
ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
Assert.assertEquals(
- "Service not compliant !", rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
+ LogMessages.SERVICE_NON_COMPLIANT,
+ rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
}
@Test
TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput();
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
result.addListener(new Runnable() {
@Override
@Test
public void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
DataBroker dataBroker = getNewDataBroker();
- Mockito.when(rendererServiceOperations.serviceDelete(any())).thenReturn(Futures.immediateFuture(any()));
+ 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, null);
- ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
serviceDataStoreOperations.createTempService(createInput);
public void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
result.addListener(new Runnable() {
ServicehandlerImpl servicehandlerImpl =
new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
+ notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, "ServiceHandler");
ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(input);
result.addListener(new Runnable() {