Migrate nbinotifications module to JUnit5 43/104643/3
authorGilles Thouenon <gilles.thouenon@orange.com>
Sat, 25 Feb 2023 20:19:13 +0000 (21:19 +0100)
committerGilles Thouenon <gilles.thouenon@orange.com>
Sat, 4 Mar 2023 07:30:11 +0000 (08:30 +0100)
JIRA: TRNSPRTPCE-730
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: Id6ec23473646a899bb28e152ba941109aad16cde

nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializerTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceDeserializerTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceSerializerTest.java

index 326c4ecdd9522dbdbf4edeec7c405a08b40954a6..5c5f6690f9032e0195af148e175c1f60074c894d 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.transportpce.nbinotifications.consumer;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -18,8 +19,8 @@ import org.apache.kafka.clients.consumer.ConsumerRecord;
 import org.apache.kafka.clients.consumer.MockConsumer;
 import org.apache.kafka.clients.consumer.OffsetResetStrategy;
 import org.apache.kafka.common.TopicPartition;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.nbinotifications.utils.NotificationServiceDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
@@ -39,8 +40,8 @@ public class SubscriberTest extends AbstractTest {
     private Subscriber<NotificationAlarmService, NotificationsAlarmService> subscriberAlarmService;
     private Subscriber<NotificationTapiService, Notification> subscriberTapiService;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         mockConsumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
         mockConsumerAlarm = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
         mockConsumerTapi = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
@@ -50,7 +51,7 @@ public class SubscriberTest extends AbstractTest {
     }
 
     @Test
-    public void subscribeServiceShouldBeSuccessful() {
+    void subscribeServiceShouldBeSuccessful() {
         // from https://www.baeldung.com/kafka-mockconsumer
         ConsumerRecord<String, NotificationsProcessService> record = new ConsumerRecord<>(
                 TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedEvent());
@@ -65,12 +66,12 @@ public class SubscriberTest extends AbstractTest {
         mockConsumer.updateBeginningOffsets(startOffsets);
         List<NotificationsProcessService> result = subscriberService.subscribe(TOPIC,
                 NotificationsProcessService.QNAME);
-        assertEquals("There should be 1 record", 1, result.size());
-        assertTrue("Consumer should be closed", mockConsumer.closed());
+        assertEquals(1, result.size(), "There should be 1 record");
+        assertTrue(mockConsumer.closed(), "Consumer should be closed");
     }
 
     @Test
-    public void subscribeAlarmShouldBeSuccessful() {
+    void subscribeAlarmShouldBeSuccessful() {
         // from https://www.baeldung.com/kafka-mockconsumer
         ConsumerRecord<String, NotificationsAlarmService> record = new ConsumerRecord<>(
                 TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedAlarmEvent());
@@ -85,12 +86,12 @@ public class SubscriberTest extends AbstractTest {
         mockConsumerAlarm.updateBeginningOffsets(startOffsets);
         List<NotificationsAlarmService> result = subscriberAlarmService.subscribe(TOPIC,
                 NotificationsAlarmService.QNAME);
-        assertEquals("There should be 1 record", 1, result.size());
-        assertTrue("Consumer should be closed", mockConsumerAlarm.closed());
+        assertEquals(1, result.size(), "There should be 1 record");
+        assertTrue(mockConsumerAlarm.closed(), "Consumer should be closed");
     }
 
     @Test
-    public void subscribeTapiAlarmShouldBeSuccessful() {
+    void subscribeTapiAlarmShouldBeSuccessful() {
         // from https://www.baeldung.com/kafka-mockconsumer
         ConsumerRecord<String, Notification> record = new ConsumerRecord<>(
             TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedTapiAlarmEvent());
@@ -105,7 +106,7 @@ public class SubscriberTest extends AbstractTest {
         mockConsumerTapi.updateBeginningOffsets(startOffsets);
         List<Notification> result = subscriberTapiService.subscribe(TOPIC,
             NotificationTapiService.QNAME);
-        assertEquals("There should be 1 record", 1, result.size());
-        assertTrue("Consumer should be closed", mockConsumerTapi.closed());
+        assertEquals(1, result.size(), "There should be 1 record");
+        assertTrue(mockConsumerTapi.closed(), "Consumer should be closed");
     }
 }
index f9a762403bddf993cc1d2d723be3d3bb501173cd..ec2a5b38873af4f6e7a4ade1202dffdebfbabd91 100644 (file)
@@ -7,13 +7,14 @@
  */
 package org.opendaylight.transportpce.nbinotifications.impl;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.ExecutionException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
@@ -39,8 +40,8 @@ public class NbiNotificationsImplTest extends AbstractTest {
     public static NetworkTransactionService networkTransactionService;
     private TopicManager topicManager;
 
-    @Before
-    public void setUp() throws ExecutionException, InterruptedException {
+    @BeforeEach
+    void setUp() throws ExecutionException, InterruptedException {
         topicManager = TopicManager.getInstance();
         networkTransactionService = new NetworkTransactionImpl(getDataBroker());
         JsonStringConverter<NotificationProcessService> converter = new JsonStringConverter<>(
@@ -57,47 +58,47 @@ public class NbiNotificationsImplTest extends AbstractTest {
     }
 
     @Test
-    public void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException {
+    void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException {
         ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
                 nbiNotificationsImpl.getNotificationsProcessService(
                         new GetNotificationsProcessServiceInputBuilder().build());
-        assertNull("Should be null", result.get().getResult().getNotificationsProcessService());
+        assertNull(result.get().getResult().getNotificationsProcessService(), "Should be null");
     }
 
     @Test
-    public void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
+    void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
         GetNotificationsProcessServiceInputBuilder builder = new GetNotificationsProcessServiceInputBuilder()
                 .setGroupId("groupId")
                 .setIdConsumer("consumerId")
                 .setConnectionType(ConnectionType.Service);
         ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
                 nbiNotificationsImpl.getNotificationsProcessService(builder.build());
-        assertNull("Should be null", result.get().getResult().getNotificationsProcessService());
+        assertNull(result.get().getResult().getNotificationsProcessService(), "Should be null");
     }
 
     @Test
-    public void getNotificationsAlarmServiceTest() throws InterruptedException, ExecutionException {
+    void getNotificationsAlarmServiceTest() throws InterruptedException, ExecutionException {
         GetNotificationsAlarmServiceInputBuilder builder = new GetNotificationsAlarmServiceInputBuilder()
                 .setGroupId("groupId")
                 .setIdConsumer("consumerId")
                 .setConnectionType(ConnectionType.Service);
         ListenableFuture<RpcResult<GetNotificationsAlarmServiceOutput>> result =
                 nbiNotificationsImpl.getNotificationsAlarmService(builder.build());
-        assertNull("Should be null", result.get().getResult().getNotificationsAlarmService());
+        assertNull(result.get().getResult().getNotificationsAlarmService(), "Should be null");
     }
 
     @Test
-    public void createTapiNotificationSubscriptionServiceTest() throws InterruptedException, ExecutionException {
+    void createTapiNotificationSubscriptionServiceTest() throws InterruptedException, ExecutionException {
         CreateNotificationSubscriptionServiceInputBuilder builder
             = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder();
         ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
             nbiNotificationsImpl.createNotificationSubscriptionService(builder.build());
-        assertNotNull("Should receive UUID for subscription service",
-            result.get().getResult().getSubscriptionService().getUuid().toString());
+        assertNotNull(result.get().getResult().getSubscriptionService().getUuid().toString(),
+            "Should receive UUID for subscription service");
     }
 
     @Test
-    public void getTapiNotificationsServiceTest() throws InterruptedException, ExecutionException {
+    void getTapiNotificationsServiceTest() throws InterruptedException, ExecutionException {
         CreateNotificationSubscriptionServiceInputBuilder builder
             = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder();
         ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
@@ -107,6 +108,6 @@ public class NbiNotificationsImplTest extends AbstractTest {
             .setSubscriptionIdOrName(result.get().getResult().getSubscriptionService().getUuid().getValue());
         ListenableFuture<RpcResult<GetNotificationListOutput>> result1 =
             nbiNotificationsImpl.getNotificationList(builder1.build());
-        assertNull("Should be null", result1.get().getResult().getNotification());
+        assertNull(result1.get().getResult().getNotification(), "Should be null");
     }
 }
index 81704db36a6f88d77fe3e4200b8366057016a213..bbf2e62e063d8ebbcda1996ead49050c8853a471 100644 (file)
@@ -12,8 +12,8 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
 import java.util.Arrays;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.mdsal.binding.api.NotificationService;
@@ -32,14 +32,13 @@ public class NbiNotificationsProviderTest  extends AbstractTest {
     @Mock
     private NotificationService notificationService;
 
-    @Before
-    public void init() {
+    @BeforeEach
+    void init() {
         MockitoAnnotations.openMocks(this);
-
     }
 
     @Test
-    public void initTest() {
+    void initTest() {
         networkTransactionService = new NetworkTransactionImpl(getDataBroker());
         NbiNotificationsProvider provider = new NbiNotificationsProvider(
                 Arrays.asList("topic1", "topic2"), Arrays.asList("topic1", "topic2"), "localhost:8080",
index ced79a2cc9668a296c350c7a895c5d0827e7633b..fd7e83ad3a24689de6b9b9fe82ff83a60609dd9c 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.transportpce.nbinotifications.listener;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
@@ -18,8 +18,8 @@ import static org.mockito.Mockito.verify;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
@@ -45,13 +45,13 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     @Mock
     private Publisher<NotificationTapiService> publisherTapiService;
 
-    @Before
-    public void setUp() throws ExecutionException, InterruptedException {
+    @BeforeEach
+    void setUp() throws ExecutionException, InterruptedException {
         MockitoAnnotations.openMocks(this);
     }
 
     @Test
-    public void onPublishNotificationServiceTest() {
+    void onPublishNotificationServiceTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
                 Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder()
@@ -67,7 +67,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     }
 
     @Test
-    public void onPublishNotificationServiceWrongPublisherTest() {
+    void onPublishNotificationServiceWrongPublisherTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
                 Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder()
@@ -83,7 +83,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     }
 
     @Test
-    public void onPublishNotificationAlarmServiceTest() {
+    void onPublishNotificationAlarmServiceTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
                 Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder()
@@ -98,7 +98,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     }
 
     @Test
-    public void onPublishNotificationAlarmServiceWrongPublisherTest() {
+    void onPublishNotificationAlarmServiceWrongPublisherTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
                 Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder()
@@ -113,7 +113,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     }
 
     @Test
-    public void onPublishTapiNotificationServiceTest() throws ExecutionException, InterruptedException {
+    void onPublishTapiNotificationServiceTest() throws ExecutionException, InterruptedException {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
                 Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
 
@@ -126,7 +126,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     }
 
     @Test
-    public void onPublishTapiNotificationServiceTestWrongPublisherTest() {
+    void onPublishTapiNotificationServiceTestWrongPublisherTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
             Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         PublishTapiNotificationService notification
@@ -138,7 +138,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     }
 
     @Test
-    public void getTapiPublisherFromTopicTest() {
+    void getTapiPublisherFromTopicTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
                 Map.of("test", publisherAlarm), Map.of("test", publisherTapiService));
         assertNull(listener.getTapiPublisherFromTopic("toto"));
index 063b1d54d6b4940ff52127eb5c6ef494add71c9e..e7d7fd66b57223b8ad302b008ec967245fd4225c 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.transportpce.nbinotifications.producer;
 
-import static org.junit.Assert.assertEquals;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.nio.file.Files;
@@ -18,8 +19,8 @@ import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import org.apache.kafka.clients.producer.MockProducer;
 import org.apache.kafka.common.serialization.StringSerializer;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
@@ -43,6 +44,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
 
 public class PublisherTest extends AbstractTest {
+    private static NetworkTransactionService networkTransactionService;
+
     private JsonStringConverter<NotificationProcessService> converterService;
     private JsonStringConverter<NotificationAlarmService> converterAlarm;
     private JsonStringConverter<NotificationTapiService> converterTapiService;
@@ -55,10 +58,9 @@ public class PublisherTest extends AbstractTest {
     private NbiNotificationsImpl nbiNotificationsImpl;
     private TopicManager topicManager;
 
-    public static NetworkTransactionService networkTransactionService;
 
-    @Before
-    public void setUp() throws ExecutionException, InterruptedException {
+    @BeforeEach
+    void setUp() throws ExecutionException, InterruptedException {
         topicManager = TopicManager.getInstance();
         converterService = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         converterAlarm = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
@@ -87,30 +89,30 @@ public class PublisherTest extends AbstractTest {
     }
 
     @Test
-    public void sendEventServiceShouldBeSuccessful() throws IOException {
+    void sendEventServiceShouldBeSuccessful() throws IOException {
         String json = Files.readString(Paths.get("src/test/resources/event.json"));
         NotificationProcessService notificationProcessService = converterService
                 .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationProcessService.QNAME),
                         json, JSONCodecFactorySupplier.RFC7951);
         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());
+        assertEquals(1, mockProducer.history().size(), "We should have one message");
+        assertEquals("test", mockProducer.history().get(0).key(), "Key should be test");
     }
 
     @Test
-    public void sendEventAlarmShouldBeSuccessful() throws IOException {
+    void sendEventAlarmShouldBeSuccessful() throws IOException {
         String json = Files.readString(Paths.get("src/test/resources/event_alarm_service.json"));
         NotificationAlarmService notificationAlarmService = converterAlarm
                 .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationAlarmService.QNAME),
                         json, JSONCodecFactorySupplier.RFC7951);
         publisherAlarm.sendEvent(notificationAlarmService, "alarm"
                 + notificationAlarmService.getConnectionType().getName());
-        assertEquals("We should have one message", 1, mockAlarmProducer.history().size());
-        assertEquals("Key should be test", "test", mockAlarmProducer.history().get(0).key());
+        assertEquals(1, mockAlarmProducer.history().size(), "We should have one message");
+        assertEquals("test", mockAlarmProducer.history().get(0).key(), "Key should be test");
     }
 
     @Test
-    public void sendTapiEventShouldBeSuccessful() throws IOException {
+    void sendTapiEventShouldBeSuccessful() throws IOException {
         CreateNotificationSubscriptionServiceInputBuilder builder
             = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder();
         SubscriptionFilter subscriptionFilter = new SubscriptionFilterBuilder(builder.getSubscriptionFilter())
@@ -123,7 +125,7 @@ public class PublisherTest extends AbstractTest {
             .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationTapiService.QNAME),
                 json, JSONCodecFactorySupplier.RFC7951);
         publisherTapiService.sendEvent(notificationTapiService, "");
-        assertEquals("We should have one message", 1, mockTapiProducer.history().size());
-        assertEquals("Key should be test", "test", mockTapiProducer.history().get(0).key());
+        assertEquals(1, mockTapiProducer.history().size(), "We should have one message");
+        assertEquals("test", mockTapiProducer.history().get(0).key(), "Key should be test");
     }
 }
index d1c5c39a4bc94bec2c9d6e38fecde84efe343943..cd642f09dcd148cb254c08cb439b672b33e76b95 100755 (executable)
@@ -7,13 +7,14 @@
  */
 package org.opendaylight.transportpce.nbinotifications.serialization;
 
-import static org.junit.Assert.assertEquals;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
@@ -22,7 +23,7 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notification
 public class NotificationAlarmServiceDeserializerTest extends AbstractTest {
 
     @Test
-    public void deserializeTest() throws IOException {
+    void deserializeTest() throws IOException {
         JsonStringConverter<NotificationAlarmService> converter =
                 new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         NotificationAlarmServiceDeserializer deserializer = new NotificationAlarmServiceDeserializer();
@@ -31,8 +32,8 @@ public class NotificationAlarmServiceDeserializerTest extends AbstractTest {
         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());
-        assertEquals("message should be The service is now inService", "The service is now inService",
-                readEvent.getMessage());
+        assertEquals("service1", readEvent.getServiceName(), "Service name should be service1");
+        assertEquals("The service is now inService", readEvent.getMessage(),
+            "message should be The service is now inService");
     }
 }
index b850f5b7956a8bc6a7526929ff42c65fd536cd45..8b267970bd4b28f8f717cdad5edfd0d96ed28179 100755 (executable)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.transportpce.nbinotifications.serialization;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -17,7 +18,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
@@ -27,7 +28,7 @@ import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
 public class NotificationAlarmServiceSerializerTest extends AbstractTest {
 
     @Test
-    public void serializeTest() throws IOException {
+    void serializeTest() throws IOException {
         JsonStringConverter<NotificationAlarmService> converter =
                 new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         String json = Files.readString(Paths.get("src/test/resources/event_alarm_service.json"));
@@ -39,10 +40,10 @@ public class NotificationAlarmServiceSerializerTest extends AbstractTest {
         serializer.configure(configs, false);
         byte[] data = serializer.serialize("test", notificationAlarmService);
         serializer.close();
-        assertNotNull("Serialized data should not be null", data);
+        assertNotNull(data, "Serialized data should not be null");
         String expectedJson = Files.readString(Paths.get("src/test/resources/expected_event_alarm_service.json"));
         // Minify the json string
         expectedJson = new ObjectMapper().readValue(expectedJson, JsonNode.class).toString();
-        assertEquals("The event should be equals", expectedJson, new String(data, StandardCharsets.UTF_8));
+        assertEquals(expectedJson, new String(data, StandardCharsets.UTF_8), "The event should be equals");
     }
 }
index 0c47b49bcdf1362a565d521670dd632f1ff6939e..25edafea8a52c2f500e1c1fca96ec86743b8ffd7 100644 (file)
@@ -7,13 +7,14 @@
  */
 package org.opendaylight.transportpce.nbinotifications.serialization;
 
-import static org.junit.Assert.assertEquals;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService;
@@ -22,7 +23,7 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notification
 public class NotificationServiceDeserializerTest extends AbstractTest {
 
     @Test
-    public void deserializeTest() throws IOException {
+    void deserializeTest() throws IOException {
         JsonStringConverter<NotificationProcessService> converter = new JsonStringConverter<>(
                 getDataStoreContextUtil().getBindingDOMCodecServices());
         NotificationServiceDeserializer deserializer = new NotificationServiceDeserializer();
@@ -31,6 +32,6 @@ public class NotificationServiceDeserializerTest extends AbstractTest {
         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());
+        assertEquals("service1", readEvent.getServiceName(), "Service name should be service1");
     }
 }
index 51d83fa14af08548b0a3118f5663df5882e3627e..0a15d9ebc5e14a11599f641a30c136216cd788e3 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.transportpce.nbinotifications.serialization;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -17,7 +17,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService;
@@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
 public class NotificationServiceSerializerTest extends AbstractTest {
 
     @Test
-    public void serializeTest() throws IOException {
+    void serializeTest() throws IOException {
         JsonStringConverter<NotificationProcessService> converter =
                 new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         String json = Files.readString(Paths.get("src/test/resources/event.json"));
@@ -39,10 +39,10 @@ public class NotificationServiceSerializerTest extends AbstractTest {
         serializer.configure(configs, false);
         byte[] data = serializer.serialize("test", notificationService);
         serializer.close();
-        assertNotNull("Serialized data should not be null", data);
+        assertNotNull(data, "Serialized data should not be null");
         String expectedJson = Files.readString(Paths.get("src/test/resources/expected_event.json"));
         // Minify the json string
         expectedJson = new ObjectMapper().readValue(expectedJson, JsonNode.class).toString();
-        assertEquals("The event should be equals", expectedJson, new String(data, StandardCharsets.UTF_8));
+        assertEquals(expectedJson, new String(data, StandardCharsets.UTF_8), "The event should be equals");
     }
 }
index e50231ed0f4b1b10974f518ca6597952d2c01375..929d6a58feef08ef309bcf1d448db931354db990 100644 (file)
@@ -7,13 +7,14 @@
  */
 package org.opendaylight.transportpce.nbinotifications.serialization;
 
-import static org.junit.Assert.assertEquals;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
@@ -22,7 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev18121
 public class NotificationTapiServiceDeserializerTest extends AbstractTest {
 
     @Test
-    public void deserializeTest() throws IOException {
+    void deserializeTest() throws IOException {
         JsonStringConverter<NotificationTapiService> converter = new JsonStringConverter<>(
                 getDataStoreContextUtil().getBindingDOMCodecServices());
         TapiNotificationDeserializer deserializer = new TapiNotificationDeserializer();
@@ -31,7 +32,7 @@ public class NotificationTapiServiceDeserializerTest extends AbstractTest {
         Notification readEvent = deserializer.deserialize("76d8f07b-ead5-4132-8eb8-cf3fdef7e079",
                 Files.readAllBytes(Paths.get("src/test/resources/tapi_event.json")));
         deserializer.close();
-        assertEquals("Service uuid should be 76d8f07b-ead5-4132-8eb8-cf3fdef7e079",
-            "76d8f07b-ead5-4132-8eb8-cf3fdef7e079", readEvent.getTargetObjectIdentifier().getValue());
+        assertEquals("76d8f07b-ead5-4132-8eb8-cf3fdef7e079", readEvent.getTargetObjectIdentifier().getValue(),
+            "Service uuid should be 76d8f07b-ead5-4132-8eb8-cf3fdef7e079");
     }
 }
index 233b1a9ba866cd8f7618d95ece755a00f43b11e7..b040246fa8be19377c95a1ac62842a736a08dc5f 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.transportpce.nbinotifications.serialization;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -17,7 +18,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
@@ -27,7 +28,7 @@ import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
 public class NotificationTapiServiceSerializerTest extends AbstractTest {
 
     @Test
-    public void serializeTest() throws IOException {
+    void serializeTest() throws IOException {
         JsonStringConverter<NotificationTapiService> converter =
                 new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         String json = Files.readString(Paths.get("src/test/resources/tapi_event.json"));
@@ -39,10 +40,10 @@ public class NotificationTapiServiceSerializerTest extends AbstractTest {
         serializer.configure(configs, false);
         byte[] data = serializer.serialize("test", notificationService);
         serializer.close();
-        assertNotNull("Serialized data should not be null", data);
+        assertNotNull(data, "Serialized data should not be null");
         String expectedJson = Files.readString(Paths.get("src/test/resources/expected_tapi_event.json"));
         // Minify the json string
         expectedJson = new ObjectMapper().readValue(expectedJson, JsonNode.class).toString();
-        assertEquals("The event should be equals", expectedJson, new String(data, StandardCharsets.UTF_8));
+        assertEquals(expectedJson, new String(data, StandardCharsets.UTF_8), "The event should be equals");
     }
 }