Migrate common/util to JUnit5
[yangtools.git] / common / util / src / test / java / org / opendaylight / yangtools / util / ListenerRegistryTest.java
index 91a9b261bc7e06978f11f07168eb86183f1ea013..288c31d472b3ac4fb062e0407f2fcc09f42efce1 100644 (file)
@@ -7,39 +7,30 @@
  */
 package org.opendaylight.yangtools.util;
 
-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 java.util.EventListener;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-public class ListenerRegistryTest {
-    private ExtendedTestEventListener extendedTestEventListener;
-    private ListenerRegistry<TestEventListener> registry;
-
-    @Before
-    public void init() {
-        extendedTestEventListener = new ExtendedTestEventListener() {};
-        registry = ListenerRegistry.create();
-    }
+import org.junit.jupiter.api.Test;
+
+class ListenerRegistryTest {
+    private final ExtendedTestEventListener extendedTestEventListener = new ExtendedTestEventListener() {};
+    private final ListenerRegistry<TestEventListener> registry = ListenerRegistry.create();
 
     @Test
-    public void testCreateNewInstance() {
-        assertNotNull("Intance of listener registry should not be null.", registry);
+    void testCreateNewInstance() {
+        assertNotNull(registry, "Intance of listener registry should not be null.");
     }
 
     @Test
-    public void testGetListenersMethod() {
-        assertEquals("Listener registry should not have any listeners.", 0, registry.streamListeners().count());
+    void testGetListenersMethod() {
+        assertEquals(0, registry.streamListeners().count(), "Listener registry should not have any listeners.");
     }
 
     @Test
-    public void testRegisterMethod() {
-        final ListenerRegistration<ExtendedTestEventListener> listenerRegistration = registry.register(
-            extendedTestEventListener);
-        assertEquals("Listeners should be the same.", extendedTestEventListener, listenerRegistration.getInstance());
+    void testRegisterMethod() {
+        final var listenerRegistration = registry.register(extendedTestEventListener);
+        assertEquals(extendedTestEventListener, listenerRegistration.getInstance(), "Listeners should be the same.");
     }
 
     interface TestEventListener extends EventListener {