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.util.Collection;
14 import java.util.Optional;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.InputSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.OutputSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
20 import org.opendaylight.yangtools.yang.stmt.TestUtils;
22 public class YinFileRpcStmtTest extends AbstractYinModulesTest {
25 public void testRpc() {
26 Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
28 Collection<? extends RpcDefinition> rpcs = testModule.getRpcs();
29 assertEquals(1, rpcs.size());
31 RpcDefinition rpc = rpcs.iterator().next();
32 assertEquals("get-schema", rpc.getQName().getLocalName());
33 assertEquals(Optional.of("This operation is used to retrieve a schema from the\n"
36 + "Positive Response:\n"
37 + "The NETCONF server returns the requested schema.\n"
39 + "Negative Response:\n"
40 + "If requested schema does not exist, the <error-tag> is\n"
41 + "'invalid-value'.\n"
43 + "If more than one schema matches the requested parameters, the\n"
44 + "<error-tag> is 'operation-failed', and <error-app-tag> is\n"
45 + "'data-not-unique'."), rpc.getDescription());
47 InputSchemaNode input = rpc.getInput();
49 assertEquals(3, input.getChildNodes().size());
51 OutputSchemaNode output = rpc.getOutput();
52 assertNotNull(output);
53 assertEquals(1, output.getChildNodes().size());