final GeneratedType output;
if (action.isAddedByUses()) {
final ActionDefinition orig = findOrigAction(parentSchema, action).get();
- input = context.getChildNode(orig.getInput().getPath()).build();
- output = context.getChildNode(orig.getOutput().getPath()).build();
+ // Original definition may live in a different module, make sure we account for that
+ final ModuleContext origContext = moduleContext(
+ orig.getPath().getPathFromRoot().iterator().next().getModule());
+ input = origContext.getChildNode(orig.getInput().getPath()).build();
+ output = origContext.getChildNode(orig.getOutput().getPath()).build();
} else {
input = actionContainer(context, RPC_INPUT, action.getInput(), inGrouping);
output = actionContainer(context, RPC_OUTPUT, action.getOutput(), inGrouping);
}
private Optional<ActionDefinition> findOrigAction(final DataNodeContainer parent, final ActionDefinition action) {
+ final QName qname = action.getQName();
for (UsesNode uses : parent.getUses()) {
final GroupingDefinition grp = findUsedGrouping(uses);
- final Optional<ActionDefinition> found = grp.findAction(action.getQName());
+ // Target grouping may reside in a different module, hence we need to rebind the QName to match grouping's
+ // namespace
+ final Optional<ActionDefinition> found = grp.findAction(qname.withModule(grp.getQName().getModule()));
if (found.isPresent()) {
final ActionDefinition result = found.get();
return result.isAddedByUses() ? findOrigAction(grp, result) : found;
--- /dev/null
+/*
+ * Copyright (c) 2020 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.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+import org.junit.Test;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+
+public class Mdsal516Test {
+ @Test
+ public void testGroupingActionType() {
+ final List<Type> types = new BindingGeneratorImpl().generateTypes(
+ YangParserTestUtils.parseYangResourceDirectory("/mdsal-516"));
+ assertNotNull(types);
+ assertEquals(7, types.size());
+ }
+}