Merge "BUG 1082 Migrate sal-rest-connector to Async Data Broker API"
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / xml / to / cnsn / test / XmlAugmentedElementToCnSnTest.java
1 /*
2  * Copyright (c) 2014 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.controller.sal.restconf.impl.xml.to.cnsn.test;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertTrue;
12
13 import java.util.Set;
14 import org.junit.Test;
15 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
16 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
17 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
18 import org.opendaylight.yangtools.yang.data.api.Node;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20
21 public class XmlAugmentedElementToCnSnTest {
22
23     @Test
24     public void loadDataAugmentedSchemaMoreEqualNamesTest() {
25         loadAndNormalizeData("/common/augment/xml/dataa.xml", "/common/augment/yang", "main", "cont");
26         loadAndNormalizeData("/common/augment/xml/datab.xml", "/common/augment/yang", "main", "cont");
27     }
28
29     private void loadAndNormalizeData(String xmlPath, String yangPath, String topLevelElementName, String moduleName) {
30         Node<?> node = TestUtils.readInputToCnSn(xmlPath, false,
31                 XmlToCompositeNodeProvider.INSTANCE);
32         assertTrue(node instanceof CompositeNode);
33         CompositeNode cnSn = (CompositeNode)node;
34
35         Set<Module> modules = TestUtils.loadModulesFrom(yangPath);
36
37         assertNotNull(modules);
38         TestUtils.normalizeCompositeNode(cnSn, modules, topLevelElementName + ":" + moduleName);
39     }
40
41 }