Address FIXME for QueuedNotificationManager
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / RpcStmtTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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.stmt;
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.model.api.AnyXmlSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
20 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
23 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
24
25 public class RpcStmtTest {
26
27     private static final YangStatementSourceImpl RPC_MODULE = new YangStatementSourceImpl("/model/baz.yang", false);
28     private static final YangStatementSourceImpl IMPORTED_MODULE = new YangStatementSourceImpl("/model/bar.yang",
29             false);
30
31     @Test
32     public void rpcTest() throws ReactorException {
33         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
34         StmtTestUtils.addSources(reactor, RPC_MODULE, IMPORTED_MODULE);
35
36         EffectiveSchemaContext result = reactor.buildEffective();
37         assertNotNull(result);
38
39         Module testModule = result.findModuleByName("baz", null);
40         assertNotNull(testModule);
41
42         assertEquals(1, testModule.getRpcs().size());
43
44         RpcDefinition rpc = testModule.getRpcs().iterator().next();
45         assertEquals("get-config", rpc.getQName().getLocalName());
46
47         ContainerSchemaNode input = rpc.getInput();
48         assertNotNull(input);
49         assertEquals(2, input.getChildNodes().size());
50
51         ContainerSchemaNode container = (ContainerSchemaNode) input.getDataChildByName("source");
52         assertNotNull(container);
53         AnyXmlSchemaNode anyXml = (AnyXmlSchemaNode) input.getDataChildByName("filter");
54         assertNotNull(anyXml);
55
56         ContainerSchemaNode output = rpc.getOutput();
57         assertNotNull(output);
58         assertEquals(1, output.getChildNodes().size());
59
60         anyXml = (AnyXmlSchemaNode) output.getDataChildByName("data");
61         assertNotNull(anyXml);
62     }
63 }