Apply style rules on whole sal-rest-connector
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / NormalizeNodeTest.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.test;
9
10 import static org.junit.Assert.assertNotNull;
11
12 import java.net.URI;
13 import java.net.URISyntaxException;
14 import org.junit.BeforeClass;
15 import org.junit.Test;
16 import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
17 import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
18 import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
19 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
20
21 public class NormalizeNodeTest extends YangAndXmlAndDataSchemaLoader {
22
23     @BeforeClass
24     public static void initialization() {
25         dataLoad("/normalize-node/yang/");
26     }
27
28     @Test(expected = RestconfDocumentedException.class)
29     public void namespaceNotNullAndInvalidNamespaceAndNoModuleNameTest() {
30
31         TestUtils.normalizeCompositeNode(prepareCnSn("wrongnamespace"), modules, schemaNodePath);
32     }
33
34     @Test
35     public void namespaceNullTest() {
36
37         TestUtils.normalizeCompositeNode(prepareCnSn(null), modules, schemaNodePath);
38     }
39
40     @Test
41     public void namespaceValidNamespaceTest() {
42
43         TestUtils.normalizeCompositeNode(prepareCnSn("normalize:node:module"), modules, schemaNodePath);
44     }
45
46     @Test
47     public void namespaceValidModuleNameTest() {
48
49         TestUtils.normalizeCompositeNode(prepareCnSn("normalize-node-module"), modules, schemaNodePath);
50     }
51
52     private CompositeNode prepareCnSn(final String namespace) {
53         URI uri = null;
54         if (namespace != null) {
55             try {
56                 uri = new URI(namespace);
57             } catch (URISyntaxException e) {
58             }
59             assertNotNull(uri);
60         }
61
62         SimpleNodeWrapper lf1 = new SimpleNodeWrapper(uri, "lf1", 43);
63         CompositeNodeWrapper cont = new CompositeNodeWrapper(uri, "cont");
64         cont.addValue(lf1);
65
66         return cont;
67     }
68
69 }