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.hamcrest.Matchers.isA;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertThat;
14 import static org.junit.Assert.assertTrue;
16 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;
26 public class YinFileAugmentStmtTest extends AbstractYinModulesTest {
29 public void testAugment() {
30 final Module testModule = TestUtils.findModule(context, "main-impl").get();
31 assertNotNull(testModule);
33 final Set<AugmentationSchemaNode> augmentations = testModule.getAugmentations();
34 assertEquals(1, augmentations.size());
36 final Iterator<AugmentationSchemaNode> augmentIterator = augmentations.iterator();
37 final AugmentationSchemaNode augment = augmentIterator.next();
38 assertNotNull(augment);
39 assertTrue(augment.getTargetPath().toString().contains(
40 "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, "
41 + "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)module, "
42 + "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)configuration"));
44 assertEquals(1, augment.getChildNodes().size());
45 final DataSchemaNode caseNode = augment.findDataChildByName(
46 QName.create(testModule.getQNameModule(), "main-impl")).get();
47 assertThat(caseNode, isA(CaseSchemaNode.class));