Fix parsing of union values
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / server / spi / NC1265Test.java
index 2d7808be8ebb1ee561fe5864625e753fcfe7b776..b745117bbb4cb968f7e613a90c159a26b7e7bc23 100644 (file)
@@ -11,7 +11,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.text.ParseException;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.restconf.api.ApiPath;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
@@ -61,7 +60,6 @@ class NC1265Test {
     }
 
     @Test
-    @Disabled("relies on TypeDefinitionAwareCodec's union handling")
     void unionKeyInstanceIdentifier() {
         assertNormalized(YangInstanceIdentifier.builder()
             .node(XYZZY)
@@ -72,6 +70,30 @@ class NC1265Test {
             .build(), "nc1265:xyzzy=%2Fnc1265:baz=123");
     }
 
+    @Test
+    void unionKeyIdentityref() {
+        assertNormalized(YangInstanceIdentifier.builder()
+            .node(XYZZY)
+            .nodeWithKey(XYZZY, KEY, QName.create("nc1265", "base-id"))
+            .build(), "nc1265:xyzzy=nc1265:base-id");
+    }
+
+    @Test
+    void unionKeyLeafref() {
+        assertNormalized(YangInstanceIdentifier.builder()
+            .node(XYZZY)
+            .nodeWithKey(XYZZY, KEY, Uint8.valueOf(123))
+            .build(), "nc1265:xyzzy=123");
+    }
+
+    @Test
+    void unionKeyString() {
+        assertNormalized(YangInstanceIdentifier.builder()
+            .node(XYZZY)
+            .nodeWithKey(XYZZY, KEY, "abc")
+            .build(), "nc1265:xyzzy=abc");
+    }
+
     @Test
     void noslashInstanceIdentifierKey() {
         final var error = assertRestconfError("nc1265:bar=nc1265:baz=123");