Initial tapi notification implementation
[transportpce.git] / dmaap-client / src / test / java / org / opendaylight / transportpce / dmaap / client / listener / NbiNotificationsListenerImplTest.java
index 39bdc0c563d81a0bb30600be6c125e69553f9cf2..f3df78362adfc1cf0e69b74e388c0e72256b52eb 100644 (file)
@@ -13,23 +13,28 @@ import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.spi.ILoggingEvent;
 import ch.qos.logback.core.read.ListAppender;
 import java.util.List;
+import java.util.Map;
 import javax.ws.rs.core.Application;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
 import org.junit.Test;
 import org.opendaylight.transportpce.dmaap.client.resource.EventsApiStub;
-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.RxDirectionBuilder;
-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.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.NbiNotificationsListener;
-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.http.org.openroadm.common.node.types.rev210528.NodeIdType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.RxDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.RxDirectionKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.TxDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.TxDirectionKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsListener;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder;
 import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.LoggerFactory;
 
 public class NbiNotificationsListenerImplTest extends JerseyTest {
@@ -47,32 +52,35 @@ public class NbiNotificationsListenerImplTest extends JerseyTest {
         listAppender.start();
         logger.addAppender(listAppender);
         NbiNotificationsListener listener = new NbiNotificationsListenerImpl("http://localhost:9998", null, null);
-        PublishNotificationService notification = new PublishNotificationServiceBuilder().setCommonId("CommonId")
+        PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder()
+                .setCommonId("CommonId")
                 .setMessage("Service implemented")
                 .setOperationalState(State.InService)
-                .setTopic("topic")
+                .setPublisherName("publisher")
                 .setConnectionType(ConnectionType.Service)
                 .setServiceAEnd(new ServiceAEndBuilder()
                         .setClli("clli")
-                        .setNodeId(new org.opendaylight.yang.gen.v1.http
-                                .org.openroadm.common.node.types.rev181130.NodeIdType("nodeidtype"))
+                        .setNodeId(new NodeIdType("nodeidtype"))
                         .setServiceFormat(ServiceFormat.Ethernet)
                         .setServiceRate(Uint32.valueOf(100))
-                        .setRxDirection(new RxDirectionBuilder().build())
-                        .setTxDirection(new TxDirectionBuilder().build())
+                        .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO),
+                            new RxDirectionBuilder().setIndex(Uint8.ZERO).build()))
+                        .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO),
+                            new TxDirectionBuilder().setIndex(Uint8.ZERO).build()))
                         .build())
                 .setServiceZEnd(new ServiceZEndBuilder()
                         .setClli("clli")
-                        .setNodeId(new org.opendaylight.yang.gen.v1.http
-                                .org.openroadm.common.node.types.rev181130.NodeIdType("nodeidtype"))
+                        .setNodeId(new NodeIdType("nodeidtype"))
                         .setServiceFormat(ServiceFormat.Ethernet)
                         .setServiceRate(Uint32.valueOf(100))
-                        .setRxDirection(new RxDirectionBuilder().build())
-                        .setTxDirection(new TxDirectionBuilder().build())
+                        .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO),
+                            new RxDirectionBuilder().setIndex(Uint8.ZERO).build()))
+                        .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO),
+                            new TxDirectionBuilder().setIndex(Uint8.ZERO).build()))
                         .build())
                 .build();
-        listener.onPublishNotificationService(notification);
-        // as onPublishNotificationService is a void method, we check log message to be sur everything went well
+        listener.onPublishNotificationProcessService(notification);
+        // as onPublishNotificationService is a void method, we check log message to be sure everything went well
         List<ILoggingEvent> logsList = listAppender.list;
         assertEquals("Response received CreatedEvent [serverTimeMs=1, count=1]", logsList.get(1).getFormattedMessage());