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.InstanceIdentifiers;
import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.pce.service.PathComputationService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
+import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
import org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl;
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.ServiceDataStoreOperations;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiPceListenerImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiRendererListenerImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiServiceHandlerListenerImpl;
+import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler;
+import org.opendaylight.transportpce.tapi.listeners.TapiRendererNotificationHandler;
+import org.opendaylight.transportpce.tapi.listeners.TapiServiceNotificationHandler;
import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
import org.opendaylight.transportpce.tapi.utils.TapiConnectivityDataUtils;
import org.opendaylight.transportpce.tapi.utils.TapiContext;
import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
import org.opendaylight.transportpce.tapi.utils.TapiLink;
+import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
import org.opendaylight.transportpce.test.AbstractTest;
import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceInput;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceOutput;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.DeleteConnectivityServiceInput;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.DeleteConnectivityServiceInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.DeleteConnectivityServiceOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommon;
+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.service.rev230526.OrgOpenroadmServiceService;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityServiceInput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityServiceOutput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.DeleteConnectivityServiceInput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.DeleteConnectivityServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.DeleteConnectivityServiceOutput;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
@Mock
private NotificationPublishService notificationPublishService;
@Mock
- private TapiPceListenerImpl tapipceListenerImpl;
+ private TapiPceNotificationHandler tapipceNotificationHandler;
@Mock
- private TapiRendererListenerImpl tapirendererListenerImpl;
+ private TapiRendererNotificationHandler tapirendererNotificationHandler;
@Mock
- private TapiServiceHandlerListenerImpl tapiserviceHandlerListenerImpl;
+ private TapiServiceNotificationHandler tapiserviceNotificationHandler;
@Mock
private PceListener pceListenerImpl;
@Mock
private RendererListener rendererListenerImpl;
@Mock
private NetworkListener networkModelListenerImpl;
+ @Mock
+ public CatalogDataStoreOperations catalogDataStoreOperations;
+ @Mock
+ private RpcProviderService rpcProviderService;
private static final Logger LOG = LoggerFactory.getLogger(TapiConnectivityImplTest.class);
private static ServiceDataStoreOperations serviceDataStoreOperations;
TapiTopologyDataUtils.PORTMAPPING_FILE);
networkTransactionService = new NetworkTransactionImpl(getDataBroker());
- tapilink = new TapiLink(networkTransactionService);
+ tapilink = new TapiLinkImpl(networkTransactionService);
serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker());
tapiContext = new TapiContext(networkTransactionService);
topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(),
@Test
void createConnServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
- OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+ OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
+ networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
- tapipceListenerImpl, tapirendererListenerImpl);
+ tapipceNotificationHandler, tapirendererNotificationHandler, networkTransactionService);
ListenableFuture<RpcResult<CreateConnectivityServiceOutput>> result =
tapiConnectivity.createConnectivityService(new CreateConnectivityServiceInputBuilder().build());
@Test
void createConnServiceShouldBeSuccessfulWhenPerformPCESuccessful()
throws ExecutionException, InterruptedException {
- OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+ OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
+ networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
CreateConnectivityServiceInput input = TapiConnectivityDataUtils.buildConnServiceCreateInput();
+
when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
- tapipceListenerImpl, tapirendererListenerImpl);
+ tapipceNotificationHandler, tapirendererNotificationHandler, networkTransactionService);
ListenableFuture<RpcResult<CreateConnectivityServiceOutput>> result =
tapiConnectivity.createConnectivityService(input);
result.addListener(new Runnable() {
}, executorService);
endSignal.await();
-
+ LOG.info("INPUT= {}", input.toString());
RpcResult<CreateConnectivityServiceOutput> rpcResult = result.get();
assertTrue(rpcResult.isSuccessful());
}
@Test
void deleteConnServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
- OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+ OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
+ networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
- tapipceListenerImpl, tapirendererListenerImpl);
+ tapipceNotificationHandler, tapirendererNotificationHandler, networkTransactionService);
ListenableFuture<RpcResult<DeleteConnectivityServiceOutput>> result =
tapiConnectivity.deleteConnectivityService(new DeleteConnectivityServiceInputBuilder().build());
@Test
void deleteConnServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
DeleteConnectivityServiceInput input = TapiConnectivityDataUtils.buildConnServiceDeleteInput1();
- OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+ OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
-
+ networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
- tapipceListenerImpl, tapirendererListenerImpl);
+ tapipceNotificationHandler, tapirendererNotificationHandler, networkTransactionService);
ListenableFuture<RpcResult<DeleteConnectivityServiceOutput>> result =
tapiConnectivity.deleteConnectivityService(input);
result.addListener(new Runnable() {
@Test
void deleteConnServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
- when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
-
- OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+ ConfigurationResponseCommon crc = new ConfigurationResponseCommonBuilder()
+ .setRequestId("request 1")
+ .setResponseCode("OK")
+ .setAckFinalIndicator("requestProcessed").build();
+ ServiceDeleteOutput sdo = new ServiceDeleteOutputBuilder()
+ .setConfigurationResponseCommon(crc)
+ .build();
+ when(rendererServiceOperations.serviceDelete(any(), any()))
+ .thenReturn(Futures.immediateFuture(sdo));
+
+ OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
- networkModelListenerImpl, serviceDataStoreOperations);
+ networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
- tapipceListenerImpl, tapirendererListenerImpl);
-
+ tapipceNotificationHandler, tapirendererNotificationHandler, networkTransactionService);
ServiceCreateInput createInput = TapiConnectivityDataUtils.buildServiceCreateInput();
serviceDataStoreOperations.createService(createInput);
tapiContext.updateConnectivityContext(TapiConnectivityDataUtils.createConnService(), new HashMap<>());
-
DeleteConnectivityServiceInput input = TapiConnectivityDataUtils.buildConnServiceDeleteInput();
ListenableFuture<RpcResult<DeleteConnectivityServiceOutput>> result =
tapiConnectivity.deleteConnectivityService(input);
}, executorService);
endSignal.await();
-
+ LOG.debug("RESULT = {}", result.toString());
RpcResult<DeleteConnectivityServiceOutput> rpcResult = result.get();
assertTrue(rpcResult.isSuccessful());
}
-}
\ No newline at end of file
+}