2 * Copyright (c) 2016 Cisco Systems, Inc. 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
8 package org.opendaylight.yangtools.yang.stmt.yin;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import java.io.IOException;
14 import java.net.URISyntaxException;
16 import org.junit.Before;
17 import org.junit.Test;
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.RpcDefinition;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
23 import org.opendaylight.yangtools.yang.stmt.TestUtils;
24 import org.xml.sax.SAXException;
26 public class YinFileRpcStmtTest {
28 private SchemaContext context;
31 public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
32 context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
33 assertEquals(9, context.getModules().size());
37 public void testRpc() {
38 Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
40 Set<RpcDefinition> rpcs = testModule.getRpcs();
41 assertEquals(1, rpcs.size());
43 RpcDefinition rpc = rpcs.iterator().next();
44 assertEquals("get-schema", rpc.getQName().getLocalName());
45 assertEquals("This operation is used to retrieve a schema from the\n"
48 + "Positive Response:\n"
49 + "The NETCONF server returns the requested schema.\n"
51 + "Negative Response:\n"
52 + "If requested schema does not exist, the <error-tag> is\n"
53 + "'invalid-value'.\n"
55 + "If more than one schema matches the requested parameters, the\n"
56 + "<error-tag> is 'operation-failed', and <error-app-tag> is\n"
57 + "'data-not-unique'.", rpc.getDescription());
59 ContainerSchemaNode input = rpc.getInput();
61 assertEquals(3, input.getChildNodes().size());
63 ContainerSchemaNode output = rpc.getOutput();
64 assertNotNull(output);
65 assertEquals(1, output.getChildNodes().size());