Use local variable type inference
[yangtools.git] / parser / 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
25 public class YinFileAugmentStmtTest extends AbstractYinModulesTest {
26     @Test
27     public void testAugment() {
28         final Module testModule = context.findModules("main-impl").iterator().next();
29         assertNotNull(testModule);
30
31         final Collection<? extends AugmentationSchemaNode> augmentations = testModule.getAugmentations();
32         assertEquals(1, augmentations.size());
33
34         final Iterator<? extends AugmentationSchemaNode> augmentIterator = augmentations.iterator();
35         final AugmentationSchemaNode augment = augmentIterator.next();
36         assertNotNull(augment);
37         assertThat(augment.getTargetPath().toString(), containsString(
38             "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, module, "
39                     + "configuration"));
40
41         assertEquals(1, augment.getChildNodes().size());
42         final DataSchemaNode caseNode = augment.findDataChildByName(
43             QName.create(testModule.getQNameModule(), "main-impl")).get();
44         assertThat(caseNode, isA(CaseSchemaNode.class));
45     }
46 }