From: Gilles Thouenon Date: Sat, 25 Feb 2023 20:19:13 +0000 (+0100) Subject: Migrate nbinotifications module to JUnit5 X-Git-Tag: 7.0.0~19 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;ds=sidebyside;h=23d3099a686a049a387e72e0e34f04f8eb5cba6b;p=transportpce.git Migrate nbinotifications module to JUnit5 JIRA: TRNSPRTPCE-730 Signed-off-by: Gilles Thouenon Change-Id: Id6ec23473646a899bb28e152ba941109aad16cde --- 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 326c4ecdd..5c5f6690f 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 @@ -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 subscriberAlarmService; private Subscriber 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 record = new ConsumerRecord<>( TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedEvent()); @@ -65,12 +66,12 @@ public class SubscriberTest extends AbstractTest { mockConsumer.updateBeginningOffsets(startOffsets); List 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 record = new ConsumerRecord<>( TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedAlarmEvent()); @@ -85,12 +86,12 @@ public class SubscriberTest extends AbstractTest { mockConsumerAlarm.updateBeginningOffsets(startOffsets); List 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 record = new ConsumerRecord<>( TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedTapiAlarmEvent()); @@ -105,7 +106,7 @@ public class SubscriberTest extends AbstractTest { mockConsumerTapi.updateBeginningOffsets(startOffsets); List 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"); } } 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 f9a762403..ec2a5b388 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 @@ -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 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> 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> 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> 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> 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> result = @@ -107,6 +108,6 @@ public class NbiNotificationsImplTest extends AbstractTest { .setSubscriptionIdOrName(result.get().getResult().getSubscriptionService().getUuid().getValue()); ListenableFuture> result1 = nbiNotificationsImpl.getNotificationList(builder1.build()); - assertNull("Should be null", result1.get().getResult().getNotification()); + assertNull(result1.get().getResult().getNotification(), "Should be null"); } } diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java index 81704db36..bbf2e62e0 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java @@ -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", 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 ced79a2cc..fd7e83ad3 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 @@ -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 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")); 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 063b1d54d..e7d7fd66b 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 @@ -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 converterService; private JsonStringConverter converterAlarm; private JsonStringConverter 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"); } } 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 d1c5c39a4..cd642f09d 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 @@ -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 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"); } } 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 b850f5b79..8b267970b 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 @@ -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 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"); } } 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 0c47b49bc..25edafea8 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 @@ -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 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"); } } 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 51d83fa14..0a15d9ebc 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 @@ -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 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"); } } diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceDeserializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceDeserializerTest.java index e50231ed0..929d6a58f 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceDeserializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceDeserializerTest.java @@ -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 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"); } } diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceSerializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceSerializerTest.java index 233b1a9ba..b040246fa 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceSerializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationTapiServiceSerializerTest.java @@ -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 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"); } }