Fix leafref-to-enum encoding 77/90377/2
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 15:02:47 +0000 (17:02 +0200)
commitf04f0b4634e4c26f396771bb870e8d7c919b78a3
tree63a40399c49305c06c192e2237535ab92c117da3
parent9b00df1529e40cdb1da0a4f7bbc3392e001f55fa
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>
(cherry picked from commit f9eceb5081877db3fc3f840c44e943605f3f4335)
(cherry picked from commit 4ad86c646f3e447842a46b89b8697b8276942955)
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]