Fix leafref-to-enum encoding 11/89611/8
authorPeter Valka <Peter.Valka@pantheon.tech>
Wed, 6 May 2020 07:54:18 +0000 (09:54 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Jun 2020 13:52:59 +0000 (15:52 +0200)
commitf9eceb5081877db3fc3f840c44e943605f3f4335
tree0e1be902ad92ea28e252042dbe31c5cb22dd470a
parentd7bdb660913f7c0507d70c0433ad2cee4e698d13
Fix leafref-to-enum encoding

When we have a leafref pointing to an enum via an absolute path,
in and RPC, we end up using a no-op codec, whereas we should be
extracting the name (from enum constant, or SchemaContext).

This ends up being a problem not in codec itself, as it is using
reflection to acquire the return type, defaulting to no-op.

The problem lies with AbstractTypeGenerator, which ends up not
being able to look up the generated type in case of RPC. The problem
here is the order in which types are generated, as the leaf being
referenced is generated after the RPC itself -- hence we cannot
find the definition.

While this is again highlighting the problem of single-pass code
generation, we can side-step the problem by moving RPC/notification
generation after the root data generation.

As a further complication, we need to record the enum/schema mapping,
as the codec needs to be able to find them via leafref types.

JIRA: MDSAL-552
Change-Id: Ifd92807029cdb7ba92dcad5655bb34d3ff4cef9d
Signed-off-by: Peter Valka <Peter.Valka@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec/src/test/java/org/opendaylight/mdsal/binding/dom/codec/impl/Mdsal552Test.java [new file with mode: 0644]
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypeGenerator.java
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/Mdsal552Test.java [new file with mode: 0644]
binding/mdsal-binding-generator-impl/src/test/resources/mdsal552.yang [new file with mode: 0644]
binding/mdsal-binding-test-model/src/main/yang/mdsal552.yang [new file with mode: 0644]