Migrate dmaap-client module to JUnit5
[transportpce.git] / dmaap-client / src / test / java / org / opendaylight / transportpce / dmaap / client / listener / NbiNotificationsListenerImplTest.java
index 710bf1b313588f35c5a5ec4d8487385b01137354..5a5b31b896a89483074a1e83104593538fbf06b9 100644 (file)
@@ -7,29 +7,35 @@
  */
 package org.opendaylight.transportpce.dmaap.client.listener;
 
-import static org.junit.Assert.assertEquals;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 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.junit.jupiter.api.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.rev201130.NbiNotificationsListener;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationServiceBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.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 {
@@ -41,40 +47,42 @@ public class NbiNotificationsListenerImplTest extends JerseyTest {
     }
 
     @Test
-    public void onPublishNotificationServiceTest() {
+    void onPublishNotificationServiceTest() {
         Logger logger = (Logger) LoggerFactory.getLogger(NbiNotificationsListenerImpl.class);
         ListAppender<ILoggingEvent> listAppender = new ListAppender<>();
         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());
-
+        assertEquals(logsList.get(1).getFormattedMessage(), "Response received CreatedEvent [serverTimeMs=1, count=1]");
     }
 }