-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When searching for children, we should be cognizant of the fact that we might be looking at an inherited contract -- such as 'output' of an 'action' inherited through 'uses'. Extend the runtime search algorithm to also look at previous() axis. JIRA: MDSAL-824 Change-Id: Ic2f57b266825c6121f7bd6156a86112abff4b67a Signed-off-by: Robert Varga <[email protected]>
- Loading branch information
Showing
4 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...g-generator/src/test/java/org/opendaylight/mdsal/binding/generator/impl/Mdsal824Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.opendaylight.mdsal.binding.generator.impl; | ||
|
||
import static org.hamcrest.CoreMatchers.instanceOf; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.opendaylight.mdsal.binding.model.api.JavaTypeName; | ||
import org.opendaylight.mdsal.binding.runtime.api.ActionRuntimeType; | ||
import org.opendaylight.mdsal.binding.runtime.api.ContainerRuntimeType; | ||
import org.opendaylight.mdsal.binding.runtime.api.InputRuntimeType; | ||
import org.opendaylight.mdsal.binding.runtime.api.ListRuntimeType; | ||
import org.opendaylight.mdsal.binding.runtime.api.OutputRuntimeType; | ||
import org.opendaylight.yangtools.yang.common.QName; | ||
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; | ||
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; | ||
|
||
public class Mdsal824Test { | ||
private static EffectiveModelContext CONTEXT; | ||
|
||
@BeforeClass | ||
public static void beforeClass() { | ||
CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/mdsal824"); | ||
} | ||
|
||
@Test | ||
public void testCompileTimeTypes() { | ||
assertEquals(13, DefaultBindingGenerator.generateFor(CONTEXT).size()); | ||
} | ||
|
||
@Test | ||
public void testRunTimeTypes() { | ||
final var types = BindingRuntimeTypesFactory.createTypes(CONTEXT); | ||
final var barTop = types.schemaTreeChild(QName.create("bar", "bar-top")); | ||
assertThat(barTop, instanceOf(ContainerRuntimeType.class)); | ||
final var barList = ((ContainerRuntimeType) barTop).schemaTreeChild(QName.create("bar", "bar-list")); | ||
assertThat(barList, instanceOf(ListRuntimeType.class)); | ||
final var barAction = ((ListRuntimeType) barList).schemaTreeChild(QName.create("bar", "foo")); | ||
assertThat(barAction, instanceOf(ActionRuntimeType.class)); | ||
|
||
final var barInput = ((ActionRuntimeType) barAction).schemaTreeChild(QName.create("bar", "input")); | ||
assertThat(barInput, instanceOf(InputRuntimeType.class)); | ||
assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.act.grp", "FooInput"), | ||
barInput.javaType().getIdentifier()); | ||
|
||
final var barOutput = ((ActionRuntimeType) barAction).schemaTreeChild(QName.create("bar", "output")); | ||
assertThat(barOutput, instanceOf(OutputRuntimeType.class)); | ||
assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.act.grp", "FooOutput"), | ||
barOutput.javaType().getIdentifier()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
binding/mdsal-binding-generator/src/test/resources/mdsal824/bar.yang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module bar { | ||
yang-version 1.1; | ||
namespace bar; | ||
prefix bar; | ||
|
||
import foo { prefix foo; } | ||
|
||
grouping bar-grp { | ||
list bar-list { | ||
key key; | ||
leaf key { | ||
type string; | ||
} | ||
|
||
uses foo:uses-grp; | ||
} | ||
} | ||
|
||
container bar-top { | ||
uses bar-grp; | ||
} | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
binding/mdsal-binding-generator/src/test/resources/mdsal824/foo.yang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module foo { | ||
yang-version 1.1; | ||
namespace foo; | ||
prefix foo; | ||
|
||
grouping act-grp { | ||
action foo { | ||
output { | ||
choice type { | ||
mandatory true; | ||
case some-type { | ||
leaf some-type { | ||
type string; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
grouping uses-grp { | ||
uses act-grp; | ||
} | ||
} |