*/
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";
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()
}
@Test
- public void testLeafList() {
+ void testLeafList() {
assertEquals(Builders.containerBuilder()
.withNodeIdentifier(rootContainer)
.withChild(Builders.orderedLeafSetBuilder()
}
@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());