X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=nbinotifications%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnbinotifications%2Fconsumer%2FSubscriberTest.java;h=5c5f6690f9032e0195af148e175c1f60074c894d;hb=23d3099a686a049a387e72e0e34f04f8eb5cba6b;hp=326c4ecdd9522dbdbf4edeec7c405a08b40954a6;hpb=a61b019dd2078be7732b7f2a4669868977c822b2;p=transportpce.git 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"); } }