From 274148a8d813140f86e1f9770ba992b072c1a5cd Mon Sep 17 00:00:00 2001 From: Thierry Jiao Date: Tue, 10 Aug 2021 11:21:36 +0200 Subject: [PATCH] Refactor NBINotifications and serviceHandlerImpl This refactoring renames the models in YANG nbi-notifications file. It also corrects a few typos, notifications and simplifies conditions. Signed-off-by: Thierry Jiao Change-Id: Ia23d44b2a158b4828b68c4a9ab2df0dcb121f034 --- ...yang => nbi-notifications@2021-08-13.yang} | 35 +++-- .../client/impl/DmaapClientProvider.java | 2 +- .../NbiNotificationsListenerImpl.java | 8 +- .../dmaap/client/resource/EventsApi.java | 4 +- .../resource/config/JsonConfigurator.java | 2 +- ...lishNotificationProcessServiceModule.java} | 12 +- ...NotificationProcessServiceSerializer.java} | 12 +- .../config/ServiceAEndSerializer.java | 2 +- .../config/ServiceZEndSerializer.java | 2 +- .../NbiNotificationsListenerImplTest.java | 26 ++-- .../tpce/module/TransportPCEImpl.java | 8 +- .../controllers/tpce/utils/TPCEUtils.java | 2 +- .../impl/NbiNotificationsImpl.java | 68 ++++---- .../impl/NbiNotificationsProvider.java | 41 +++-- .../NbiNotificationsListenerImpl.java | 51 +++--- .../NotificationAlarmServiceDeserializer.java | 44 +++--- .../NotificationAlarmServiceSerializer.java | 5 +- .../NotificationServiceDeserializer.java | 49 +++--- .../NotificationServiceSerializer.java | 16 +- .../utils/NbiNotificationsUtils.java | 3 +- .../consumer/SubscriberTest.java | 26 ++-- .../impl/NbiNotificationsImplTest.java | 33 ++-- .../NbiNotificationsListenerImplTest.java | 63 +++++--- .../producer/PublisherTest.java | 16 +- ...ificationAlarmServiceDeserializerTest.java | 8 +- ...otificationAlarmServiceSerializerTest.java | 2 +- .../NotificationServiceDeserializerTest.java | 9 +- .../NotificationServiceSerializerTest.java | 8 +- .../utils/NotificationServiceDataUtils.java | 103 ++++++------ .../src/test/resources/event.json | 2 +- .../src/test/resources/expected_event.json | 146 +++++++++--------- .../expected_event_alarm_service.json | 4 +- .../impl/ServicehandlerImpl.java | 49 +++--- .../listeners/PceListenerImpl.java | 38 +++-- .../listeners/RendererListenerImpl.java | 24 +-- .../listeners/ServiceListener.java | 10 +- .../blueprint/servicehandler-blueprint.xml | 1 - .../impl/ServicehandlerImplTest.java | 42 ++--- .../listeners/ServiceListenerTest.java | 89 +++++++---- tests/transportpce_tests/common/test_utils.py | 6 +- .../with_docker/test02_nbinotifications.py | 45 +++--- 41 files changed, 587 insertions(+), 529 deletions(-) rename api/src/main/yang/{nbi-notifications@2021-06-28.yang => nbi-notifications@2021-08-13.yang} (86%) rename dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/{PublishNotificationServiceModule.java => PublishNotificationProcessServiceModule.java} (73%) rename dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/{PublishNotificationServiceSerializer.java => PublishNotificationProcessServiceSerializer.java} (74%) diff --git a/api/src/main/yang/nbi-notifications@2021-06-28.yang b/api/src/main/yang/nbi-notifications@2021-08-13.yang similarity index 86% rename from api/src/main/yang/nbi-notifications@2021-06-28.yang rename to api/src/main/yang/nbi-notifications@2021-08-13.yang index d61c3993a..4bed2f803 100644 --- a/api/src/main/yang/nbi-notifications@2021-06-28.yang +++ b/api/src/main/yang/nbi-notifications@2021-08-13.yang @@ -24,6 +24,11 @@ module nbi-notifications { "YANG definitions for using REST API in NBI notifications module. Copyright (c) 2020 ORANGE and others. All rights reserved."; + revision 2021-08-13 { + description + "Rename the groupings, containers and RPCs"; + } + revision 2021-06-28 { description "Implement new models, RPC for service alarms"; @@ -34,7 +39,7 @@ module nbi-notifications { "Initial revision of NBI notifications"; } - grouping notification-service { + grouping notification-process-service { leaf message { type string; mandatory true; @@ -103,10 +108,10 @@ module nbi-notifications { } } - container notification-service { + container notification-process-service { description "Model used to send a notification from a service request"; - uses notification-service; + uses notification-process-service; } container notification-alarm-service { @@ -115,7 +120,7 @@ module nbi-notifications { uses notification-alarm-service; } - rpc get-notifications-service { + rpc get-notifications-process-service { description "Get the notifications service sent by ServiceHandler through filtering connection type"; input { leaf connection-type { @@ -138,8 +143,8 @@ module nbi-notifications { } } output { - list notification-service { - uses notification-service; + list notifications-process-service { + uses notification-process-service; } } } @@ -167,30 +172,30 @@ module nbi-notifications { } } output { - list notification-alarm-service { + list notifications-alarm-service { uses notification-alarm-service; } } } - notification publish-notification-service { - description "Publish the notifications service for topic"; - leaf topic { + notification publish-notification-process-service { + description "Publish the notifications service through a publisher"; + leaf publisher-name { type string; mandatory true; description - "Topic where to send the notification service"; + "Name of the publisher"; } - uses notification-service; + uses notification-process-service; } notification publish-notification-alarm-service { - description "Publish the notifications service alarm for topic"; - leaf topic { + description "Publish the notifications service alarm through a publisher"; + leaf publisher-name { type string; mandatory true; description - "Topic where to send the notification service alarm"; + "Name of the publisher"; } uses notification-alarm-service; } diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java index 1da61d040..63bee5357 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java @@ -9,7 +9,7 @@ package org.opendaylight.transportpce.dmaap.client.impl; import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.transportpce.dmaap.client.listener.NbiNotificationsListenerImpl; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NbiNotificationsListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java index d5003ce12..4a91e6a4c 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java @@ -17,9 +17,9 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.opendaylight.transportpce.dmaap.client.resource.EventsApi; import org.opendaylight.transportpce.dmaap.client.resource.config.JsonConfigurator; import org.opendaylight.transportpce.dmaap.client.resource.model.CreatedEvent; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NbiNotificationsListener; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +43,7 @@ public class NbiNotificationsListenerImpl implements NbiNotificationsListener { } @Override - public void onPublishNotificationService(PublishNotificationService notification) { + public void onPublishNotificationProcessService(PublishNotificationProcessService notification) { try { CreatedEvent response = api.sendEvent(topic, notification); LOG.info("Response received {}", response); diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java index b1a5ae036..e6f167824 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java @@ -14,7 +14,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.opendaylight.transportpce.dmaap.client.resource.model.CreatedEvent; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; @Path("/events") public interface EventsApi { @@ -23,6 +23,6 @@ public interface EventsApi { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/{topic}") - CreatedEvent sendEvent(@PathParam("topic") String topic, PublishNotificationService event); + CreatedEvent sendEvent(@PathParam("topic") String topic, PublishNotificationProcessService event); } diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/JsonConfigurator.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/JsonConfigurator.java index 62676c0ee..d6035d205 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/JsonConfigurator.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/JsonConfigurator.java @@ -22,7 +22,7 @@ public class JsonConfigurator implements ContextResolver { mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.registerModule(new JavaTimeModule()); - mapper.registerModule(new PublishNotificationServiceModule()); + mapper.registerModule(new PublishNotificationProcessServiceModule()); } @Override diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceModule.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceModule.java similarity index 73% rename from dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceModule.java rename to dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceModule.java index b33de94ea..250e1c03a 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceModule.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceModule.java @@ -13,19 +13,19 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev1 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirection; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.Lgx; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.Port; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceAEnd; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceZEnd; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEnd; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEnd; //This class is a temporary workaround while waiting jackson //support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852 -public class PublishNotificationServiceModule extends SimpleModule { +public class PublishNotificationProcessServiceModule extends SimpleModule { private static final long serialVersionUID = 1L; - public PublishNotificationServiceModule() { + public PublishNotificationProcessServiceModule() { super(PackageVersion.VERSION); - addSerializer(PublishNotificationService.class, new PublishNotificationServiceSerializer()); + addSerializer(PublishNotificationProcessService.class, new PublishNotificationProcessServiceSerializer()); addSerializer(Lgx.class, new LgxSerializer()); addSerializer(Port.class, new PortSerializer()); addSerializer(RxDirection.class, new RxDirectionSerializer()); diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceSerializer.java similarity index 74% rename from dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceSerializer.java rename to dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceSerializer.java index 0b282b4c9..b9b650ce0 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceSerializer.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceSerializer.java @@ -11,19 +11,19 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import java.io.IOException; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; // This class is a temporary workaround while waiting jackson // support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852 -public class PublishNotificationServiceSerializer extends StdSerializer { +public class PublishNotificationProcessServiceSerializer extends StdSerializer { private static final long serialVersionUID = 1L; - public PublishNotificationServiceSerializer() { - super(PublishNotificationService.class); + public PublishNotificationProcessServiceSerializer() { + super(PublishNotificationProcessService.class); } @Override - public void serialize(PublishNotificationService value, JsonGenerator gen, SerializerProvider provider) + public void serialize(PublishNotificationProcessService value, JsonGenerator gen, SerializerProvider provider) throws IOException { if (value != null) { gen.writeStartObject(); @@ -31,7 +31,7 @@ public class PublishNotificationServiceSerializer extends StdSerializer logsList = listAppender.list; assertEquals("Response received CreatedEvent [serverTimeMs=1, count=1]", logsList.get(1).getFormattedMessage()); diff --git a/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java b/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java index 7ea47d278..6a6d2506d 100644 --- a/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java +++ b/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java @@ -122,9 +122,9 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP /** * List of publisher topics. */ - private final List publisherTopicList = Arrays.asList("PceListener", "ServiceHandlerOperations", + private final List publisherServiceList = Arrays.asList("PceListener", "ServiceHandlerOperations", "ServiceHandler", "RendererListener"); - private final List publisherTopicAlarmList = Arrays.asList("ServiceListener"); + private final List publisherAlarmList = Arrays.asList("ServiceListener"); public TransportPCEImpl(LightyServices lightyServices, boolean activateNbiNotification) { LOG.info("Initializing transaction providers ..."); @@ -200,7 +200,7 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP lightyServices.getBindingNotificationPublishService(), serviceDataStoreOperations); ServicehandlerImpl servicehandler = new ServicehandlerImpl(lightyServices.getBindingDataBroker(), pathComputationService, rendererServiceOperations, lightyServices.getBindingNotificationPublishService(), - pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations, "N/A"); + pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); servicehandlerProvider = new ServicehandlerProvider(lightyServices.getBindingDataBroker(), lightyServices.getRpcProviderService(), lightyServices.getNotificationService(), serviceDataStoreOperations, pceListenerImpl, serviceListener, rendererListenerImpl, @@ -229,7 +229,7 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP if (activateNbiNotification) { LOG.info("Creating nbi-notifications beans ..."); nbiNotificationsProvider = new NbiNotificationsProvider( - publisherTopicList, publisherTopicAlarmList, null, null, lightyServices.getRpcProviderService(), + publisherServiceList, publisherAlarmList, null, null, lightyServices.getRpcProviderService(), lightyServices.getNotificationService(), lightyServices.getAdapterContext().currentSerializer()); } } diff --git a/lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java b/lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java index 2b2575c30..e4c88df0f 100644 --- a/lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java +++ b/lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java @@ -348,7 +348,7 @@ public final class TPCEUtils { .getInstance(), org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.$YangModuleInfoImpl .getInstance(), - org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.$YangModuleInfoImpl + org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.$YangModuleInfoImpl .getInstance()); private static final Set TPCE_YANG_MODEL = Stream.concat( 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 index 60fd5517f..77f6f8552 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java @@ -13,15 +13,17 @@ import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.nbinotifications.consumer.Subscriber; import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceDeserializer; import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceDeserializer; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsAlarmServiceInput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsAlarmServiceOutput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsAlarmServiceOutputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsServiceInput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsServiceOutput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsServiceOutputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NbiNotificationsService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.service.output.NotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceInput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceOutputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceInput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceOutputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -29,37 +31,32 @@ import org.slf4j.LoggerFactory; public class NbiNotificationsImpl implements NbiNotificationsService { private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsImpl.class); - private final JsonStringConverter converterService; - private final JsonStringConverter converterAlarmService; + private final JsonStringConverter converterService; + private final JsonStringConverter converterAlarmService; private final String server; - public NbiNotificationsImpl(JsonStringConverter converterService, - JsonStringConverter converterAlarmService, String server) { + public NbiNotificationsImpl(JsonStringConverter converterService, + JsonStringConverter converterAlarmService, String server) { this.converterService = converterService; this.converterAlarmService = converterAlarmService; this.server = server; } @Override - public ListenableFuture> getNotificationsService( - GetNotificationsServiceInput input) { + public ListenableFuture> getNotificationsProcessService( + GetNotificationsProcessServiceInput input) { LOG.info("RPC getNotificationsService received"); if (input == null || input.getIdConsumer() == null || input.getGroupId() == null) { LOG.warn("Missing mandatory params for input {}", input); - return RpcResultBuilder.success(new GetNotificationsServiceOutputBuilder().build()).buildFuture(); + return RpcResultBuilder.success(new GetNotificationsProcessServiceOutputBuilder().build()).buildFuture(); } - Subscriber subscriber = new Subscriber<>(input.getIdConsumer(), input.getGroupId(), server, - converterService, NotificationServiceDeserializer.class); - List notificationServiceList = subscriber - .subscribe(input.getConnectionType().getName(), NotificationService.QNAME); - GetNotificationsServiceOutputBuilder output = new GetNotificationsServiceOutputBuilder() - .setNotificationService(notificationServiceList); - return RpcResultBuilder.success(output.build()).buildFuture(); + Subscriber subscriber = new Subscriber<>( + input.getIdConsumer(), input.getGroupId(), server, converterService, + NotificationServiceDeserializer.class); + List notificationServiceList = subscriber + .subscribe(input.getConnectionType().getName(), NotificationsProcessService.QNAME); + return RpcResultBuilder.success(new GetNotificationsProcessServiceOutputBuilder() + .setNotificationsProcessService(notificationServiceList).build()).buildFuture(); } @Override @@ -70,13 +67,12 @@ public class NbiNotificationsImpl implements NbiNotificationsService { LOG.warn("Missing mandatory params for input {}", input); return RpcResultBuilder.success(new GetNotificationsAlarmServiceOutputBuilder().build()).buildFuture(); } - Subscriber subscriber = new Subscriber<>(input.getIdConsumer(), input.getGroupId(), - server, converterAlarmService, NotificationAlarmServiceDeserializer.class); - List notificationAlarmServiceList = subscriber - .subscribe("alarm" + input.getConnectionType().getName(), NotificationAlarmService.QNAME); - GetNotificationsAlarmServiceOutputBuilder output = new GetNotificationsAlarmServiceOutputBuilder() - .setNotificationAlarmService(notificationAlarmServiceList); - return RpcResultBuilder.success(output.build()).buildFuture(); + Subscriber subscriber = new Subscriber<>( + input.getIdConsumer(), input.getGroupId(), server, converterAlarmService, + NotificationAlarmServiceDeserializer.class); + List notificationAlarmServiceList = subscriber + .subscribe("alarm" + input.getConnectionType().getName(), NotificationsAlarmService.QNAME); + return RpcResultBuilder.success(new GetNotificationsAlarmServiceOutputBuilder() + .setNotificationsAlarmService(notificationAlarmServiceList).build()).buildFuture(); } } diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java index 0d578de95..24c0383e4 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java @@ -18,9 +18,10 @@ import org.opendaylight.transportpce.nbinotifications.listener.NbiNotificationsL import org.opendaylight.transportpce.nbinotifications.producer.Publisher; import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceSerializer; import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceSerializer; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NbiNotificationsListener; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NbiNotificationsService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.slf4j.Logger; @@ -29,37 +30,34 @@ import org.slf4j.LoggerFactory; public class NbiNotificationsProvider { private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsProvider.class); - private static Map> publishersServiceMap = new HashMap<>(); + private static Map> publishersServiceMap = new HashMap<>(); private static Map> publishersAlarmMap = new HashMap<>(); - private final RpcProviderService rpcService; - private ObjectRegistration rpcRegistration; - private ListenerRegistration listenerRegistration; - private NotificationService notificationService; - private final JsonStringConverter converterService; + private final NotificationService notificationService; + private final JsonStringConverter converterService; private final JsonStringConverter converterAlarmService; private final String subscriberServer; + private ObjectRegistration rpcRegistration; + private ListenerRegistration listenerRegistration; - public NbiNotificationsProvider(List topicsService, List topicsAlarm, + public NbiNotificationsProvider(List publishersService, List publishersAlarm, String subscriberServer, String publisherServer, RpcProviderService rpcProviderService, NotificationService notificationService, BindingDOMCodecServices bindingDOMCodecServices) { this.rpcService = rpcProviderService; this.notificationService = notificationService; converterService = new JsonStringConverter<>(bindingDOMCodecServices); - for (String topic: topicsService) { - LOG.info("Creating publisher for topic {}", topic); - publishersServiceMap.put(topic, new Publisher<>(topic, publisherServer, converterService, - NotificationServiceSerializer.class)); + for (String publisherService: publishersService) { + LOG.info("Creating publisher for the following class {}", publisherService); + publishersServiceMap.put(publisherService, new Publisher<>(publisherService, publisherServer, + converterService, NotificationServiceSerializer.class)); } converterAlarmService = new JsonStringConverter<>(bindingDOMCodecServices); - for (String topic: topicsAlarm) { - LOG.info("Creating publisher for topic {}", topic); - publishersAlarmMap.put(topic, new Publisher<>(topic, publisherServer, converterAlarmService, - NotificationAlarmServiceSerializer.class)); + for (String publisherAlarm: publishersAlarm) { + LOG.info("Creating publisher for the following class {}", publisherAlarm); + publishersAlarmMap.put(publisherAlarm, new Publisher<>(publisherAlarm, publisherServer, + converterAlarmService, NotificationAlarmServiceSerializer.class)); } this.subscriberServer = subscriberServer; } @@ -79,8 +77,7 @@ public class NbiNotificationsProvider { * Method called when the blueprint container is destroyed. */ public void close() { - for (Publisher publisher : publishersServiceMap.values()) { + for (Publisher publisher : publishersServiceMap.values()) { publisher.close(); } for (Publisher publisherAlarm : publishersAlarmMap.values()) { diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java index e72b2282a..37b4c0181 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java @@ -9,59 +9,62 @@ package org.opendaylight.transportpce.nbinotifications.listener; import java.util.Map; import org.opendaylight.transportpce.nbinotifications.producer.Publisher; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NbiNotificationsListener; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class NbiNotificationsListenerImpl implements NbiNotificationsListener { private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsListenerImpl.class); - private final Map> publishersServiceMap; + private final Map> publishersServiceMap; private final Map> publishersAlarmMap; - public NbiNotificationsListenerImpl(Map> publishersServiceMap, + public NbiNotificationsListenerImpl(Map> publishersServiceMap, Map> publishersAlarmMap) { this.publishersServiceMap = publishersServiceMap; this.publishersAlarmMap = publishersAlarmMap; } @Override - public void onPublishNotificationService(PublishNotificationService notification) { + public void onPublishNotificationProcessService(PublishNotificationProcessService notification) { LOG.info("Receiving request for publishing notification service"); - String topic = notification.getTopic(); - if (!publishersServiceMap.containsKey(topic)) { - LOG.error("Unknown topic {}", topic); + String publisherName = notification.getPublisherName(); + if (!publishersServiceMap.containsKey(publisherName)) { + LOG.error("Unknown publisher {}", publisherName); return; } - Publisher publisher = publishersServiceMap.get(topic); - publisher.sendEvent(new NotificationServiceBuilder().setCommonId(notification.getCommonId()) - .setConnectionType(notification.getConnectionType()).setMessage(notification.getMessage()) + Publisher publisher = publishersServiceMap.get(publisherName); + publisher.sendEvent(new NotificationProcessServiceBuilder() + .setCommonId(notification.getCommonId()) + .setConnectionType(notification.getConnectionType()) + .setMessage(notification.getMessage()) .setOperationalState(notification.getOperationalState()) .setResponseFailed(notification.getResponseFailed()) .setServiceAEnd(notification.getServiceAEnd()) .setServiceName(notification.getServiceName()) - .setServiceZEnd(notification.getServiceZEnd()).build(), notification.getConnectionType().getName()); + .setServiceZEnd(notification.getServiceZEnd()) + .build(), notification.getConnectionType().getName()); } @Override public void onPublishNotificationAlarmService(PublishNotificationAlarmService notification) { LOG.info("Receiving request for publishing notification alarm service"); - String topic = notification.getTopic(); - if (!publishersAlarmMap.containsKey(topic)) { - LOG.error("Unknown topic {}", topic); + String publisherName = notification.getPublisherName(); + if (!publishersAlarmMap.containsKey(publisherName)) { + LOG.error("Unknown topic {}", publisherName); return; } - Publisher publisherAlarm = publishersAlarmMap.get(topic); - publisherAlarm.sendEvent(new NotificationAlarmServiceBuilder().setConnectionType(notification - .getConnectionType()) + Publisher publisherAlarm = publishersAlarmMap.get(publisherName); + publisherAlarm.sendEvent(new NotificationAlarmServiceBuilder() + .setConnectionType(notification.getConnectionType()) .setMessage(notification.getMessage()) .setOperationalState(notification.getOperationalState()) .setServiceName(notification.getServiceName()) - .build(), "alarm" + notification.getConnectionType().getName()); + .build(), "alarm" + notification.getConnectionType().getName()); } } diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializer.java index 4612d84bc..c08dbfb2f 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializer.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializer.java @@ -11,17 +11,17 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.kafka.common.serialization.Deserializer; import org.opendaylight.transportpce.common.converter.JsonStringConverter; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmServiceBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NotificationAlarmServiceDeserializer implements Deserializer { +public class NotificationAlarmServiceDeserializer implements Deserializer { private static final Logger LOG = LoggerFactory.getLogger(NotificationAlarmServiceDeserializer.class); - private JsonStringConverter converter; + private JsonStringConverter converter; @SuppressWarnings("unchecked") @Override @@ -29,37 +29,33 @@ public class NotificationAlarmServiceDeserializer implements Deserializer) { - converter = (JsonStringConverter) configs - .get(ConfigConstants.CONVERTER); + converter = (JsonStringConverter) configs.get(ConfigConstants.CONVERTER); } } @Override - public NotificationAlarmService deserialize(String topic, byte[] data) { + public NotificationsAlarmService deserialize(String topic, byte[] data) { if (converter == null) { throw new IllegalArgumentException( "Converter should be configured through configure method of deserializer"); } String value = new String(data, StandardCharsets.UTF_8); // The message published is - // org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService + // org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService // we have to map it to // org.opendaylight.yang.gen - // .v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService - org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmService mappedString = converter - .createDataObjectFromJsonString(YangInstanceIdentifier.of( - org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmService.QNAME), - value, - JSONCodecFactorySupplier.RFC7951); - if (mappedString != null) { - LOG.info("Reading event {}", mappedString); - return new NotificationAlarmServiceBuilder().setConnectionType(mappedString.getConnectionType()) - .setMessage(mappedString.getMessage()) - .setOperationalState(mappedString.getOperationalState()) - .setServiceName(mappedString.getServiceName()) - .build(); + // .v1.nbi.notifications.rev210813.get.notifications.service.output.NotificationsAlarmService + NotificationAlarmService mappedString = converter.createDataObjectFromJsonString( + YangInstanceIdentifier.of(NotificationAlarmService.QNAME), value, JSONCodecFactorySupplier.RFC7951); + if (mappedString == null) { + return null; } - return null; + LOG.info("Reading event {}", mappedString); + return new NotificationsAlarmServiceBuilder() + .setConnectionType(mappedString.getConnectionType()) + .setMessage(mappedString.getMessage()) + .setOperationalState(mappedString.getOperationalState()) + .setServiceName(mappedString.getServiceName()) + .build(); } } diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializer.java index c2ce676ee..fcf5f026f 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializer.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializer.java @@ -12,7 +12,7 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.kafka.common.serialization.Serializer; import org.opendaylight.transportpce.common.converter.JsonStringConverter; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.slf4j.Logger; @@ -36,8 +36,7 @@ public class NotificationAlarmServiceSerializer implements Serializer { +public class NotificationServiceDeserializer implements Deserializer { private static final Logger LOG = LoggerFactory.getLogger(NotificationServiceDeserializer.class); - private JsonStringConverter converter; + private JsonStringConverter converter; @SuppressWarnings("unchecked") @Override @@ -29,39 +29,38 @@ public class NotificationServiceDeserializer implements Deserializer) { - converter = (JsonStringConverter) configs - .get(ConfigConstants.CONVERTER); + converter = (JsonStringConverter) configs.get(ConfigConstants.CONVERTER); } } @Override - public NotificationService deserialize(String topic, byte[] data) { + public NotificationsProcessService deserialize(String topic, byte[] data) { if (converter == null) { throw new IllegalArgumentException( "Converter should be configured through configure method of deserializer"); } String value = new String(data, StandardCharsets.UTF_8); // The message published is - // org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService + // org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService // we have to map it to // org.opendaylight.yang.gen - // .v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService - org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService mappedString = converter - .createDataObjectFromJsonString(YangInstanceIdentifier.of( - org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService.QNAME), - value, - JSONCodecFactorySupplier.RFC7951); - if (mappedString != null) { - LOG.info("Reading event {}", mappedString); - return new NotificationServiceBuilder().setCommonId(mappedString.getCommonId()) - .setConnectionType(mappedString.getConnectionType()).setMessage(mappedString.getMessage()) - .setOperationalState(mappedString.getOperationalState()) - .setResponseFailed(mappedString.getResponseFailed()).setServiceName(mappedString.getServiceName()) - .setServiceAEnd(mappedString.getServiceAEnd()).setServiceZEnd(mappedString.getServiceZEnd()) - .build(); + // .v1.nbi.notifications.rev210813.get.notifications.service.output.NotificationService + NotificationProcessService mappedString = converter.createDataObjectFromJsonString( + YangInstanceIdentifier.of(NotificationProcessService.QNAME), value, JSONCodecFactorySupplier.RFC7951); + if (mappedString == null) { + return null; } - return null; + LOG.info("Reading event {}", mappedString); + return new NotificationsProcessServiceBuilder() + .setCommonId(mappedString.getCommonId()) + .setConnectionType(mappedString.getConnectionType()) + .setMessage(mappedString.getMessage()) + .setOperationalState(mappedString.getOperationalState()) + .setResponseFailed(mappedString.getResponseFailed()) + .setServiceName(mappedString.getServiceName()) + .setServiceAEnd(mappedString.getServiceAEnd()) + .setServiceZEnd(mappedString.getServiceZEnd()) + .build(); } } diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java index bc99d90c9..b3f6ae119 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java @@ -12,15 +12,15 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.kafka.common.serialization.Serializer; import org.opendaylight.transportpce.common.converter.JsonStringConverter; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NotificationServiceSerializer implements Serializer { +public class NotificationServiceSerializer implements Serializer { private static final Logger LOG = LoggerFactory.getLogger(NotificationServiceSerializer.class); - private JsonStringConverter converter; + private JsonStringConverter converter; @SuppressWarnings("unchecked") @Override @@ -28,21 +28,21 @@ public class NotificationServiceSerializer implements Serializer) { - converter = (JsonStringConverter) configs.get(ConfigConstants.CONVERTER); + converter = (JsonStringConverter) configs.get(ConfigConstants.CONVERTER); } } @Override - public byte[] serialize(String topic, NotificationService data) { + public byte[] serialize(String topic, NotificationProcessService data) { if (converter == null) { - throw new IllegalArgumentException( - "Converter should be" + "configured through configure method of serializer"); + throw new IllegalArgumentException("Converter should be configured through configure method of serializer"); } if (data == null) { return new byte[0]; } try { - InstanceIdentifier iid = InstanceIdentifier.builder(NotificationService.class).build(); + InstanceIdentifier iid = InstanceIdentifier + .builder(NotificationProcessService.class).build(); String serialized = converter.createJsonStringFromDataObject(iid, data, JSONCodecFactorySupplier.RFC7951); LOG.info("Serialized event {}", serialized); return serialized.getBytes(StandardCharsets.UTF_8); diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/NbiNotificationsUtils.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/NbiNotificationsUtils.java index d1a4ceeca..0c00503b7 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/NbiNotificationsUtils.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/NbiNotificationsUtils.java @@ -22,8 +22,7 @@ public final class NbiNotificationsUtils { public static Properties loadProperties(String propertyFileName) { Properties props = new Properties(); - InputStream inputStream = NbiNotificationsUtils.class.getClassLoader() - .getResourceAsStream(propertyFileName); + InputStream inputStream = NbiNotificationsUtils.class.getClassLoader().getResourceAsStream(propertyFileName); try { if (inputStream != null) { props.load(inputStream); diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java index 168f43d25..7e5fcf615 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java @@ -22,18 +22,18 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.transportpce.nbinotifications.utils.NotificationServiceDataUtils; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.service.output.NotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; public class SubscriberTest extends AbstractTest { private static final String TOPIC = "topic"; private static final int PARTITION = 0; - private MockConsumer mockConsumer; - private MockConsumer mockConsumerAlarm; - private Subscriber subscriberService; - private Subscriber subscriberAlarmService; + private MockConsumer mockConsumer; + private MockConsumer mockConsumerAlarm; + private Subscriber subscriberService; + private Subscriber subscriberAlarmService; @Before public void setUp() { @@ -46,7 +46,7 @@ public class SubscriberTest extends AbstractTest { @Test public void subscribeServiceShouldBeSuccessful() { // from https://www.baeldung.com/kafka-mockconsumer - ConsumerRecord record = new ConsumerRecord<>( + ConsumerRecord record = new ConsumerRecord<>( TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedEvent()); mockConsumer.schedulePollTask(() -> { mockConsumer.rebalance(Collections.singletonList(new TopicPartition(TOPIC, PARTITION))); @@ -57,7 +57,8 @@ public class SubscriberTest extends AbstractTest { TopicPartition tp = new TopicPartition(TOPIC, PARTITION); startOffsets.put(tp, 0L); mockConsumer.updateBeginningOffsets(startOffsets); - List result = subscriberService.subscribe(TOPIC, NotificationService.QNAME); + List result = subscriberService.subscribe(TOPIC, + NotificationsProcessService.QNAME); assertEquals("There should be 1 record", 1, result.size()); assertTrue("Consumer should be closed", mockConsumer.closed()); } @@ -65,7 +66,7 @@ public class SubscriberTest extends AbstractTest { @Test public void subscribeAlarmShouldBeSuccessful() { // from https://www.baeldung.com/kafka-mockconsumer - ConsumerRecord record = new ConsumerRecord<>( + ConsumerRecord record = new ConsumerRecord<>( TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedAlarmEvent()); mockConsumerAlarm.schedulePollTask(() -> { mockConsumerAlarm.rebalance(Collections.singletonList(new TopicPartition(TOPIC, PARTITION))); @@ -76,7 +77,8 @@ public class SubscriberTest extends AbstractTest { TopicPartition tp = new TopicPartition(TOPIC, PARTITION); startOffsets.put(tp, 0L); mockConsumerAlarm.updateBeginningOffsets(startOffsets); - List result = subscriberAlarmService.subscribe(TOPIC, NotificationAlarmService.QNAME); + List result = subscriberAlarmService.subscribe(TOPIC, + NotificationsAlarmService.QNAME); assertEquals("There should be 1 record", 1, result.size()); assertTrue("Consumer should be closed", mockConsumerAlarm.closed()); } diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java index c121eb75a..dc8fdeac0 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java @@ -16,10 +16,12 @@ import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsAlarmServiceInputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsAlarmServiceOutput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsServiceInputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceInputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceInputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; import org.opendaylight.yangtools.yang.common.RpcResult; public class NbiNotificationsImplTest extends AbstractTest { @@ -27,31 +29,30 @@ public class NbiNotificationsImplTest extends AbstractTest { @Before public void setUp() { - JsonStringConverter converter = new JsonStringConverter<>( + JsonStringConverter converter = new JsonStringConverter<>( getDataStoreContextUtil().getBindingDOMCodecServices()); - JsonStringConverter converterAlarm = new JsonStringConverter<>( + JsonStringConverter converterAlarm = new JsonStringConverter<>( getDataStoreContextUtil().getBindingDOMCodecServices()); nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm,"localhost:8080"); } @Test public void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException { - ListenableFuture> result = - nbiNotificationsImpl.getNotificationsService(new GetNotificationsServiceInputBuilder().build()); - assertNull("Should be null", result.get().getResult().getNotificationService()); + ListenableFuture> result = + nbiNotificationsImpl.getNotificationsProcessService( + new GetNotificationsProcessServiceInputBuilder().build()); + assertNull("Should be null", result.get().getResult().getNotificationsProcessService()); } @Test public void getNotificationsServiceTest() throws InterruptedException, ExecutionException { - GetNotificationsServiceInputBuilder builder = new GetNotificationsServiceInputBuilder() + GetNotificationsProcessServiceInputBuilder builder = new GetNotificationsProcessServiceInputBuilder() .setGroupId("groupId") .setIdConsumer("consumerId") .setConnectionType(ConnectionType.Service); - ListenableFuture> result = - nbiNotificationsImpl.getNotificationsService(builder.build()); - assertNull("Should be null", result.get().getResult().getNotificationService()); + ListenableFuture> result = + nbiNotificationsImpl.getNotificationsProcessService(builder.build()); + assertNull("Should be null", result.get().getResult().getNotificationsProcessService()); } @Test @@ -62,6 +63,6 @@ public class NbiNotificationsImplTest extends AbstractTest { .setConnectionType(ConnectionType.Service); ListenableFuture> result = nbiNotificationsImpl.getNotificationsAlarmService(builder.build()); - assertNull("Should be null", result.get().getResult().getNotificationAlarmService()); + assertNull("Should be null", result.get().getResult().getNotificationsAlarmService()); } } diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java index d8e832ead..c66efdbbc 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java @@ -21,16 +21,16 @@ import org.opendaylight.transportpce.nbinotifications.producer.Publisher; import org.opendaylight.transportpce.test.AbstractTest; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; public class NbiNotificationsListenerImplTest extends AbstractTest { @Mock - private Publisher publisherService; + private Publisher publisherService; @Mock private Publisher publisherAlarm; @@ -43,21 +43,31 @@ public class NbiNotificationsListenerImplTest extends AbstractTest { public void onPublishNotificationServiceTest() { NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), Map.of("test", publisherAlarm)); - PublishNotificationService notification = new PublishNotificationServiceBuilder().setTopic("test") - .setCommonId("commonId").setConnectionType(ConnectionType.Service).setMessage("Service deleted") - .setOperationalState(State.OutOfService).setServiceName("service name").build(); - listener.onPublishNotificationService(notification); + PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder() + .setPublisherName("test") + .setCommonId("commonId") + .setConnectionType(ConnectionType.Service) + .setMessage("Service deleted") + .setOperationalState(State.OutOfService) + .setServiceName("service name") + .build(); + listener.onPublishNotificationProcessService(notification); verify(publisherService, times(1)).sendEvent(any(), anyString()); } @Test - public void onPublishNotificationServiceWrongTopicTest() { + public void onPublishNotificationServiceWrongPublisherTest() { NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), Map.of("test", publisherAlarm)); - PublishNotificationService notification = new PublishNotificationServiceBuilder().setTopic("wrongtopic") - .setCommonId("commonId").setConnectionType(ConnectionType.Service).setMessage("Service deleted") - .setOperationalState(State.OutOfService).setServiceName("service name").build(); - listener.onPublishNotificationService(notification); + PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder() + .setPublisherName("wrongPublisher") + .setCommonId("commonId") + .setConnectionType(ConnectionType.Service) + .setMessage("Service deleted") + .setOperationalState(State.OutOfService) + .setServiceName("service name") + .build(); + listener.onPublishNotificationProcessService(notification); verify(publisherService, times(0)).sendEvent(any(), anyString()); } @@ -65,21 +75,28 @@ public class NbiNotificationsListenerImplTest extends AbstractTest { public void onPublishNotificationAlarmServiceTest() { NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), Map.of("test", publisherAlarm)); - PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder().setTopic("test") - .setConnectionType(ConnectionType.Service).setMessage("The service is now inService") - .setOperationalState(State.OutOfService).setServiceName("service name").build(); + PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder() + .setPublisherName("test") + .setConnectionType(ConnectionType.Service) + .setMessage("The service is now inService") + .setOperationalState(State.OutOfService) + .setServiceName("service name") + .build(); listener.onPublishNotificationAlarmService(notification); verify(publisherAlarm, times(1)).sendEvent(any(), anyString()); } @Test - public void onPublishNotificationAlarmServiceWrongTopicTest() { + public void onPublishNotificationAlarmServiceWrongPublisherTest() { NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), Map.of("test", publisherAlarm)); PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder() - .setTopic("wrongtopic").setConnectionType(ConnectionType.Service) - .setMessage("The service is now inService").setOperationalState(State.OutOfService) - .setServiceName("service name").build(); + .setPublisherName("wrongPublisher") + .setConnectionType(ConnectionType.Service) + .setMessage("The service is now inService") + .setOperationalState(State.OutOfService) + .setServiceName("service name") + .build(); listener.onPublishNotificationAlarmService(notification); verify(publisherAlarm, times(0)).sendEvent(any(), anyString()); } diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java index 7218a222c..86e33307b 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java @@ -22,17 +22,17 @@ import org.opendaylight.transportpce.nbinotifications.serialization.ConfigConsta import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceSerializer; import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceSerializer; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; public class PublisherTest extends AbstractTest { - private JsonStringConverter converterService; + private JsonStringConverter converterService; private JsonStringConverter converterAlarm; - private Publisher publisherService; + private Publisher publisherService; private Publisher publisherAlarm; - private MockProducer mockProducer; + private MockProducer mockProducer; private MockProducer mockAlarmProducer; @Before @@ -54,10 +54,10 @@ public class PublisherTest extends AbstractTest { @Test public void sendEventServiceShouldBeSuccessful() throws IOException { String json = Files.readString(Paths.get("src/test/resources/event.json")); - NotificationService notificationService = converterService - .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationService.QNAME), + NotificationProcessService notificationProcessService = converterService + .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationProcessService.QNAME), json, JSONCodecFactorySupplier.RFC7951); - publisherService.sendEvent(notificationService, notificationService.getConnectionType().name()); + publisherService.sendEvent(notificationProcessService, notificationProcessService.getConnectionType().name()); assertEquals("We should have one message", 1, mockProducer.history().size()); assertEquals("Key should be test", "test", mockProducer.history().get(0).key()); } diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializerTest.java index 2998b2560..b0d156a2a 100755 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializerTest.java @@ -16,19 +16,19 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; public class NotificationAlarmServiceDeserializerTest extends AbstractTest { @Test public void deserializeTest() throws IOException { - JsonStringConverter converter = + JsonStringConverter converter = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices()); NotificationAlarmServiceDeserializer deserializer = new NotificationAlarmServiceDeserializer(); Map configs = Map.of(ConfigConstants.CONVERTER, converter); deserializer.configure(configs, false); - NotificationAlarmService readEvent = deserializer.deserialize("Test", + NotificationsAlarmService readEvent = deserializer.deserialize("Test", Files.readAllBytes(Paths.get("src/test/resources/event_alarm_service.json"))); deserializer.close(); assertEquals("Service name should be service1", "service1", readEvent.getServiceName()); diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java index ed276cbf2..605c85158 100755 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java @@ -20,7 +20,7 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java index 430e7d8e2..12f7a80f3 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java @@ -16,18 +16,19 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.service.output.NotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; public class NotificationServiceDeserializerTest extends AbstractTest { @Test public void deserializeTest() throws IOException { - JsonStringConverter converter = - new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices()); + JsonStringConverter converter = new JsonStringConverter<>( + getDataStoreContextUtil().getBindingDOMCodecServices()); NotificationServiceDeserializer deserializer = new NotificationServiceDeserializer(); Map configs = Map.of(ConfigConstants.CONVERTER, converter); deserializer.configure(configs, false); - NotificationService readEvent = deserializer.deserialize("Test", + NotificationsProcessService readEvent = deserializer.deserialize("Test", Files.readAllBytes(Paths.get("src/test/resources/event.json"))); deserializer.close(); assertEquals("Service name should be service1", "service1", readEvent.getServiceName()); diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java index ca11dda9c..4a4868bbd 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java @@ -20,7 +20,7 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; @@ -28,11 +28,11 @@ public class NotificationServiceSerializerTest extends AbstractTest { @Test public void serializeTest() throws IOException { - JsonStringConverter converter = + JsonStringConverter converter = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices()); String json = Files.readString(Paths.get("src/test/resources/event.json")); - NotificationService notificationService = converter - .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationService.QNAME), + NotificationProcessService notificationService = converter + .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationProcessService.QNAME), json, JSONCodecFactorySupplier.RFC7951); NotificationServiceSerializer serializer = new NotificationServiceSerializer(); Map configs = Map.of(ConfigConstants.CONVERTER, converter); diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java index c2ad2ff94..4f660f100 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java @@ -10,15 +10,21 @@ package org.opendaylight.transportpce.nbinotifications.utils; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirection; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirectionBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirection; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirectionBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder; import org.opendaylight.yangtools.yang.common.Uint32; public final class NotificationServiceDataUtils { @@ -26,8 +32,8 @@ public final class NotificationServiceDataUtils { private NotificationServiceDataUtils() { } - public static NotificationService buildSendEventInput() { - NotificationServiceBuilder notificationServiceBuilder = new NotificationServiceBuilder() + public static NotificationProcessService buildSendEventInput() { + return new NotificationProcessServiceBuilder() .setMessage("message") .setServiceName("service1") .setOperationalState(State.InService) @@ -35,17 +41,12 @@ public final class NotificationServiceDataUtils { .setCommonId("commond-id") .setConnectionType(ConnectionType.Service) .setServiceZEnd(getServiceZEndBuild().build()) - .setServiceAEnd(getServiceAEndBuild().build()); - - return notificationServiceBuilder.build(); + .setServiceAEnd(getServiceAEndBuild().build()) + .build(); } - public static org.opendaylight.yang.gen.v1 - .nbi.notifications.rev210628.get.notifications.service.output.NotificationService buildReceivedEvent() { - org.opendaylight.yang.gen.v1 - .nbi.notifications.rev210628.get.notifications.service.output.NotificationServiceBuilder - notificationServiceBuilder = new org.opendaylight.yang.gen.v1 - .nbi.notifications.rev210628.get.notifications.service.output.NotificationServiceBuilder() + public static NotificationsProcessService buildReceivedEvent() { + return new NotificationsProcessServiceBuilder() .setMessage("message") .setServiceName("service1") .setOperationalState(State.InService) @@ -53,28 +54,24 @@ public final class NotificationServiceDataUtils { .setCommonId("commond-id") .setConnectionType(ConnectionType.Service) .setServiceZEnd(getServiceZEndBuild().build()) - .setServiceAEnd(getServiceAEndBuild().build()); - - return notificationServiceBuilder.build(); + .setServiceAEnd(getServiceAEndBuild().build()) + .build(); } - public static org.opendaylight.yang.gen.v1 - .nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmService - buildReceivedAlarmEvent() { - org.opendaylight.yang.gen.v1 - .nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmServiceBuilder - notificationAlarmServiceBuilder = new org.opendaylight.yang.gen.v1 - .nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmServiceBuilder() + public static NotificationsAlarmService buildReceivedAlarmEvent() { + return new NotificationsAlarmServiceBuilder() .setMessage("message") .setServiceName("service1") .setOperationalState(State.InService) - .setConnectionType(ConnectionType.Service); - return notificationAlarmServiceBuilder.build(); + .setConnectionType(ConnectionType.Service) + .build(); } public static ServiceAEndBuilder getServiceAEndBuild() { return new ServiceAEndBuilder() - .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1)) + .setClli("clli") + .setServiceFormat(ServiceFormat.OC) + .setServiceRate(Uint32.valueOf(1)) .setNodeId(new NodeIdType("XPONDER-1-2")) .setTxDirection(getTxDirection()) .setRxDirection(getRxDirection()); @@ -82,31 +79,51 @@ public final class NotificationServiceDataUtils { public static ServiceZEndBuilder getServiceZEndBuild() { return new ServiceZEndBuilder() - .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1)) + .setClli("clli") + .setServiceFormat(ServiceFormat.OC) + .setServiceRate(Uint32.valueOf(1)) .setNodeId(new NodeIdType("XPONDER-1-2")) .setTxDirection(getTxDirection()) .setRxDirection(getRxDirection()); } private static TxDirection getTxDirection() { - return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service - .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name") - .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf") - .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build()) - .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name") - .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build()) + return new TxDirectionBuilder() + .setPort(new PortBuilder() + .setPortDeviceName("device name") + .setPortName("port name") + .setPortRack("port rack") + .setPortShelf("port shelf") + .setPortSlot("port slot") + .setPortSubSlot("port subslot") + .setPortType("port type") + .build()) + .setLgx(new LgxBuilder() + .setLgxDeviceName("lgx device name") + .setLgxPortName("lgx port name") + .setLgxPortRack("lgx port rack") + .setLgxPortShelf("lgx port shelf") + .build()) .build(); } private static RxDirection getRxDirection() { - return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service - .endpoint.RxDirectionBuilder() - .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name") - .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot") - .setPortSubSlot("port subslot").setPortType("port type").build()) - .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name") - .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack") - .setLgxPortShelf("lgx port shelf").build()) + return new RxDirectionBuilder() + .setPort(new PortBuilder() + .setPortDeviceName("device name") + .setPortName("port name") + .setPortRack("port rack") + .setPortShelf("port shelf") + .setPortSlot("port slot") + .setPortSubSlot("port subslot") + .setPortType("port type") + .build()) + .setLgx(new LgxBuilder() + .setLgxDeviceName("lgx device name") + .setLgxPortName("lgx port name") + .setLgxPortRack("lgx port rack") + .setLgxPortShelf("lgx port shelf") + .build()) .build(); } } diff --git a/nbinotifications/src/test/resources/event.json b/nbinotifications/src/test/resources/event.json index 9e85e38f2..2c3106880 100644 --- a/nbinotifications/src/test/resources/event.json +++ b/nbinotifications/src/test/resources/event.json @@ -1,5 +1,5 @@ { - "notification-service": { + "notification-process-service": { "service-z-end": { "service-format": "OC", "node-id": "XPONDER-1-2", diff --git a/nbinotifications/src/test/resources/expected_event.json b/nbinotifications/src/test/resources/expected_event.json index 499c7e47a..25a6b851d 100644 --- a/nbinotifications/src/test/resources/expected_event.json +++ b/nbinotifications/src/test/resources/expected_event.json @@ -1,90 +1,90 @@ { - "notification-service": { - "service-z-end": { - "clli": "clli", - "service-rate": 1, - "node-id": "XPONDER-1-2", - "rx-direction": { - "lgx": { - "lgx-port-name": "lgx port name", - "lgx-port-shelf": "lgx port shelf", - "lgx-port-rack": "lgx port rack", - "lgx-device-name": "lgx device name" + "notification-process-service":{ + "common-id":"commond-id", + "message":"message", + "operational-state":"inService", + "service-z-end":{ + "node-id":"XPONDER-1-2", + "service-rate":1, + "clli":"clli", + "service-format":"OC", + "tx-direction":{ + "port":{ + "port-name":"port name", + "port-slot":"port slot", + "port-sub-slot":"port subslot", + "port-device-name":"device name", + "port-shelf":"port shelf", + "port-type":"port type", + "port-rack":"port rack" }, - "port": { - "port-shelf": "port shelf", - "port-rack": "port rack", - "port-device-name": "device name", - "port-name": "port name", - "port-slot": "port slot", - "port-type": "port type", - "port-sub-slot": "port subslot" + "lgx":{ + "lgx-port-shelf":"lgx port shelf", + "lgx-port-rack":"lgx port rack", + "lgx-port-name":"lgx port name", + "lgx-device-name":"lgx device name" } }, - "service-format": "OC", - "tx-direction": { - "lgx": { - "lgx-port-name": "lgx port name", - "lgx-port-shelf": "lgx port shelf", - "lgx-port-rack": "lgx port rack", - "lgx-device-name": "lgx device name" + "rx-direction":{ + "port":{ + "port-name":"port name", + "port-slot":"port slot", + "port-sub-slot":"port subslot", + "port-device-name":"device name", + "port-shelf":"port shelf", + "port-type":"port type", + "port-rack":"port rack" }, - "port": { - "port-shelf": "port shelf", - "port-rack": "port rack", - "port-device-name": "device name", - "port-name": "port name", - "port-slot": "port slot", - "port-type": "port type", - "port-sub-slot": "port subslot" + "lgx":{ + "lgx-port-shelf":"lgx port shelf", + "lgx-port-rack":"lgx port rack", + "lgx-port-name":"lgx port name", + "lgx-device-name":"lgx device name" } } }, - "connection-type": "service", - "operational-state": "inService", - "common-id": "commond-id", - "service-a-end": { - "clli": "clli", - "service-rate": 1, - "node-id": "XPONDER-1-2", - "rx-direction": { - "lgx": { - "lgx-port-name": "lgx port name", - "lgx-port-shelf": "lgx port shelf", - "lgx-port-rack": "lgx port rack", - "lgx-device-name": "lgx device name" + "service-name":"service1", + "connection-type":"service", + "service-a-end":{ + "node-id":"XPONDER-1-2", + "service-rate":1, + "clli":"clli", + "service-format":"OC", + "tx-direction":{ + "port":{ + "port-name":"port name", + "port-slot":"port slot", + "port-sub-slot":"port subslot", + "port-device-name":"device name", + "port-shelf":"port shelf", + "port-type":"port type", + "port-rack":"port rack" }, - "port": { - "port-shelf": "port shelf", - "port-rack": "port rack", - "port-device-name": "device name", - "port-name": "port name", - "port-slot": "port slot", - "port-type": "port type", - "port-sub-slot": "port subslot" + "lgx":{ + "lgx-port-shelf":"lgx port shelf", + "lgx-port-rack":"lgx port rack", + "lgx-port-name":"lgx port name", + "lgx-device-name":"lgx device name" } }, - "service-format": "OC", - "tx-direction": { - "lgx": { - "lgx-port-name": "lgx port name", - "lgx-port-shelf": "lgx port shelf", - "lgx-port-rack": "lgx port rack", - "lgx-device-name": "lgx device name" + "rx-direction":{ + "port":{ + "port-name":"port name", + "port-slot":"port slot", + "port-sub-slot":"port subslot", + "port-device-name":"device name", + "port-shelf":"port shelf", + "port-type":"port type", + "port-rack":"port rack" }, - "port": { - "port-shelf": "port shelf", - "port-rack": "port rack", - "port-device-name": "device name", - "port-name": "port name", - "port-slot": "port slot", - "port-type": "port type", - "port-sub-slot": "port subslot" + "lgx":{ + "lgx-port-shelf":"lgx port shelf", + "lgx-port-rack":"lgx port rack", + "lgx-port-name":"lgx port name", + "lgx-device-name":"lgx device name" } } }, - "service-name": "service1", - "response-failed": "", - "message": "message" + "response-failed":"" } } \ No newline at end of file diff --git a/nbinotifications/src/test/resources/expected_event_alarm_service.json b/nbinotifications/src/test/resources/expected_event_alarm_service.json index 403e6dc3d..b194ee19f 100755 --- a/nbinotifications/src/test/resources/expected_event_alarm_service.json +++ b/nbinotifications/src/test/resources/expected_event_alarm_service.json @@ -1,8 +1,8 @@ { "notification-alarm-service": { + "message": "The service is now inService", "operational-state": "inService", "service-name": "service1", - "connection-type": "service", - "message": "The service is now inService" + "connection-type": "service" } } \ No newline at end of file diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java index e176348fe..43d40309a 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java @@ -80,10 +80,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempSer import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfo.TailRetention; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfoBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; @@ -95,11 +95,12 @@ import org.slf4j.LoggerFactory; */ public class ServicehandlerImpl implements OrgOpenroadmServiceService { private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class); + private static final String PUBLISHER = "ServiceHandler"; private static final String TEMP_SERVICE_CREATE_MSG = "tempServiceCreate: {}"; private static final String TEMP_SERVICE_DELETE_MSG = "tempServiceDelete: {}"; private static final String SERVICE_RESTORATION_MSG = "serviceRestoration: {}"; private static final String SERVICE_RECONFIGURE_MSG = "serviceReconfigure: {}"; - private static final String SERVICE_FEASABILITY_CHECK_MSG = "serviceFeasabilityCheck: {}"; + private static final String SERVICE_FEASIBILITY_CHECK_MSG = "serviceFeasibilityCheck: {}"; private static final String SERVICE_DELETE_MSG = "serviceDelete: {}"; private static final String SERVICE_CREATE_MSG = "serviceCreate: {}"; @@ -111,15 +112,13 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { private RendererListenerImpl rendererListenerImpl; private NetworkModelListenerImpl networkModelListenerImpl; private NotificationPublishService notificationPublishService; - private final String topic; //TODO: remove private request fields as they are in global scope public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService, RendererServiceOperations rendererServiceOperations, NotificationPublishService notificationPublishService, PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl, - NetworkModelListenerImpl networkModelListenerImpl, ServiceDataStoreOperations serviceDataStoreOperations, - String topic) { + NetworkModelListenerImpl networkModelListenerImpl, ServiceDataStoreOperations serviceDataStoreOperations) { this.db = databroker; this.serviceDataStoreOperations = serviceDataStoreOperations; this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService); @@ -128,7 +127,6 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { this.rendererListenerImpl = rendererListenerImpl; this.networkModelListenerImpl = networkModelListenerImpl; this.notificationPublishService = notificationPublishService; - this.topic = topic; } @@ -188,14 +186,16 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true); if (output == null) { LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED); - sendNbiNotification(new PublishNotificationServiceBuilder() + sendNbiNotification(new PublishNotificationProcessServiceBuilder() .setServiceName(input.getServiceName()) .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build()) .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build()) - .setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType()) + .setCommonId(input.getCommonId()) + .setConnectionType(input.getConnectionType()) .setResponseFailed(LogMessages.ABORT_PCE_FAILED) .setMessage("ServiceCreate request failed ...") .setOperationalState(State.Degraded) + .setPublisherName(PUBLISHER) .build()); return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED); @@ -230,7 +230,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { //Check presence of service to be deleted Optional serviceOpt = this.serviceDataStoreOperations.getService(serviceName); Services service; - if (!serviceOpt.isPresent()) { + if (serviceOpt.isEmpty()) { LOG.warn(SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(serviceName)); return ModelMappingUtils.createDeleteServiceReply( input, ResponseCodes.FINAL_ACK_YES, @@ -253,14 +253,16 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { if (output == null) { LOG.error(SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED); - sendNbiNotification(new PublishNotificationServiceBuilder() + sendNbiNotification(new PublishNotificationProcessServiceBuilder() .setServiceName(service.getServiceName()) .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build()) .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build()) - .setCommonId(service.getCommonId()).setConnectionType(service.getConnectionType()) + .setCommonId(service.getCommonId()) + .setConnectionType(service.getConnectionType()) .setMessage("ServiceDelete request failed ...") .setOperationalState(State.InService) .setResponseFailed(LogMessages.RENDERER_DELETE_FAILED) + .setPublisherName(PUBLISHER) .build()); return ModelMappingUtils.createDeleteServiceReply( input, ResponseCodes.FINAL_ACK_YES, @@ -283,7 +285,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput, RpcActions.ServiceFeasibilityCheck); if (! validationResult.isSuccess()) { - LOG.warn(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.ABORT_VALID_FAILED); + LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_VALID_FAILED); return ModelMappingUtils.createCreateServiceReply( input, ResponseCodes.FINAL_ACK_YES, validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED); @@ -295,10 +297,10 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations); this.rendererListenerImpl.setServiceInput(new ServiceInput(input)); this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations); - LOG.debug(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.PCE_CALLING); + LOG.debug(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.PCE_CALLING); PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true); if (output == null) { - LOG.warn(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.ABORT_PCE_FAILED); + LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_PCE_FAILED); return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES, LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED); } @@ -314,7 +316,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { String serviceName = input.getServiceName(); LOG.info("RPC serviceReconfigure received for {}", serviceName); Optional servicesObject = this.serviceDataStoreOperations.getService(serviceName); - if (!servicesObject.isPresent()) { + if (servicesObject.isEmpty()) { LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.serviceNotInDS(serviceName)); return ModelMappingUtils.createCreateServiceReply( input, @@ -402,13 +404,12 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { if (softConstraints == null) { LOG.warn("service '{}' SoftConstraints is not set !", serviceName); serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints)); - serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints)); } else { LOG.info("converting hard constraints to soft constraints ..."); serviceInput.setSoftConstraints( DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints)); - serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints)); } + serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints)); } this.pceListenerImpl.setInput(serviceInput); this.pceListenerImpl.setServiceReconfigure(true); @@ -453,7 +454,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { String serviceName = input.getServiceName(); LOG.info("RPC serviceReroute received for {}", serviceName); Optional servicesObject = this.serviceDataStoreOperations.getService(serviceName); - if (!servicesObject.isPresent()) { + if (servicesObject.isEmpty()) { LOG.warn("serviceReroute: {}", LogMessages.serviceNotInDS(serviceName)); return ModelMappingUtils.createRerouteServiceReply( input, ResponseCodes.FINAL_ACK_NO, @@ -528,7 +529,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { /* * Upon receipt of service-deleteService RPC, service header and sdnc-request - * header compliancy are verified. + * header compliance are verified. */ LOG.debug("checking Service Compliance ..."); ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check( @@ -546,7 +547,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { Optional service = this.serviceDataStoreOperations.getTempService(commonId); - if (!service.isPresent()) { + if (service.isEmpty()) { LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(commonId)); return ModelMappingUtils.createDeleteServiceReply( input, ResponseCodes.FINAL_ACK_YES, @@ -656,7 +657,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { * Send notification to NBI notification in order to publish message. * @param service PublishNotificationService */ - private void sendNbiNotification(PublishNotificationService service) { + private void sendNbiNotification(PublishNotificationProcessService service) { try { notificationPublishService.putNotification(service); } catch (InterruptedException e) { diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java index 305c4156e..16e2fd58e 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java @@ -28,17 +28,17 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.RpcStatusEx; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.response.parameters.sp.ResponseParameters; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.response.parameters.sp.ResponseParametersBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PceListenerImpl implements TransportpcePceListener { private static final Logger LOG = LoggerFactory.getLogger(PceListenerImpl.class); - private static final String TOPIC = "PceListener"; + private static final String PUBLISHER = "PceListener"; private ServicePathRpcResult servicePathRpcResult; private RendererServiceOperations rendererServiceOperations; @@ -147,13 +147,14 @@ public class PceListenerImpl implements TransportpcePceListener { * @return true is status is Successful, false otherwise. */ private boolean checkStatus(ServicePathRpcResult notification) { - PublishNotificationService nbiNotification = getPublishNotificationService(notification); - PublishNotificationServiceBuilder publishNotificationServiceBuilder = new PublishNotificationServiceBuilder( - nbiNotification); + PublishNotificationProcessService nbiNotification = getPublishNotificationProcessService(notification); + PublishNotificationProcessServiceBuilder publishNotificationProcessServiceBuilder = + new PublishNotificationProcessServiceBuilder(nbiNotification); switch (servicePathRpcResult.getStatus()) { case Failed: LOG.error("PCE path computation failed !"); - nbiNotification = publishNotificationServiceBuilder.setMessage("ServiceCreate request failed ...") + nbiNotification = publishNotificationProcessServiceBuilder + .setMessage("ServiceCreate request failed ...") .setResponseFailed("PCE path computation failed !") .setOperationalState(State.Degraded).build(); sendNbiNotification(nbiNotification); @@ -167,7 +168,8 @@ public class PceListenerImpl implements TransportpcePceListener { default: LOG.error("PCE path computation returned an unknown RpcStatusEx code {}", servicePathRpcResult.getStatus()); - nbiNotification = publishNotificationServiceBuilder.setMessage("ServiceCreate request failed ...") + nbiNotification = publishNotificationProcessServiceBuilder + .setMessage("ServiceCreate request failed ...") .setResponseFailed("PCE path computation returned an unknown RpcStatusEx code!") .setOperationalState(State.Degraded).build(); sendNbiNotification(nbiNotification); @@ -175,17 +177,19 @@ public class PceListenerImpl implements TransportpcePceListener { } } - private PublishNotificationService getPublishNotificationService(ServicePathRpcResult notification) { - PublishNotificationServiceBuilder nbiNotificationBuilder = new PublishNotificationServiceBuilder(); + private PublishNotificationProcessService getPublishNotificationProcessService(ServicePathRpcResult notification) { + PublishNotificationProcessServiceBuilder nbiNotificationBuilder = + new PublishNotificationProcessServiceBuilder(); if (input != null) { nbiNotificationBuilder.setServiceName(input.getServiceName()) .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build()) .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build()) - .setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType()); + .setCommonId(input.getCommonId()) + .setConnectionType(input.getConnectionType()); } else { nbiNotificationBuilder.setServiceName(notification.getServiceName()); } - nbiNotificationBuilder.setTopic(TOPIC); + nbiNotificationBuilder.setPublisherName(PUBLISHER); return nbiNotificationBuilder.build(); } @@ -202,13 +206,13 @@ public class PceListenerImpl implements TransportpcePceListener { return; } Services service = serviceDataStoreOperations.getService(input.getServiceName()).get(); - PublishNotificationServiceBuilder nbiNotificationBuilder = new PublishNotificationServiceBuilder() + PublishNotificationProcessServiceBuilder nbiNotificationBuilder = new PublishNotificationProcessServiceBuilder() .setServiceName(service.getServiceName()) .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build()) .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build()) .setCommonId(service.getCommonId()) .setConnectionType(service.getConnectionType()) - .setTopic(TOPIC); + .setPublisherName(PUBLISHER); if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) { LOG.info("PCE cancel resource failed !"); sendNbiNotification(nbiNotificationBuilder @@ -302,7 +306,7 @@ public class PceListenerImpl implements TransportpcePceListener { * Send notification to NBI notification in order to publish message. * @param service PublishNotificationService */ - private void sendNbiNotification(PublishNotificationService service) { + private void sendNbiNotification(PublishNotificationProcessService service) { try { notificationPublishService.putNotification(service); } catch (InterruptedException e) { diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java index 1ca8fafa6..0a6e6f1e6 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java @@ -27,10 +27,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services; import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.OtnLinkType; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory; */ public class RendererListenerImpl implements TransportpceRendererListener { - private static final String TOPIC = "RendererListener"; + private static final String PUBLISHER = "RendererListener"; private static final Logger LOG = LoggerFactory.getLogger(RendererListenerImpl.class); private RendererRpcResultSp serviceRpcResultSp; private ServiceDataStoreOperations serviceDataStoreOperations; @@ -98,7 +98,7 @@ public class RendererListenerImpl implements TransportpceRendererListener { case Failed: LOG.error("Renderer service delete failed !"); Services service = serviceDataStoreOperations.getService(input.getServiceName()).get(); - sendNbiNotification(new PublishNotificationServiceBuilder() + sendNbiNotification(new PublishNotificationProcessServiceBuilder() .setServiceName(service.getServiceName()) .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build()) .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build()) @@ -107,7 +107,7 @@ public class RendererListenerImpl implements TransportpceRendererListener { .setResponseFailed("Renderer service delete failed !") .setMessage("ServiceDelete request failed ...") .setOperationalState(service.getOperationalState()) - .setTopic(TOPIC) + .setPublisherName(PUBLISHER) .build()); return; case Pending: @@ -162,12 +162,12 @@ public class RendererListenerImpl implements TransportpceRendererListener { updateOtnTopology(notification, false); - PublishNotificationServiceBuilder nbiNotificationBuilder = new PublishNotificationServiceBuilder() + PublishNotificationProcessServiceBuilder nbiNotificationBuilder = new PublishNotificationProcessServiceBuilder() .setServiceName(input.getServiceName()) .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build()) .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build()) .setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType()) - .setTopic(TOPIC); + .setPublisherName(PUBLISHER); OperationResult operationResult; String serviceTemp = ""; if (tempService) { @@ -231,7 +231,7 @@ public class RendererListenerImpl implements TransportpceRendererListener { private void onFailedServiceImplementation(String serviceName) { LOG.error("Renderer implementation failed !"); Services service = serviceDataStoreOperations.getService(input.getServiceName()).get(); - sendNbiNotification(new PublishNotificationServiceBuilder() + sendNbiNotification(new PublishNotificationProcessServiceBuilder() .setServiceName(service.getServiceName()) .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build()) .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build()) @@ -240,7 +240,7 @@ public class RendererListenerImpl implements TransportpceRendererListener { .setResponseFailed("Renderer implementation failed !") .setMessage("ServiceCreate request failed ...") .setOperationalState(service.getOperationalState()) - .setTopic(TOPIC) + .setPublisherName(PUBLISHER) .build()); OperationResult deleteServicePathOperationResult = this.serviceDataStoreOperations.deleteServicePath(serviceName); @@ -290,7 +290,7 @@ public class RendererListenerImpl implements TransportpceRendererListener { * Send notification to NBI notification in order to publish message. * @param service PublishNotificationService */ - private void sendNbiNotification(PublishNotificationService service) { + private void sendNbiNotification(PublishNotificationProcessService service) { try { notificationPublishService.putNotification(service); } catch (InterruptedException e) { diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java index ee64141f0..736e6471b 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java @@ -15,15 +15,15 @@ import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmServiceBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ServiceListener implements DataTreeChangeListener { private static final Logger LOG = LoggerFactory.getLogger(ServiceListener.class); - private static final String TOPIC = "ServiceListener"; + private static final String PUBLISHER = "ServiceListener"; private final DataBroker dataBroker; private NotificationPublishService notificationPublishService; @@ -54,7 +54,7 @@ public class ServiceListener implements DataTreeChangeListener { .setConnectionType(input.getConnectionType()) .setMessage("The service is now outOfService") .setOperationalState(State.OutOfService) - .setTopic(TOPIC) + .setPublisherName(PUBLISHER) .build()); } else if (rootService.getDataBefore().getOperationalState() == State.OutOfService @@ -65,7 +65,7 @@ public class ServiceListener implements DataTreeChangeListener { .setConnectionType(input.getConnectionType()) .setMessage("The service is now inService") .setOperationalState(State.InService) - .setTopic(TOPIC) + .setPublisherName(PUBLISHER) .build()); } break; diff --git a/servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml b/servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml index 8e2ba983b..1900ea305 100644 --- a/servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml +++ b/servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml @@ -68,7 +68,6 @@ Author: Martial Coulibaly on behalf of Orange - > result = servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build()); result.addListener(new Runnable() { @@ -129,7 +129,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceCreate(input); result.addListener(new Runnable() { @Override @@ -151,7 +151,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceDelete(new ServiceDeleteInputBuilder() .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("").build()).build()); @@ -176,7 +176,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceDelete(input); result.addListener(new Runnable() { @Override @@ -200,7 +200,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput(); serviceDataStoreOperations.createService(createInput); ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput(); @@ -226,7 +226,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build()); result.addListener(new Runnable() { @@ -252,7 +252,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceFeasibilityCheck(input); result.addListener(new Runnable() { @@ -275,7 +275,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build()); result.addListener(new Runnable() { @@ -302,7 +302,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceReconfigure(input); result.addListener(new Runnable() { @@ -332,7 +332,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput(); serviceDataStoreOperations.createService(createInput); @@ -360,7 +360,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build()); result.addListener(new Runnable() { @@ -387,7 +387,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceRestoration(input); result.addListener(new Runnable() { @@ -417,7 +417,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput(); serviceDataStoreOperations.createService(createInput); @@ -445,7 +445,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build()); result.addListener(new Runnable() { @@ -471,7 +471,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceReroute(input); result.addListener(new Runnable() { @@ -501,7 +501,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput(); serviceDataStoreOperations.createService(createInput); @@ -529,7 +529,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder() .setCommonId("").build()); @@ -557,7 +557,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.tempServiceDelete(input); result.addListener(new Runnable() { @Override @@ -583,7 +583,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput(); serviceDataStoreOperations.createTempService(createInput); @@ -610,7 +610,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build()); result.addListener(new Runnable() { @@ -638,7 +638,7 @@ public class ServicehandlerImplTest extends AbstractTest { ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, - serviceDataStoreOperations, "ServiceHandler"); + serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.tempServiceCreate(input); result.addListener(new Runnable() { diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListenerTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListenerTest.java index f02dec19f..cf85247a5 100755 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListenerTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListenerTest.java @@ -28,8 +28,14 @@ import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEndBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirection; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirectionBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirection; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirectionBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State; @@ -37,8 +43,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.re import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmServiceBuilder; import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.StrictStubs.class) @@ -127,18 +133,15 @@ public class ServiceListenerTest { } private Services buildService(State state, AdminStates adminStates) { - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd - serviceAEnd = getServiceAEndBuild() - .build(); - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service - .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1 - .http.org.openroadm.common.service.types.rev190531.service.ServiceZEndBuilder() - .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1)) - .setNodeId(new NodeIdType("XPONDER-3-2")) - .setTxDirection(getTxDirection()) - .setRxDirection(getRxDirection()) - .build(); - + ServiceAEnd serviceAEnd = getServiceAEndBuild().build(); + ServiceZEnd serviceZEnd = new ServiceZEndBuilder() + .setClli("clli") + .setServiceFormat(ServiceFormat.OC) + .setServiceRate(Uint32.valueOf(1)) + .setNodeId(new NodeIdType("XPONDER-3-2")) + .setTxDirection(getTxDirection()) + .setRxDirection(getRxDirection()) + .build(); ServicesBuilder builtInput = new ServicesBuilder() .setCommonId("commonId") .setConnectionType(ConnectionType.Service) @@ -152,35 +155,53 @@ public class ServiceListenerTest { return builtInput.build(); } - private org.opendaylight.yang.gen.v1 - .http.org.openroadm.common.service.types.rev190531.service.ServiceAEndBuilder getServiceAEndBuild() { - return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service - .ServiceAEndBuilder() - .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1)) + private ServiceAEndBuilder getServiceAEndBuild() { + return new ServiceAEndBuilder() + .setClli("clli") + .setServiceFormat(ServiceFormat.OC) + .setServiceRate(Uint32.valueOf(1)) .setNodeId(new NodeIdType("XPONDER-1-2")) .setTxDirection(getTxDirection()) .setRxDirection(getRxDirection()); } private TxDirection getTxDirection() { - return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service - .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name") - .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf") - .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build()) - .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name") - .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build()) + return new TxDirectionBuilder() + .setPort(new PortBuilder() + .setPortDeviceName("device name") + .setPortName("port name") + .setPortRack("port rack") + .setPortShelf("port shelf") + .setPortSlot("port slot") + .setPortSubSlot("port subslot") + .setPortType("port type") + .build()) + .setLgx(new LgxBuilder() + .setLgxDeviceName("lgx device name") + .setLgxPortName("lgx port name") + .setLgxPortRack("lgx port rack") + .setLgxPortShelf("lgx port shelf") + .build()) .build(); } private RxDirection getRxDirection() { - return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service - .endpoint.RxDirectionBuilder() - .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name") - .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot") - .setPortSubSlot("port subslot").setPortType("port type").build()) - .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name") - .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack") - .setLgxPortShelf("lgx port shelf").build()) + return new RxDirectionBuilder() + .setPort(new PortBuilder() + .setPortDeviceName("device name") + .setPortName("port name") + .setPortRack("port rack") + .setPortShelf("port shelf") + .setPortSlot("port slot") + .setPortSubSlot("port subslot") + .setPortType("port type") + .build()) + .setLgx(new LgxBuilder() + .setLgxDeviceName("lgx device name") + .setLgxPortName("lgx port name") + .setLgxPortRack("lgx port rack") + .setLgxPortShelf("lgx port shelf") + .build()) .build(); } @@ -190,7 +211,7 @@ public class ServiceListenerTest { .setConnectionType(ConnectionType.Service) .setMessage(message) .setOperationalState(services.getOperationalState()) - .setTopic("ServiceListener") + .setPublisherName("ServiceListener") .build(); } } diff --git a/tests/transportpce_tests/common/test_utils.py b/tests/transportpce_tests/common/test_utils.py index 64fb89390..b70a4eeb5 100644 --- a/tests/transportpce_tests/common/test_utils.py +++ b/tests/transportpce_tests/common/test_utils.py @@ -42,7 +42,7 @@ URL_CONFIG_CLLI_NET = "{}/config/ietf-network:networks/network/clli-network/" URL_CONFIG_ORDM_NET = "{}/config/ietf-network:networks/network/openroadm-network/" URL_PORTMAPPING = "{}/config/transportpce-portmapping:network/nodes/" URL_OPER_SERV_LIST = "{}/operational/org-openroadm-service:service-list/" -URL_GET_NBINOTIFICATIONS_SERV = "{}/operations/nbi-notifications:get-notifications-service/" +URL_GET_NBINOTIFICATIONS_PROCESS_SERV = "{}/operations/nbi-notifications:get-notifications-process-service/" URL_GET_NBINOTIFICATIONS_ALARM_SERV = "{}/operations/nbi-notifications:get-notifications-alarm-service/" URL_SERV_CREATE = "{}/operations/org-openroadm-service:service-create" URL_SERV_DELETE = "{}/operations/org-openroadm-service:service-delete" @@ -353,8 +353,8 @@ def portmapping_request(suffix: str): return get_request(url) -def get_notifications_service_request(attr): - return post_request(URL_GET_NBINOTIFICATIONS_SERV, attr) +def get_notifications_process_service_request(attr): + return post_request(URL_GET_NBINOTIFICATIONS_PROCESS_SERV, attr) def get_notifications_alarm_service_request(attr): diff --git a/tests/transportpce_tests/with_docker/test02_nbinotifications.py b/tests/transportpce_tests/with_docker/test02_nbinotifications.py index 27ff94b59..14b8bd888 100644 --- a/tests/transportpce_tests/with_docker/test02_nbinotifications.py +++ b/tests/transportpce_tests/with_docker/test02_nbinotifications.py @@ -207,7 +207,7 @@ class TransportNbiNotificationstesting(unittest.TestCase): "group-id": "transportpceTest" } } - response = test_utils.get_notifications_service_request(data) + response = test_utils.get_notifications_process_service_request(data) self.assertEqual(response.status_code, requests.codes.no_content) time.sleep(2) @@ -228,13 +228,14 @@ class TransportNbiNotificationstesting(unittest.TestCase): "group-id": "transportpceTest" } } - response = test_utils.get_notifications_service_request(data) + response = test_utils.get_notifications_process_service_request(data) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() - self.assertEqual(res['output']['notification-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notification-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notification-service'][-1]['message'], 'ServiceCreate request failed ...') - self.assertEqual(res['output']['notification-service'][-1]['response-failed'], + self.assertEqual(res['output']['notifications-process-service'][-1]['service-name'], 'service1') + self.assertEqual(res['output']['notifications-process-service'][-1]['connection-type'], 'service') + self.assertEqual(res['output']['notifications-process-service'][-1]['message'], + 'ServiceCreate request failed ...') + self.assertEqual(res['output']['notifications-process-service'][-1]['response-failed'], 'PCE path computation failed !') time.sleep(2) @@ -300,12 +301,12 @@ class TransportNbiNotificationstesting(unittest.TestCase): "group-id": "transportpceTest" } } - response = test_utils.get_notifications_service_request(data) + response = test_utils.get_notifications_process_service_request(data) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() - self.assertEqual(res['output']['notification-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notification-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notification-service'][-1]['message'], 'Service implemented !') + self.assertEqual(res['output']['notifications-process-service'][-1]['service-name'], 'service1') + self.assertEqual(res['output']['notifications-process-service'][-1]['connection-type'], 'service') + self.assertEqual(res['output']['notifications-process-service'][-1]['message'], 'Service implemented !') time.sleep(2) def test_17_get_notifications_alarm_service1(self): @@ -319,10 +320,10 @@ class TransportNbiNotificationstesting(unittest.TestCase): response = test_utils.get_notifications_alarm_service_request(data) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() - self.assertEqual(res['output']['notification-alarm-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notification-alarm-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notification-alarm-service'][-1]['operational-state'], 'inService') - self.assertEqual(res['output']['notification-alarm-service'][-1]['message'], 'The service is now inService') + self.assertEqual(res['output']['notifications-alarm-service'][-1]['service-name'], 'service1') + self.assertEqual(res['output']['notifications-alarm-service'][-1]['connection-type'], 'service') + self.assertEqual(res['output']['notifications-alarm-service'][-1]['operational-state'], 'inService') + self.assertEqual(res['output']['notifications-alarm-service'][-1]['message'], 'The service is now inService') time.sleep(2) def test_18_change_status_port_roadma_srg(self): @@ -351,10 +352,10 @@ class TransportNbiNotificationstesting(unittest.TestCase): response = test_utils.get_notifications_alarm_service_request(data) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() - self.assertEqual(res['output']['notification-alarm-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notification-alarm-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notification-alarm-service'][-1]['operational-state'], 'outOfService') - self.assertEqual(res['output']['notification-alarm-service'][-1]['message'], 'The service is now outOfService') + self.assertEqual(res['output']['notifications-alarm-service'][-1]['service-name'], 'service1') + self.assertEqual(res['output']['notifications-alarm-service'][-1]['connection-type'], 'service') + self.assertEqual(res['output']['notifications-alarm-service'][-1]['operational-state'], 'outOfService') + self.assertEqual(res['output']['notifications-alarm-service'][-1]['message'], 'The service is now outOfService') time.sleep(2) def test_20_restore_status_port_roadma_srg(self): @@ -391,12 +392,12 @@ class TransportNbiNotificationstesting(unittest.TestCase): "group-id": "transportpceTest" } } - response = test_utils.get_notifications_service_request(data) + response = test_utils.get_notifications_process_service_request(data) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() - self.assertEqual(res['output']['notification-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notification-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notification-service'][-1]['message'], 'Service deleted !') + self.assertEqual(res['output']['notifications-process-service'][-1]['service-name'], 'service1') + self.assertEqual(res['output']['notifications-process-service'][-1]['connection-type'], 'service') + self.assertEqual(res['output']['notifications-process-service'][-1]['message'], 'Service deleted !') time.sleep(2) def test_24_disconnect_XPDRA(self): -- 2.36.6