Refine the RPC implementation registration 49/110849/2
authorGilles Thouenon <gilles.thouenon@orange.com>
Mon, 18 Mar 2024 17:45:32 +0000 (18:45 +0100)
committerGilles Thouenon <gilles.thouenon@orange.com>
Tue, 19 Mar 2024 07:48:34 +0000 (08:48 +0100)
- Replace the ClassToInstanceMap argument by a plain varargs with the
RPC implementations when registering RPC to
mdsal.binding.api.RpcProviderService.
- Optimize code by removing classes that have now become almost useless
- adapt the JUnit tests to check exactly which RPC impl are registered

JIRA: TRNSPRTPCE-788
Change-Id: I6014d5f7a4d0447a14ddcac59de6b1d9539677fb
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
23 files changed:
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java [deleted file]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/rpc/CreateNotificationSubscriptionServiceImpl.java
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/rpc/GetNotificationSubscriptionServiceDetailsImpl.java
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/rpc/GetNotificationSubscriptionServiceListImpl.java
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/rpc/GetSupportedNotificationTypesImpl.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetworkUtilsImpl.java
networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/NetworkUtilsImplTest.java
olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImpl.java
pce/src/main/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImpl.java
pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImplTest.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/RendererRPCImpl.java
renderer/src/test/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImplTest.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImpl.java [deleted file]
tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImpl.java [deleted file]
tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java
tapi/src/test/java/org/opendaylight/transportpce/tapi/provider/TapiProviderTest.java
tapi/src/test/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImplTest.java

diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java
deleted file mode 100644 (file)
index 6683139..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.nbinotifications.impl;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.transportpce.common.converter.JsonStringConverter;
-import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.CreateNotificationSubscriptionServiceImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.DeleteNotificationSubscriptionServiceImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationListImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceDetailsImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceListImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsAlarmServiceImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsProcessServiceImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetSupportedNotificationTypesImpl;
-import org.opendaylight.transportpce.nbinotifications.utils.TopicManager;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.GetNotificationsAlarmService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.GetNotificationsProcessService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationAlarmService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationProcessService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationTapiService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.Context1;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.CreateNotificationSubscriptionService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.DeleteNotificationSubscriptionService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationList;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceList;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetSupportedNotificationTypes;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.context.NotificationContext;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Rpc;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NbiNotificationsImpl {
-    private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsImpl.class);
-    private final JsonStringConverter<NotificationProcessService> converterService;
-    private final JsonStringConverter<NotificationAlarmService> converterAlarmService;
-    private final JsonStringConverter<NotificationTapiService> converterTapiService;
-    private final String server;
-    private final NetworkTransactionService networkTransactionService;
-    private final TopicManager topicManager;
-
-    public NbiNotificationsImpl(JsonStringConverter<NotificationProcessService> converterService,
-                                JsonStringConverter<NotificationAlarmService> converterAlarmService,
-                                JsonStringConverter<NotificationTapiService> converterTapiService, String server,
-                                NetworkTransactionService networkTransactionService, TopicManager topicManager) {
-        this.converterService = converterService;
-        this.converterAlarmService = converterAlarmService;
-        this.converterTapiService = converterTapiService;
-        this.server = server;
-        this.networkTransactionService = networkTransactionService;
-        this.topicManager = topicManager;
-    }
-
-    public ImmutableClassToInstanceMap<Rpc<?, ?>> registerRPCs() {
-        return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
-            .put(GetNotificationsProcessService.class, new GetNotificationsProcessServiceImpl(converterService, server))
-            .put(GetNotificationsAlarmService.class,
-                    new GetNotificationsAlarmServiceImpl(converterAlarmService, server))
-            .put(GetSupportedNotificationTypes.class, new GetSupportedNotificationTypesImpl(this))
-            .put(CreateNotificationSubscriptionService.class,
-                    new CreateNotificationSubscriptionServiceImpl(this, topicManager))
-            .put(DeleteNotificationSubscriptionService.class,
-                    new DeleteNotificationSubscriptionServiceImpl(networkTransactionService, topicManager))
-            .put(GetNotificationSubscriptionServiceDetails.class,
-                    new GetNotificationSubscriptionServiceDetailsImpl(this))
-            .put(GetNotificationSubscriptionServiceList.class, new GetNotificationSubscriptionServiceListImpl(this))
-            .put(GetNotificationList.class,
-                    new GetNotificationListImpl(converterTapiService, server, networkTransactionService, topicManager))
-            .build();
-    }
-
-    public NotificationContext getNotificationContext() {
-        LOG.info("Getting tapi notification context");
-        try {
-            InstanceIdentifier<NotificationContext> notificationcontextIID =
-                InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
-                    .child(NotificationContext.class).build();
-            Optional<NotificationContext> notificationContextOptional
-                = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, notificationcontextIID).get();
-            if (!notificationContextOptional.isPresent()) {
-                LOG.error("Could not get TAPI notification context");
-                return null;
-            }
-            return notificationContextOptional.orElseThrow();
-        } catch (InterruptedException | ExecutionException e) {
-            LOG.error("Could not get TAPI notification context");
-        }
-        return null;
-    }
-
-    public boolean updateNotificationContext(NotificationContext notificationContext1) {
-        try {
-            InstanceIdentifier<NotificationContext> notificationcontextIID =
-                InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
-                    .child(NotificationContext.class).build();
-            this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, notificationcontextIID,
-                notificationContext1);
-            this.networkTransactionService.commit().get();
-            return true;
-        } catch (InterruptedException | ExecutionException e) {
-            LOG.error("Could not update TAPI notification context");
-        }
-        return false;
-    }
-
-}
index c26c1478ffd51c4a5be37591b38bc00ac6096acc..7eda70e1e864e439de77a8fc414495aad2444021 100644 (file)
@@ -10,18 +10,33 @@ package org.opendaylight.transportpce.nbinotifications.impl;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.mdsal.binding.api.NotificationService;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.CreateNotificationSubscriptionServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.DeleteNotificationSubscriptionServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationListImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceDetailsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceListImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsAlarmServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsProcessServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetSupportedNotificationTypesImpl;
 import org.opendaylight.transportpce.nbinotifications.listener.NbiNotificationsHandler;
 import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
 import org.opendaylight.transportpce.nbinotifications.utils.TopicManager;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationAlarmService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationProcessService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationTapiService;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.Context1;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.context.NotificationContext;
 import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
