Migrate yang-repo-spi to JUnit5
[yangtools.git] / yang / yang-repo-spi / src / test / java / org / opendaylight / yangtools / yang / model / repo / spi / RefcountedRegistrationTest.java
index ec8f6bdf0f763b6f0437312eba9e9218b09680e4..a3124d2f55d0a09e0dd0b38265b27aa79e5ff5ca 100644 (file)
@@ -7,49 +7,40 @@
  */
 package org.opendaylight.yangtools.yang.model.repo.spi;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 
-@RunWith(MockitoJUnitRunner.class)
-public class RefcountedRegistrationTest {
+@ExtendWith(MockitoExtension.class)
+class RefcountedRegistrationTest {
     @Mock
-    public SchemaSourceRegistration<?> reg;
-
-    @Before
-    public void before() {
-        doNothing().when(reg).close();
-    }
+    private SchemaSourceRegistration<?> reg;
 
     @Test
-    public void refcountDecTrue() {
-        final RefcountedRegistration ref = new RefcountedRegistration(reg);
+    void refcountDecTrue() {
+        final var ref = new RefcountedRegistration(reg);
+        doNothing().when(reg).close();
         assertTrue(ref.decRef());
-        verify(reg, times(1)).close();
     }
 
     @Test
-    public void refcountIncDecFalse() {
-        final RefcountedRegistration ref = new RefcountedRegistration(reg);
+    void refcountIncDecFalse() {
+        final var ref = new RefcountedRegistration(reg);
         ref.incRef();
         assertFalse(ref.decRef());
-        verify(reg, times(0)).close();
     }
 
     @Test
-    public void refcountIncDecTrue() {
-        final RefcountedRegistration ref = new RefcountedRegistration(reg);
+    void refcountIncDecTrue() {
+        final var ref = new RefcountedRegistration(reg);
         ref.incRef();
         assertFalse(ref.decRef());
+        doNothing().when(reg).close();
         assertTrue(ref.decRef());
-        verify(reg, times(1)).close();
     }
 }