YANGTOOLS-706: Split out yang-parser-rfc7950
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / parser / stmt / rfc7950 / Bug9241Test.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13
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;
24
25 public class Bug9241Test {
26
27     @Test
28     public void testImplicitInputAndOutputInAction() throws Exception {
29         final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug9241/foo.yang");
30         assertNotNull(schemaContext);
31
32         final Module fooModule = schemaContext.findModule("foo", Revision.of("2017-10-13")).get();
33
34         final ContainerSchemaNode actionCont = (ContainerSchemaNode) fooModule.getDataChildByName(QName.create(
35                 fooModule.getQNameModule(), "action-cont"));
36         assertNotNull(actionCont);
37
38         final ActionDefinition actionInCont = actionCont.getActions().iterator().next();
39
40         final ContainerSchemaNode input = actionInCont.getInput();
41         assertNotNull(input);
42         assertEquals(1, input.getChildNodes().size());
43         assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) input).getDeclared().getStatementSource());
44
45         final ContainerSchemaNode output = actionInCont.getOutput();
46         assertNotNull(output);
47         assertEquals(1, output.getChildNodes().size());
48         assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) output).getDeclared().getStatementSource());
49     }
50 }