2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.Revision;
17 import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
22 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
23 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
25 public class Bug9241Test {
28 public void testImplicitInputAndOutputInAction() throws Exception {
29 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug9241/foo.yang");
30 assertNotNull(schemaContext);
32 final Module fooModule = schemaContext.findModule("foo", Revision.valueOf("2017-10-13")).get();
34 final ContainerSchemaNode actionCont = (ContainerSchemaNode) fooModule.getDataChildByName(QName.create(
35 fooModule.getQNameModule(), "action-cont"));
36 assertNotNull(actionCont);
38 final ActionDefinition actionInCont = actionCont.getActions().iterator().next();
40 final ContainerSchemaNode input = actionInCont.getInput();
42 assertEquals(1, input.getChildNodes().size());
43 assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) input).getDeclared().getStatementSource());
45 final ContainerSchemaNode output = actionInCont.getOutput();
46 assertNotNull(output);
47 assertEquals(1, output.getChildNodes().size());
48 assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) output).getDeclared().getStatementSource());