Migrate common/util to JUnit5
[yangtools.git] / common / util / src / test / java / org / opendaylight / yangtools / util / UnmodifiableCollectionTest.java
index b36370102be030a8747f206de67fb70e60697768..080653ae9eaa9d34f62ccacf127a7e89aa160999 100644 (file)
@@ -7,41 +7,39 @@
  */
 package org.opendaylight.yangtools.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.UnmodifiableIterator;
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class UnmodifiableCollectionTest {
+class UnmodifiableCollectionTest {
 
     @Test
-    public void testUnmodifiableCollection() {
-        final List<Integer> immutableTestList = ImmutableList.<Integer>builder()
+    void testUnmodifiableCollection() {
+        final var immutableTestList = ImmutableList.<Integer>builder()
                 .add(1)
                 .add(2)
                 .add(3)
                 .add(4)
                 .add(5).build();
 
-        final Collection<Integer> testUnmodifiableCollection = UnmodifiableCollection.create(immutableTestList);
+        final var testUnmodifiableCollection = UnmodifiableCollection.create(immutableTestList);
         assertNotNull(testUnmodifiableCollection);
 
         // Note: this cannot be ImmutableList, because UnmodifiableCollection does recognize it and returns it as is,
         //       without converting it to an UnmodifiableCollection -- which is not what we want.
-        final List<Integer> testList = Arrays.asList(1, 2, 3, 4, 5);
-        final Collection<Integer> testUnmodifiableCollection2 = UnmodifiableCollection.create(testList);
+        final var testList = Arrays.asList(1, 2, 3, 4, 5);
+        final var testUnmodifiableCollection2 = UnmodifiableCollection.create(testList);
 
-        final Iterator<Integer> iterator = testUnmodifiableCollection2.iterator();
+        final var iterator = testUnmodifiableCollection2.iterator();
         assertNotNull(iterator);
-        assertTrue(iterator instanceof UnmodifiableIterator);
+        assertInstanceOf(UnmodifiableIterator.class, iterator);
 
         assertEquals(5, testUnmodifiableCollection2.size());
 
@@ -49,11 +47,11 @@ public class UnmodifiableCollectionTest {
 
         assertTrue(testUnmodifiableCollection2.contains(1));
 
-        final Object[] objectArray = testUnmodifiableCollection2.toArray();
+        final var objectArray = testUnmodifiableCollection2.toArray();
         assertNotNull(objectArray);
         assertEquals(5, objectArray.length);
 
-        final Integer[] integerArray = testUnmodifiableCollection2.toArray(
+        final var integerArray = testUnmodifiableCollection2.toArray(
                 new Integer[testUnmodifiableCollection2.size()]);
         assertNotNull(integerArray);
         assertEquals(5, integerArray.length);