Port yang-parser-rfc7950 to JUnit 5
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / yin / YinFileRpcStmtTest.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 package org.opendaylight.yangtools.yang.stmt.yin;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertNotNull;
12
13 import java.util.Collection;
14 import java.util.Optional;
15 import org.junit.jupiter.api.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
21 class YinFileRpcStmtTest extends AbstractYinModulesTest {
22     @Test
23     void testRpc() {
24         Module testModule = context.findModules("ietf-netconf-monitoring").iterator().next();
25
26         Collection<? extends RpcDefinition> rpcs = testModule.getRpcs();
27         assertEquals(1, rpcs.size());
28
29         RpcDefinition rpc = rpcs.iterator().next();
30         assertEquals("get-schema", rpc.getQName().getLocalName());
31         assertEquals(Optional.of("This operation is used to retrieve a schema from the\n"
32             + "NETCONF server.\n"
33             + "\n"
34             + "Positive Response:\n"
35             + "The NETCONF server returns the requested schema.\n"
36             + "\n"
37             + "Negative Response:\n"
38             + "If requested schema does not exist, the <error-tag> is\n"
39             + "'invalid-value'.\n"
40             + "\n"
41             + "If more than one schema matches the requested parameters, the\n"
42             + "<error-tag> is 'operation-failed', and <error-app-tag> is\n"
43             + "'data-not-unique'."), rpc.getDescription());
44
45         InputSchemaNode input = rpc.getInput();
46         assertNotNull(input);
47         assertEquals(3, input.getChildNodes().size());
48
49         OutputSchemaNode output = rpc.getOutput();
50         assertNotNull(output);
51         assertEquals(1, output.getChildNodes().size());
52     }
53 }