@@ -47,6 +62,7 @@ public class NbiNotificationsProvider {
     private static Map<String, Publisher<NotificationAlarmService>> publishersAlarmMap =  new HashMap<>();
     private Registration listenerRegistration;
     private Registration rpcRegistration;
+    private NetworkTransactionService networkTransactionService;
 
     @Activate
     public NbiNotificationsProvider(@Reference RpcProviderService rpcProviderService,
@@ -61,6 +77,7 @@ public class NbiNotificationsProvider {
     public NbiNotificationsProvider(String subscriberServer, String publisherServer,
             RpcProviderService rpcProviderService, NotificationService notificationService,
             BindingDOMCodecServices bindingDOMCodecServices, NetworkTransactionService networkTransactionService) {
+        this.networkTransactionService = networkTransactionService;
         List<String> publishersServiceList = List.of("PceListener", "ServiceHandlerOperations", "ServiceHandler",
                 "RendererListener");
         TopicManager topicManager = TopicManager.getInstance();
@@ -85,9 +102,17 @@ public class NbiNotificationsProvider {
         LOG.info("baozhi tapi converter: {}", converterTapiService);
         topicManager.setTapiConverter(converterTapiService);
 
-        NbiNotificationsImpl nbiImpl = new NbiNotificationsImpl(converterService, converterAlarmService,
-            converterTapiService, subscriberServer, networkTransactionService, topicManager);
-        rpcRegistration = rpcProviderService.registerRpcImplementations(nbiImpl.registerRPCs());
+        rpcRegistration = rpcProviderService.registerRpcImplementations(
+                new GetNotificationsProcessServiceImpl(converterService, subscriberServer),
+                new GetNotificationsAlarmServiceImpl(converterAlarmService, subscriberServer),
+                new GetSupportedNotificationTypesImpl(this),
+                new CreateNotificationSubscriptionServiceImpl(this, topicManager),
+                new DeleteNotificationSubscriptionServiceImpl(networkTransactionService, topicManager),
+                new GetNotificationSubscriptionServiceDetailsImpl(this),
+                new GetNotificationSubscriptionServiceListImpl(this),
+                new GetNotificationListImpl(converterTapiService, subscriberServer, networkTransactionService,
+                        topicManager));
+
         NbiNotificationsHandler notificationsListener = new NbiNotificationsHandler(
             topicManager.getProcessTopicMap(), topicManager.getAlarmTopicMap(), topicManager.getTapiTopicMap());
         listenerRegistration = notificationService.registerCompositeListener(
@@ -111,4 +136,41 @@ public class NbiNotificationsProvider {
         listenerRegistration.close();
         LOG.info("NbiNotificationsProvider Closed");
     }
+
+    public NotificationContext getNotificationContext() {
+        LOG.info("Getting tapi notification context");
+        try {
+            Optional<NotificationContext> notificationContextOptional = this.networkTransactionService.read(
+                    LogicalDatastoreType.OPERATIONAL,
+                    InstanceIdentifier.builder(Context.class)
+                        .augmentation(Context1.class).child(NotificationContext.class)
+                        .build())
+                .get();
+            if (notificationContextOptional.isPresent()) {
+                return notificationContextOptional.orElseThrow();
+            }
+            LOG.debug("notification context is empty");
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Caught exception getting Notification Context", e);
+        }
+        LOG.error("Could not get TAPI notification context");
+        return null;
+    }
+
+    public boolean updateNotificationContext(NotificationContext notificationContext1) {
+        try {
+            this.networkTransactionService.merge(
+                    LogicalDatastoreType.OPERATIONAL,
+                    InstanceIdentifier.builder(Context.class)
+                        .augmentation(Context1.class).child(NotificationContext.class)
+                        .build(),
+                    notificationContext1);
+            this.networkTransactionService.commit().get();
+            return true;
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Could not update TAPI notification context");
+        }
+        return false;
+    }
+
 }
index 9652ad78531c4745ef05fea51687fda5c629c20a..772fb20aeecd63d3c0980c8490a5d2563f0423c8 100644 (file)
@@ -11,7 +11,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
 import org.opendaylight.transportpce.nbinotifications.utils.TopicManager;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.CreateNotificationSubscriptionService;
@@ -38,10 +38,11 @@ import org.slf4j.LoggerFactory;
 public class CreateNotificationSubscriptionServiceImpl implements CreateNotificationSubscriptionService {
     private static final Logger LOG = LoggerFactory.getLogger(CreateNotificationSubscriptionServiceImpl.class);
 
-    private NbiNotificationsImpl nbiNotifications;
+    private NbiNotificationsProvider nbiNotifications;
     private final TopicManager topicManager;
 
-    public CreateNotificationSubscriptionServiceImpl(NbiNotificationsImpl nbiNotifications, TopicManager topicManager) {
+    public CreateNotificationSubscriptionServiceImpl(NbiNotificationsProvider nbiNotifications,
+            TopicManager topicManager) {
         this.nbiNotifications = nbiNotifications;
         this.topicManager = topicManager;
     }
index f75efe2291ef9d64a685099b67ea3b8e789ac937..150616b17e0ee08dc06f16fa8d0907842842c335 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.transportpce.nbinotifications.impl.rpc;
 
 import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetails;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetailsInput;
@@ -26,9 +26,9 @@ import org.slf4j.LoggerFactory;
 public class GetNotificationSubscriptionServiceDetailsImpl implements GetNotificationSubscriptionServiceDetails {
     private static final Logger LOG = LoggerFactory.getLogger(GetNotificationSubscriptionServiceDetailsImpl.class);
 
-    private NbiNotificationsImpl nbiNotifications;
+    private NbiNotificationsProvider nbiNotifications;
 
-    public GetNotificationSubscriptionServiceDetailsImpl(NbiNotificationsImpl nbiNotifications) {
+    public GetNotificationSubscriptionServiceDetailsImpl(NbiNotificationsProvider nbiNotifications) {
         this.nbiNotifications = nbiNotifications;
     }
 
index 7e9c8ba02e3f8c115f4e1188750d4f40979854bb..6eb004a8448136dc5cef590cef7c31f61099ab1d 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.transportpce.nbinotifications.impl.rpc;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.HashMap;
 import java.util.Map;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceList;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceListInput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceListOutput;
@@ -25,9 +25,9 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 public class GetNotificationSubscriptionServiceListImpl implements GetNotificationSubscriptionServiceList {
 
-    private NbiNotificationsImpl nbiNotifications;
+    private NbiNotificationsProvider nbiNotifications;
 
-    public GetNotificationSubscriptionServiceListImpl(NbiNotificationsImpl nbiNotifications) {
+    public GetNotificationSubscriptionServiceListImpl(NbiNotificationsProvider nbiNotifications) {
         this.nbiNotifications = nbiNotifications;
     }
 
index a5d337c0c7daf4c221b5f0ebab1a4277d0384138..91dc75ccc148915529e912ef4fec554b12a8b73d 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.transportpce.nbinotifications.impl.rpc;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.HashSet;
 import java.util.Set;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPE;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPEPROFILE;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPESERVICEINTERFACEPOINT;
@@ -40,9 +40,9 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 public class GetSupportedNotificationTypesImpl implements GetSupportedNotificationTypes {
 
-    private NbiNotificationsImpl nbiNotifications;
+    private NbiNotificationsProvider nbiNotifications;
 
-    public GetSupportedNotificationTypesImpl(NbiNotificationsImpl nbiNotifications) {
+    public GetSupportedNotificationTypesImpl(NbiNotificationsProvider nbiNotifications) {
         this.nbiNotifications = nbiNotifications;
     }
 
index deb7c0b2f57a737064bc8e27971c7968b6c28c6f..91b109b73cd4a66426cbf8c77fc4e14650abcaa0 100644 (file)
@@ -15,6 +15,11 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.ExecutionException;
 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.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
@@ -38,8 +43,15 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev22112
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationListOutput;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
+@ExtendWith(MockitoExtension.class)
 public class NbiNotificationsImplTest extends AbstractTest {
-    private NbiNotificationsImpl nbiNotificationsImpl;
+
+    @Mock
+    RpcProviderService rpcProviderRegistry;
+    @Mock
+    private NotificationService notificationService;
+
+    private NbiNotificationsProvider nbiNotifications;
     public static NetworkTransactionService networkTransactionService;
     private TopicManager topicManager;
     private JsonStringConverter<NotificationProcessService> converterProcess;
@@ -56,8 +68,9 @@ public class NbiNotificationsImplTest extends AbstractTest {
         topicManager.setTapiConverter(converterTapi);
         NotificationServiceDataUtils.createTapiContext(networkTransactionService);
 
-        nbiNotificationsImpl = new NbiNotificationsImpl(converterProcess, converterAlarm, converterTapi,
-            "localhost:8080", networkTransactionService, topicManager);
+        nbiNotifications = new NbiNotificationsProvider("localhost:8080", "localhost:8080",
+                rpcProviderRegistry, notificationService, getDataStoreContextUtil().getBindingDOMCodecServices(),
+                networkTransactionService);
     }
 
     @Test
@@ -95,7 +108,7 @@ public class NbiNotificationsImplTest extends AbstractTest {
     @Test
     void createTapiNotificationSubscriptionServiceTest() throws InterruptedException, ExecutionException {
         ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
-                new CreateNotificationSubscriptionServiceImpl(nbiNotificationsImpl, topicManager)
+                new CreateNotificationSubscriptionServiceImpl(nbiNotifications, topicManager)
             .invoke(NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder().build());
         assertNotNull(result.get().getResult().getSubscriptionService().getUuid().toString(),
             "Should receive UUID for subscription service");
@@ -104,7 +117,7 @@ public class NbiNotificationsImplTest extends AbstractTest {
     @Test
     void getTapiNotificationsServiceTest() throws InterruptedException, ExecutionException {
         ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
-                new CreateNotificationSubscriptionServiceImpl(nbiNotificationsImpl, topicManager)
+                new CreateNotificationSubscriptionServiceImpl(nbiNotifications, topicManager)
             .invoke(NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder().build());
         ListenableFuture<RpcResult<GetNotificationListOutput>> result2 =
                 new GetNotificationListImpl(converterTapi, "localhost:8080", networkTransactionService, topicManager)
index c5b2237729cd35b3f55856bac2cfd916e4985d5d..bed0d1ccde3ecf60cced51ddbf698e9c1dfe5698 100644 (file)
@@ -11,7 +11,6 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import com.google.common.collect.ClassToInstanceMap;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
@@ -20,6 +19,14 @@ import org.opendaylight.mdsal.binding.api.NotificationService;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.CreateNotificationSubscriptionServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.DeleteNotificationSubscriptionServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationListImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceDetailsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceListImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsAlarmServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsProcessServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetSupportedNotificationTypesImpl;
 import org.opendaylight.transportpce.test.AbstractTest;
 
 
@@ -42,7 +49,15 @@ public class NbiNotificationsProviderTest  extends AbstractTest {
         new NbiNotificationsProvider("localhost:8080", "localhost:8080",
                 rpcProviderRegistry, notificationService, getDataStoreContextUtil().getBindingDOMCodecServices(),
                 networkTransactionService);
-        verify(rpcProviderRegistry, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
+        verify(rpcProviderRegistry, times(1)).registerRpcImplementations(
+                any(GetNotificationsProcessServiceImpl.class),
+                any(GetNotificationsAlarmServiceImpl.class),
+                any(GetSupportedNotificationTypesImpl.class),
+                any(CreateNotificationSubscriptionServiceImpl.class),
+                any(DeleteNotificationSubscriptionServiceImpl.class),
+                any(GetNotificationSubscriptionServiceDetailsImpl.class),
+                any(GetNotificationSubscriptionServiceListImpl.class),
+                any(GetNotificationListImpl.class));
         verify(notificationService, times(1))
                 .registerCompositeListener(any(NotificationService.CompositeListener.class));
     }
index fe15de210d8c6915af2952497a9ec4d477e31c9e..8030b9253f5ac51902697d0ccb0bb94b24ee9bfb 100644 (file)
@@ -21,11 +21,14 @@ import org.apache.kafka.clients.producer.MockProducer;
 import org.apache.kafka.common.serialization.StringSerializer;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
 import org.opendaylight.transportpce.nbinotifications.impl.rpc.CreateNotificationSubscriptionServiceImpl;
 import org.opendaylight.transportpce.nbinotifications.serialization.ConfigConstants;
 import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceSerializer;
@@ -45,8 +48,14 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
 
 public class PublisherTest extends AbstractTest {
+
     private static NetworkTransactionService networkTransactionService;
 
+    @Mock
+    RpcProviderService rpcProviderRegistry;
+    @Mock
+    private NotificationService notificationService;
+
     private JsonStringConverter<NotificationProcessService> converterService;
     private JsonStringConverter<NotificationAlarmService> converterAlarm;
     private JsonStringConverter<NotificationTapiService> converterTapiService;
@@ -56,7 +65,7 @@ public class PublisherTest extends AbstractTest {
     private MockProducer<String, NotificationProcessService> mockProducer;
     private MockProducer<String, NotificationAlarmService> mockAlarmProducer;
     private MockProducer<String, NotificationTapiService> mockTapiProducer;
-    private NbiNotificationsImpl nbiNotificationsImpl;
+    private NbiNotificationsProvider nbiNotifications;
     private TopicManager topicManager;
 
 
@@ -85,8 +94,9 @@ public class PublisherTest extends AbstractTest {
         networkTransactionService = new NetworkTransactionImpl(getDataBroker());
         topicManager.setTapiConverter(converterTapiService);
         NotificationServiceDataUtils.createTapiContext(networkTransactionService);
-        nbiNotificationsImpl = new NbiNotificationsImpl(converterService, converterAlarm, converterTapiService,
-            "localhost:8080", networkTransactionService, topicManager);
+        nbiNotifications = new NbiNotificationsProvider("localhost:8080", "localhost:8080",
+                rpcProviderRegistry, notificationService, getDataStoreContextUtil().getBindingDOMCodecServices(),
+                networkTransactionService);
     }
 
     @Test
@@ -121,7 +131,7 @@ public class PublisherTest extends AbstractTest {
             .build();
         builder.setSubscriptionFilter(subscriptionFilter);
 
-        new CreateNotificationSubscriptionServiceImpl(nbiNotificationsImpl, topicManager).invoke(builder.build());
+        new CreateNotificationSubscriptionServiceImpl(nbiNotifications, topicManager).invoke(builder.build());
         String json = Files.readString(Paths.get("src/test/resources/tapi_event.json"));
         NotificationTapiService notificationTapiService = converterTapiService
             .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationTapiService.QNAME),
index e464f75c768dd52aa99d29aed9f6a461ff730d08..9b6287c62ab0634e65d0eb0c4fa8e10d35652317 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.transportpce.networkmodel;
 
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
@@ -44,7 +42,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.top
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkKey;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Rpc;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.osgi.service.component.annotations.Activate;
@@ -64,10 +61,16 @@ public class NetworkUtilsImpl {
     @Activate
     public NetworkUtilsImpl(@Reference DataBroker dataBroker, @Reference RpcProviderService rpcProvider) {
         this.dataBroker = dataBroker;
-        rpcReg = rpcProvider.registerRpcImplementations(getRpcClassToInstanceMap());
+        rpcReg = rpcProvider.registerRpcImplementations(
+                (DeleteLink) this::deleteLink,
+                (InitRoadmNodes) this::initRoadmNodes,
+                (InitXpdrRdmLinks) this::initXpdrRdmLinks,
+                (InitRdmXpdrLinks) this::initRdmXpdrLinks
+                );
         LOG.info("NetworkUtilsImpl instanciated");
     }
 
+
     @Deactivate
     public void close() {
         rpcReg.close();
@@ -158,13 +161,4 @@ public class NetworkUtilsImpl {
             return RpcResultBuilder.<InitRdmXpdrLinksOutput>failed().buildFuture();
         }
     }
-
-    public final ClassToInstanceMap<Rpc<?, ?>> getRpcClassToInstanceMap() {
-        return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
-            .put(DeleteLink.class, this::deleteLink)
-            .put(InitRoadmNodes.class, this::initRoadmNodes)
-            .put(InitXpdrRdmLinks.class, this::initXpdrRdmLinks)
-            .put(InitRdmXpdrLinks.class, this::initRdmXpdrLinks)
-            .build();
-    }
 }
index 5093ad2379fc78ee6f608bfeab174d1b01e1f543..83da135396c5cc84cdace6523147c86c96d782aa 100644 (file)
@@ -11,13 +11,16 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import com.google.common.collect.ClassToInstanceMap;
 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.DataBroker;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.DeleteLink;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.InitRdmXpdrLinks;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.InitRoadmNodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.InitXpdrRdmLinks;
 
 
 @ExtendWith(MockitoExtension.class)
@@ -31,6 +34,8 @@ class NetworkUtilsImplTest {
     void networkUtilsInitTest() {
         new NetworkUtilsImpl(dataBroker, rpcProvider);
 
-        verify(rpcProvider, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
+        verify(rpcProvider, times(1)).registerRpcImplementations(
+                any(DeleteLink.class), any(InitRoadmNodes.class), any(InitXpdrRdmLinks.class),
+                any(InitRdmXpdrLinks.class));
     }
 }
index e3c07e20169a8e6048dd0647a4a0bef9dc22970f..5fd005995ee26de1cfff0360faa6945496f683c2 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.transportpce.olm;
 
-import com.google.common.collect.ImmutableClassToInstanceMap;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossBaseImpl;
 import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossCurrentImpl;
@@ -17,14 +16,7 @@ import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerResetImpl;
 import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerSetupImpl;
 import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerTurndownImpl;
 import org.opendaylight.transportpce.olm.service.OlmPowerService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBase;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrent;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPm;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerReset;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetup;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndown;
 import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Rpc;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
@@ -44,14 +36,12 @@ public class OlmPowerServiceRpcImpl {
     public OlmPowerServiceRpcImpl(@Reference OlmPowerService olmPowerService,
             @Reference RpcProviderService rpcProviderService) {
         this.rpcRegistration = rpcProviderService.registerRpcImplementations(
-                ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
-            .put(GetPm.class, new GetPmImpl(olmPowerService))
-            .put(ServicePowerSetup.class, new ServicePowerSetupImpl(olmPowerService))
-            .put(ServicePowerTurndown.class, new ServicePowerTurndownImpl(olmPowerService))
-            .put(CalculateSpanlossBase.class, new CalculateSpanlossBaseImpl(olmPowerService))
-            .put(CalculateSpanlossCurrent.class, new CalculateSpanlossCurrentImpl(olmPowerService))
-            .put(ServicePowerReset.class, new ServicePowerResetImpl(olmPowerService))
-            .build());
+            new GetPmImpl(olmPowerService),
+            new ServicePowerSetupImpl(olmPowerService),
+            new ServicePowerTurndownImpl(olmPowerService),
+            new CalculateSpanlossBaseImpl(olmPowerService),
+            new CalculateSpanlossCurrentImpl(olmPowerService),
+            new ServicePowerResetImpl(olmPowerService));
         LOG.info("OlmPowerServiceRpcImpl instantiated");
     }
 
index 49f8e71b9d29ff7ca5613774315f34f931b90c2d..56143f4f7a6f548d273684510a01d8fcb2890684 100644 (file)
@@ -7,14 +7,9 @@
  */
 package org.opendaylight.transportpce.pce.impl;
 
-import com.google.common.collect.ImmutableClassToInstanceMap;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserve;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequest;
 import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Rpc;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
@@ -33,11 +28,10 @@ public class PceServiceRPCImpl {
     @Activate
     public PceServiceRPCImpl(@Reference RpcProviderService rpcProviderService,
             @Reference PathComputationService pathComputationService) {
-        this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
-            .put(CancelResourceReserve.class, new CancelResourceReserveImpl(pathComputationService))
-            .put(PathComputationRequest.class, new PathComputationRequestImpl(pathComputationService))
-            .put(PathComputationRerouteRequest.class, new PathComputationRerouteRequestImpl(pathComputationService))
-            .build());
+        this.reg = rpcProviderService.registerRpcImplementations(
+                new CancelResourceReserveImpl(pathComputationService),
+                new PathComputationRequestImpl(pathComputationService),
+                new PathComputationRerouteRequestImpl(pathComputationService));
         LOG.info("PceServiceRPCImpl instantiated");
     }
 
index a90beececd7bbed77ca5b2dcb1d1e8fb1640bc6c..549a708cbbf83f6f9b95d1c54b809f595ed4c275 100644 (file)
@@ -14,7 +14,6 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import com.google.common.collect.ClassToInstanceMap;
 import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -60,7 +59,9 @@ public class PceServiceRPCImplTest extends AbstractTest {
     @Test
     void testRpcRegistration() {
         new PceServiceRPCImpl(rpcProviderService, pathComputationService);
-        verify(rpcProviderService, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
+        verify(rpcProviderService, times(1)).registerRpcImplementations(
+                any(CancelResourceReserveImpl.class), any(PathComputationRequestImpl.class),
+                any(PathComputationRerouteRequestImpl.class));
     }
 
     @Test
index d76d56306bdc5bccc3c2ecceeefd8917adec8ae2..005a32a5aef0f6319bb6cad0e6028ade56ca01f9 100644 (file)
@@ -8,16 +8,10 @@
 
 package org.opendaylight.transportpce.renderer.rpcs;
 
-import com.google.common.collect.ImmutableClassToInstanceMap;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
 import org.opendaylight.transportpce.renderer.provisiondevice.OtnDeviceRendererService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOms;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePath;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollback;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePath;
 import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Rpc;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
@@ -35,12 +29,11 @@ public class DeviceRendererRPCImpl {
     public DeviceRendererRPCImpl(@Reference RpcProviderService rpcProviderService,
             @Reference DeviceRendererService deviceRenderer,
             @Reference OtnDeviceRendererService otnDeviceRendererService) {
-        this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
-            .put(ServicePath.class, new ServicePathImpl(deviceRenderer))
-            .put(OtnServicePath.class, new OtnServicePathImpl(otnDeviceRendererService))
-            .put(RendererRollback.class, new RendererRollbackImpl(deviceRenderer))
-            .put(CreateOtsOms.class, new CreateOtsOmsImpl(deviceRenderer))
-            .build());
+        this.reg = rpcProviderService.registerRpcImplementations(
+                new ServicePathImpl(deviceRenderer),
+                new OtnServicePathImpl(otnDeviceRendererService),
+                new RendererRollbackImpl(deviceRenderer),
+                new CreateOtsOmsImpl(deviceRenderer));
         LOG.debug("RPC of DeviceRendererRPCImpl instantiated");
     }
 
index 864469ca6141a89b414c898c20d7c1f1f02602c8..4cff118ff5bb24fc824b7db39a06e8b1096d763b 100644 (file)
@@ -7,13 +7,9 @@
  */
 package org.opendaylight.transportpce.renderer.rpcs;
 
-import com.google.common.collect.ImmutableClassToInstanceMap;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDelete;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequest;
 import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Rpc;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
@@ -30,10 +26,9 @@ public class RendererRPCImpl {
     @Activate
     public RendererRPCImpl(@Reference RendererServiceOperations rendererServiceOperations,
             @Reference RpcProviderService rpcProviderService) {
-        this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
-            .put(ServiceImplementationRequest.class, new ServiceImplementationRequestImpl(rendererServiceOperations))
-            .put(ServiceDelete.class, new ServiceDeleteImpl(rendererServiceOperations))
-            .build());
+        this.reg = rpcProviderService.registerRpcImplementations(
+                new ServiceImplementationRequestImpl(rendererServiceOperations),
+                new ServiceDeleteImpl(rendererServiceOperations));
         LOG.debug("TransportPCEServicePathRPCImpl instantiated");
     }
 
index b5a0682b4bfe69c30961f91f4748cd01b70c5829..80a81d00c5cc5532637b380a5599630ef93d5667 100644 (file)
@@ -16,7 +16,6 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.BeforeEach;
@@ -70,7 +69,9 @@ public class DeviceRendererRPCImplTest {
     @Test
     void testRpcRegistration() {
         new DeviceRendererRPCImpl(rpcProviderService, deviceRenderer, otnDeviceRendererService);
-        verify(rpcProviderService, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
+        verify(rpcProviderService, times(1)).registerRpcImplementations(
+                any(ServicePathImpl.class), any(OtnServicePathImpl.class), any(RendererRollbackImpl.class),
+                any(CreateOtsOmsImpl.class));
     }
 
     @Test
diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImpl.java
deleted file mode 100644 (file)
index faaf3e3..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.tapi.connectivity;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import org.opendaylight.mdsal.binding.api.RpcService;
-import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.tapi.impl.rpc.CreateConnectivityServiceImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.DeleteConnectivityServiceImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectionDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceListImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler;
-import org.opendaylight.transportpce.tapi.listeners.TapiRendererNotificationHandler;
-import org.opendaylight.transportpce.tapi.utils.TapiContext;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.DeleteConnectivityService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.GetConnectionDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.GetConnectivityServiceDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.GetConnectivityServiceList;
-import org.opendaylight.yangtools.yang.binding.Rpc;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Top level service interface providing main TAPI Connectivity services.
- */
-public class TapiConnectivityImpl {
-    private static final Logger LOG = LoggerFactory.getLogger(TapiConnectivityImpl.class);
-
-    private RpcService rpcService;
-    private final TapiContext tapiContext;
-    private final ConnectivityUtils connectivityUtils;
-    private TapiPceNotificationHandler pceListenerImpl;
-    private TapiRendererNotificationHandler rendererListenerImpl;
-    private final NetworkTransactionService networkTransactionService;
-
-    public TapiConnectivityImpl(RpcService rpcService, TapiContext tapiContext,
-                                ConnectivityUtils connectivityUtils, TapiPceNotificationHandler pceListenerImpl,
-                                TapiRendererNotificationHandler rendererListenerImpl,
-                                NetworkTransactionService networkTransactionService) {
-        LOG.info("inside TapiImpl constructor");
-        this.rpcService = rpcService;
-        this.tapiContext = tapiContext;
-        this.connectivityUtils = connectivityUtils;
-        this.pceListenerImpl = pceListenerImpl;
-        this.rendererListenerImpl = rendererListenerImpl;
-        this.networkTransactionService = networkTransactionService;
-    }
-
-
-    public ImmutableClassToInstanceMap<Rpc<?, ?>> registerRPCs() {
-        return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
-            .put(CreateConnectivityService.class, new CreateConnectivityServiceImpl(rpcService, tapiContext,
-                    connectivityUtils, pceListenerImpl, rendererListenerImpl))
-            .put(GetConnectivityServiceDetails.class, new GetConnectivityServiceDetailsImpl(tapiContext))
-            .put(GetConnectionDetails.class, new GetConnectionDetailsImpl(tapiContext))
-            .put(DeleteConnectivityService.class, new DeleteConnectivityServiceImpl(rpcService, tapiContext,
-                    networkTransactionService))
-            .put(GetConnectivityServiceList.class, new GetConnectivityServiceListImpl(tapiContext))
-            .build();
-    }
-
-}
index 6c3f77a858427a7d85acbdd1f8297331e30a7b2b..f5cb9dd76c2efdc07011114fa9ab90c3d83f30fb 100644 (file)
@@ -22,7 +22,18 @@ import org.opendaylight.transportpce.common.NetworkUtils;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
-import org.opendaylight.transportpce.tapi.connectivity.TapiConnectivityImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.CreateConnectivityServiceImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.DeleteConnectivityServiceImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectionDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceListImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetLinkDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeEdgePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointListImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyListImpl;
 import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelNotificationHandler;
 import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler;
 import org.opendaylight.transportpce.tapi.listeners.TapiRendererNotificationHandler;
@@ -31,7 +42,6 @@ import org.opendaylight.transportpce.tapi.topology.TapiNetconfTopologyListener;
 import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelService;
 import org.opendaylight.transportpce.tapi.topology.TapiOrLinkListener;
 import org.opendaylight.transportpce.tapi.topology.TapiPortMappingListener;
-import org.opendaylight.transportpce.tapi.topology.TapiTopologyImpl;
 import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
 import org.opendaylight.transportpce.tapi.utils.TapiContext;
 import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
@@ -78,7 +88,7 @@ public class TapiProvider {
     private final NetworkTransactionService networkTransactionService;
     private final ServiceDataStoreOperations serviceDataStoreOperations;
     private List<Registration> listeners;
-    private List<Registration> rpcRegistrations = new ArrayList<>();
+    private Registration rpcRegistration;
     private Registration pcelistenerRegistration;
     private Registration rendererlistenerRegistration;
     private Registration servicehandlerlistenerRegistration;
@@ -112,11 +122,20 @@ public class TapiProvider {
         TapiRendererNotificationHandler rendererListenerImpl = new TapiRendererNotificationHandler(dataBroker,
                 notificationPublishService);
 
-        TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(rpcService, tapiContext,
-            connectivityUtils, pceListenerImpl, rendererListenerImpl, networkTransactionService);
-        rpcRegistrations.add(rpcProviderService.registerRpcImplementations(tapiConnectivity.registerRPCs()));
-        TapiTopologyImpl topo = new TapiTopologyImpl(networkTransactionService, tapiContext, topologyUtils, tapiLink);
-        rpcRegistrations.add(rpcProviderService.registerRpcImplementations(topo.registerRPCs()));
+        rpcRegistration = rpcProviderService.registerRpcImplementations(
+                new CreateConnectivityServiceImpl(rpcService, tapiContext, connectivityUtils, pceListenerImpl,
+                        rendererListenerImpl),
+                new GetConnectivityServiceDetailsImpl(tapiContext),
+                new GetConnectionDetailsImpl(tapiContext),
+                new DeleteConnectivityServiceImpl(rpcService, tapiContext, networkTransactionService),
+                new GetConnectivityServiceListImpl(tapiContext),
+                new GetNodeDetailsImpl(tapiContext),
+                new GetTopologyDetailsImpl(tapiContext, topologyUtils, tapiLink, networkTransactionService),
+                new GetNodeEdgePointDetailsImpl(tapiContext),
+                new GetLinkDetailsImpl(tapiContext),
+                new GetTopologyListImpl(tapiContext),
+                new GetServiceInterfacePointDetailsImpl(tapiContext),
+                new GetServiceInterfacePointListImpl(tapiContext));
 
         this.listeners = new ArrayList<>();
         TapiNetconfTopologyListener topologyListener = new TapiNetconfTopologyListener(tapiNetworkModelServiceImpl);
@@ -158,14 +177,12 @@ public class TapiProvider {
         rendererlistenerRegistration.close();
         servicehandlerlistenerRegistration.close();
         tapinetworkmodellistenerRegistration.close();
-        for (Registration reg : rpcRegistrations) {
-            reg.close();
-        }
+        rpcRegistration.close();
         LOG.info("TapiProvider Session Closed");
     }
 
-    public List<Registration> getRegisteredRpcs() {
-        return rpcRegistrations;
+    public Registration getRegisteredRpcs() {
+        return rpcRegistration;
     }
 
 }
diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImpl.java
deleted file mode 100644 (file)
index aabc5f3..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright © 2019 Orange, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.tapi.topology;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetLinkDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeEdgePointDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointListImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyListImpl;
-import org.opendaylight.transportpce.tapi.utils.TapiContext;
-import org.opendaylight.transportpce.tapi.utils.TapiLink;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointList;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyList;
-import org.opendaylight.yangtools.yang.binding.Rpc;
-
-public class TapiTopologyImpl {
-
-    private final NetworkTransactionService networkTransactionService;
-    private final TapiContext tapiContext;
-    private final TopologyUtils topologyUtils;
-    private final TapiLink tapiLink;
-
-    public TapiTopologyImpl(NetworkTransactionService networkTransactionService, TapiContext tapiContext,
-            TopologyUtils topologyUtils, TapiLink tapiLink) {
-        this.networkTransactionService = networkTransactionService;
-        this.tapiContext = tapiContext;
-        this.topologyUtils = topologyUtils;
-        this.tapiLink = tapiLink;
-
-    }
-
-    public ImmutableClassToInstanceMap<Rpc<?, ?>> registerRPCs() {
-        return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
-            .put(GetNodeDetails.class, new GetNodeDetailsImpl(tapiContext))
-            .put(GetTopologyDetails.class, new GetTopologyDetailsImpl(tapiContext, topologyUtils, tapiLink,
-                    networkTransactionService))
-            .put(GetNodeEdgePointDetails.class, new GetNodeEdgePointDetailsImpl(tapiContext))
-            .put(GetLinkDetails.class, new GetLinkDetailsImpl(tapiContext))
-            .put(GetTopologyList.class, new GetTopologyListImpl(tapiContext))
-            .put(GetServiceInterfacePointDetails.class, new GetServiceInterfacePointDetailsImpl(tapiContext))
-            .put(GetServiceInterfacePointList.class, new GetServiceInterfacePointListImpl(tapiContext))
-            .build();
-    }
-
-}
index 294ff66eed043bb79eb407a6ea1fd589ed471b90..8e1313ea9c32e58d7d921ec250771d2d32e29d29 100644 (file)
@@ -142,8 +142,6 @@ public class TapiConnectivityImplTest extends AbstractTest {
         tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
             tapiContext, serviceDataStoreOperations);
         tapiInitialORMapping.performTopoInitialMapping();
-        new TapiConnectivityImpl(rpcService, tapiContext, connectivityUtils,
-                tapipceNotificationHandler, tapirendererNotificationHandler, networkTransactionService);
         LOG.info("setup done");
     }
 
index 535ba90b393b6e94b892373f176af6115d645d8e..4e2a9f22c3e69aad5d6634f1aa0edea5a0c8071f 100644 (file)
@@ -14,7 +14,6 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.opendaylight.mdsal.common.api.CommitInfo.emptyFluentFuture;
 
-import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.util.concurrent.Futures;
 import java.util.Optional;
 import org.junit.jupiter.api.Test;
@@ -29,6 +28,18 @@ import org.opendaylight.mdsal.binding.api.RpcService;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.tapi.impl.TapiProvider;
+import org.opendaylight.transportpce.tapi.impl.rpc.CreateConnectivityServiceImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.DeleteConnectivityServiceImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectionDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceListImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetLinkDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeEdgePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointListImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyListImpl;
 import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelNotificationHandler;
 import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelService;
 
@@ -62,7 +73,19 @@ public class TapiProviderTest {
                 networkTransactionService, serviceDataStoreOperations,
                 tapiNetworkModelNotificationHandler, tapiNetworkModelServiceImpl);
 
-        verify(rpcProviderService, times(2)).registerRpcImplementations(any(ClassToInstanceMap.class));
+        verify(rpcProviderService, times(1)).registerRpcImplementations(
+                any(CreateConnectivityServiceImpl.class),
+                any(GetConnectivityServiceDetailsImpl.class),
+                any(GetConnectionDetailsImpl.class),
+                any(DeleteConnectivityServiceImpl.class),
+                any(GetConnectivityServiceListImpl.class),
+                any(GetNodeDetailsImpl.class),
+                any(GetTopologyDetailsImpl.class),
+                any(GetNodeEdgePointDetailsImpl.class),
+                any(GetLinkDetailsImpl.class),
+                any(GetTopologyListImpl.class),
+                any(GetServiceInterfacePointDetailsImpl.class),
+                any(GetServiceInterfacePointListImpl.class));
         verify(dataBroker, times(4)).registerTreeChangeListener(any(), any());
     }
 }
index 233032238609b2163105d806ba7b2d090c5f3af1..3277b98fde099b7e5c1189200f131d95af8d5763 100644 (file)
@@ -14,7 +14,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
@@ -98,8 +97,6 @@ public class TapiTopologyImplTest extends AbstractTest {
 
     @Mock
     private RpcService rpcService;
-    private static ListeningExecutorService executorService;
-    private static CountDownLatch endSignal;
     private static final int NUM_THREADS = 3;
     private static NetworkTransactionService networkTransactionService;
     private static TapiContext tapiContext;
@@ -111,8 +108,8 @@ public class TapiTopologyImplTest extends AbstractTest {
 
     @BeforeAll
     static void setUp() throws InterruptedException, ExecutionException {
-        executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
-        endSignal = new CountDownLatch(1);
+        MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
+        new CountDownLatch(1);
         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
             TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),