Improve SchemaNodeIdentifier.toString()
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / yin / YinFileAugmentStmtTest.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.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.hamcrest.Matchers.isA;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15
16 import java.util.Collection;
17 import java.util.Iterator;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.Module;
24 import org.opendaylight.yangtools.yang.stmt.TestUtils;
25
26 public class YinFileAugmentStmtTest extends AbstractYinModulesTest {
27
28     @Test
29     public void testAugment() {
30         final Module testModule = TestUtils.findModule(context, "main-impl").get();
31         assertNotNull(testModule);
32
33         final Collection<? extends AugmentationSchemaNode> augmentations = testModule.getAugmentations();
34         assertEquals(1, augmentations.size());
35
36         final Iterator<? extends AugmentationSchemaNode> augmentIterator = augmentations.iterator();
37         final AugmentationSchemaNode augment = augmentIterator.next();
38         assertNotNull(augment);
39         assertThat(augment.getTargetPath().toString(), containsString(
40             "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, module, "
41                     + "configuration"));
42
43         assertEquals(1, augment.getChildNodes().size());
44         final DataSchemaNode caseNode = augment.findDataChildByName(
45             QName.create(testModule.getQNameModule(), "main-impl")).get();
46         assertThat(caseNode, isA(CaseSchemaNode.class));
47     }
48 }