Migrate yang-data-impl to JUnit5
[yangtools.git] / data / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / schema / InstanceIdToNodesTest.java
index 3827b5a413416786aec90fa40a1ac8b00e0c18ee..9a89ef3b9297b8ccd140f07e59070e9f73adb448 100644 (file)
@@ -7,31 +7,27 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import com.google.common.collect.ImmutableMap;
-import java.util.Collection;
 import java.util.Map;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.util.ImmutableOffsetMap;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class InstanceIdToNodesTest {
+class InstanceIdToNodesTest {
 
     private static final String NS = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:normalization:test";
     private static final String REVISION = "2014-03-13";
@@ -50,18 +46,18 @@ public class InstanceIdToNodesTest {
     private final NodeIdentifier leafList = new NodeIdentifier(QName.create(NS, REVISION, "ordered-leaf-list"));
     private final NodeWithValue<?> leafListWithValue = new NodeWithValue<>(leafList.getNodeType(), "abcd");
 
-    @BeforeClass
-    public static void setUp() {
+    @BeforeAll
+    static void setUp() {
         ctx = YangParserTestUtils.parseYangResources(InstanceIdToNodesTest.class, "/filter-test.yang");
     }
 
-    @AfterClass
-    public static void teardown() {
+    @AfterAll
+    static void teardown() {
         ctx = null;
     }
 
     @Test
-    public void testListLastChildOverride() {
+    void testListLastChildOverride() {
         assertEquals(Builders.containerBuilder()
             .withNodeIdentifier(rootContainer)
             .withChild(Builders.mapBuilder()
@@ -79,7 +75,7 @@ public class InstanceIdToNodesTest {
     }
 
     @Test
-    public void testLeafList() {
+    void testLeafList() {
         assertEquals(Builders.containerBuilder()
             .withNodeIdentifier(rootContainer)
             .withChild(Builders.orderedLeafSetBuilder()
@@ -94,22 +90,21 @@ public class InstanceIdToNodesTest {
     }
 
     @Test
-    public void testEmptyInstanceIdentifier() {
+    void testEmptyInstanceIdentifier() {
         assertEquals(ImmutableNodes.containerNode(SchemaContext.NAME),
             ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of()));
     }
 
     @Test
-    public void testKeyOrdering() {
+    void testKeyOrdering() {
         final Map<QName, Object> misordered = ImmutableOffsetMap.orderedCopyOf(ImmutableMap.of(BAR, "bar", FOO, "foo"));
-        final NodeIdentifierWithPredicates id = NodeIdentifierWithPredicates.of(TWO_KEY_LIST.getNodeType(), misordered);
+        final var id = NodeIdentifierWithPredicates.of(TWO_KEY_LIST.getNodeType(), misordered);
         assertArrayEquals(new Object[] { BAR, FOO }, id.keySet().toArray());
 
-        final NormalizedNode filter = ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of(TWO_KEY_LIST, id));
-        assertThat(filter, isA(MapNode.class));
-        final Collection<MapEntryNode> value = ((MapNode) filter).body();
+        final var filter = ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of(TWO_KEY_LIST, id));
+        final var value = assertInstanceOf(MapNode.class, filter).body();
         assertEquals(1, value.size());
-        final MapEntryNode entry = value.iterator().next();
+        final var entry = value.iterator().next();
 
         // The entry must have a the proper order
         assertArrayEquals(new Object[] { FOO, BAR }, entry.name().keySet().toArray());