Deprecate simple DataTreeFactory.create()
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug6410Test.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;
9
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.junit.jupiter.api.Assertions.assertEquals;
12
13 import org.junit.jupiter.api.Test;
14
15 class Bug6410Test extends AbstractYangTest {
16     @Test
17     void testTypedefsInRpc() {
18         final var schemaContext = assertEffectiveModel("/bugs/bug6410/foo.yang");
19
20         final var modules = schemaContext.getModules();
21         assertEquals(1, modules.size());
22         final var module = modules.iterator().next();
23
24         final var rpcs = module.getRpcs();
25         assertEquals(1, rpcs.size());
26         final var rpc = rpcs.iterator().next();
27
28         final var typeDefs = rpc.getTypeDefinitions();
29         assertEquals(2, typeDefs.size());
30     }
31
32     @Test
33     void shouldFailOnDuplicateTypedefs() {
34         assertSourceException(containsString("Duplicate name for typedef"), "/bugs/bug6410/bar.yang");
35     }
36 }