Eliminate SchemaPath references in codec infrastructure 28/92828/4
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 1 Oct 2020 10:01:02 +0000 (12:01 +0200)
committerRobert Varga <nite@hq.sk>
Thu, 1 Oct 2020 13:23:29 +0000 (13:23 +0000)
We have switched to SchemaNodeIdentifier across the board, this patch
makes the finishing touches.

JIRA: MDSAL-570
Change-Id: I8b54143e71ebbd4aef03cb00704e2b4f5311174f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMRpcProviderServiceAdapter.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/CurrentAdapterSerializer.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/LazySerializedDOMNotification.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/ActionLookupTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/BindingNormalizedCodecTest.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java

index 91ff75fbebfa693590918a7071d3a29336112df9..af2c44fe92f441601b0b0e162fd12cccd72d2c4f 100644 (file)
@@ -49,7 +49,7 @@ public class BindingDOMRpcProviderServiceAdapter extends AbstractBindingAdapter<
 
     private <S extends RpcService, T extends S> ObjectRegistration<T> register(final Class<S> type,
             final T implementation, final Collection<YangInstanceIdentifier> rpcContextPaths) {
-        final Map<QName, Method> rpcs = currentSerializer().getRpcMethodToSchemaPath(type).inverse();
+        final Map<QName, Method> rpcs = currentSerializer().getRpcMethodToQName(type).inverse();
 
         final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter(adapterContext(),
             type, rpcs, implementation);
index 14b2fc278f23e83c0aac7f42399b6392afff2697..cea844371fdda9e5f6c2169c6810c74fe0e50074 100644 (file)
@@ -103,7 +103,7 @@ public final class CurrentAdapterSerializer extends ForwardingBindingDOMCodecSer
     }
 
     // FIXME: This should be probably part of Binding Runtime context
-    ImmutableBiMap<Method, QName> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) {
+    ImmutableBiMap<Method, QName> getRpcMethodToQName(final Class<? extends RpcService> key) {
         final Module module = getModule(key);
         final ImmutableBiMap.Builder<Method, QName> ret = ImmutableBiMap.builder();
         try {
index 40098457035db58588c252f5c357635490ab0a9f..847e0eb6ce0edfde03c488372200719cb80c7d4a 100644 (file)
@@ -34,10 +34,10 @@ public final class LazySerializedDOMNotification implements DOMNotification, DOM
             .build(new CacheLoader<Class<?>, Absolute>() {
                 @Override
                 public Absolute load(final Class<?> key) {
-                    // TODO: for nested (YANG 1.1) notifications we will need the SchemaPath where the notification is
-                    //       being invoked and use that instead of ROOT. How Binding users will refer to it is TBD (but
-                    //       probably InstanceIdentifier, which means we will need to do some lifting to find the
-                    //       SchemaPath)
+                    // TODO: for nested (YANG 1.1) notifications we will need the SchemaNodeIdentifier where the
+                    //       notification is being invoked and use that instead of ROOT. How Binding users will refer to
+                    //       it is TBD (but probably InstanceIdentifier, which means we will need to do some lifting to
+                    //       find the SchemaNodeIdentifier)
                     return Absolute.of(BindingReflections.findQName(key)).intern();
                 }
             });
index 597e4cef0982c9b1c8cb1264de7d4f64fca8fb77..fd9c54c9fad42bbc9659c132829ed83d57afcde0 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absol
 
 public class ActionLookupTest {
     @Test
-    public void testActionSchemaPath() {
+    public void testActionPath() {
         CurrentAdapterSerializer codec = new CurrentAdapterSerializer(new BindingCodecContext(
             BindingRuntimeHelpers.createRuntimeContext()));
 
index 8e223880e2405d3a59badfeef33bb2d20bc36229..b74c659ac73f785e204bee3ab530c12c8563de17 100644 (file)
@@ -80,10 +80,10 @@ public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest {
     }
 
     @Test
-    public void testGetRpcMethodToSchemaPath() {
+    public void testGetRpcMethodToQName() {
         codec.onModelContextUpdated(context);
         final List<String> retMap = codec.currentSerializer()
-                .getRpcMethodToSchemaPath(OpendaylightTestRpcServiceService.class).keySet().stream()
+                .getRpcMethodToQName(OpendaylightTestRpcServiceService.class).keySet().stream()
                 .map(Method::getName)
                 .collect(Collectors.toList());
         assertTrue(retMap.contains("rockTheHouse"));
index e00999b7265a928938bc2e99b854d303eeb1edbf..8d10ff2948155617b27553375c11a815be6dd685 100644 (file)
@@ -47,7 +47,6 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
@@ -271,14 +270,8 @@ final class SchemaRootCodecContext<D extends DataObject> extends DataContainerCo
         checkArgument(Notification.class.isAssignableFrom(notificationType));
         checkArgument(notificationType.isInterface(), "Supplied class must be interface.");
         final QName qname = BindingReflections.findQName(notificationType);
-        /**
-         *  FIXME: After Lithium cleanup of yang-model-api, use direct call on schema context
-         *  to retrieve notification via index.
-         */
-        final NotificationDefinition schema = SchemaContextUtil.getNotificationSchema(getSchema(),
-                SchemaPath.create(true, qname));
-        checkArgument(schema != null, "Supplied %s is not valid notification", notificationType);
-
+        final NotificationDefinition schema = getSchema().findNotification(qname).orElseThrow(
+            () -> new IllegalArgumentException("Supplied " + notificationType + " is not valid notification"));
         return new NotificationCodecContext<>(notificationType, schema, factory());
     }