Add ApiPath.toString()
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / utils / parser / YangInstanceIdentifierSerializerTest.java
index 7fcb0f42a2ac7ca1198240ab5204d873ef58258e..2d7e15716098cc265bfef5da921975ffd68e5977 100644 (file)
@@ -11,17 +11,14 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.collect.ImmutableSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@@ -35,8 +32,8 @@ public class YangInstanceIdentifierSerializerTest {
     private static EffectiveModelContext SCHEMA_CONTEXT;
 
     @BeforeClass
-    public static void beforeClass() throws Exception {
-        SCHEMA_CONTEXT = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/parser/serializer"));
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/restconf/parser/serializer");
     }
 
     @AfterClass
@@ -205,7 +202,7 @@ public class YangInstanceIdentifierSerializerTest {
     @Test
     public void serializeNullSchemaContextNegativeTest() {
         assertThrows(NullPointerException.class,
-            () -> YangInstanceIdentifierSerializer.create(null, YangInstanceIdentifier.empty()));
+            () -> YangInstanceIdentifierSerializer.create(null, YangInstanceIdentifier.of()));
     }
 
     /**
@@ -226,7 +223,7 @@ public class YangInstanceIdentifierSerializerTest {
      */
     @Test
     public void serializeEmptyDataTest() {
-        final String result = YangInstanceIdentifierSerializer.create(SCHEMA_CONTEXT, YangInstanceIdentifier.empty());
+        final String result = YangInstanceIdentifierSerializer.create(SCHEMA_CONTEXT, YangInstanceIdentifier.of());
         assertTrue("Empty identifier is expected", result.isEmpty());
     }
 
@@ -245,26 +242,6 @@ public class YangInstanceIdentifierSerializerTest {
             () -> YangInstanceIdentifierSerializer.create(SCHEMA_CONTEXT, data));
     }
 
-    /**
-     * Test to verify if all reserved characters according to rfc3986 are considered by serializer implementation to
-     * be percent encoded.
-     */
-    @Test
-    public void verifyReservedCharactersTest() {
-        final char[] genDelims = { ':', '/', '?', '#', '[', ']', '@' };
-        final char[] subDelims = { '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' };
-
-        for (final char c : genDelims) {
-            assertTrue("Current character is reserved and should be percent encoded",
-                    YangInstanceIdentifierSerializer.PERCENT_ENCODE_CHARS.matches(c));
-        }
-
-        for (final char c : subDelims) {
-            assertTrue("Current character is reserved and should be percent encoded",
-                    YangInstanceIdentifierSerializer.PERCENT_ENCODE_CHARS.matches(c));
-        }
-    }
-
     /**
      * Test if URIs with percent encoded characters are all correctly serialized.
      */
@@ -312,7 +289,6 @@ public class YangInstanceIdentifierSerializerTest {
         final YangInstanceIdentifier data = YangInstanceIdentifier.builder()
                 .node(list)
                 .node(NodeIdentifierWithPredicates.of(list, QName.create(list, "list-key"), 100))
-                .node(new AugmentationIdentifier(ImmutableSet.of(child)))
                 .node(child)
                 .build();
 
@@ -337,7 +313,6 @@ public class YangInstanceIdentifierSerializerTest {
         final YangInstanceIdentifier data = YangInstanceIdentifier.builder()
                 .node(list)
                 .node(NodeIdentifierWithPredicates.of(list, QName.create(list, "list-key"), 100))
-                .node(new AugmentationIdentifier(ImmutableSet.of(child)))
                 .node(child)
                 .build();