Bug 1411-4: MDSAL Binding2 Generator Impl
[mdsal.git] / binding2 / mdsal-binding2-generator-impl / src / main / test / java / org / opendaylight / mdsal / binding2 / YangTemplateTest.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
9 package org.opendaylight.mdsal.binding2;
10
11 import com.google.common.annotations.Beta;
12 import java.net.URISyntaxException;
13 import java.util.Set;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.binding2.txt.yangTemplateForModule;
17 import org.opendaylight.mdsal.binding2.txt.yangTemplateForNode;
18 import org.opendaylight.mdsal.binding2.txt.yangTemplateForNodes;
19 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
22
23 @Beta
24 public class YangTemplateTest {
25
26     private Set<Module> modules;
27
28     @Before
29     public void setup() throws URISyntaxException, ReactorException {
30         modules = TestUtils.loadModules(getClass().getResource("/yang-template").toURI());
31     }
32
33     @Test
34     public void printYangSnippetForModule() {
35         for (Module module : modules) {
36             /**
37              * We should be able to call Scala render method from Binding Generator implementation
38              * for 3 different inputs:
39              * 1. single SchemaNode
40              * 2. set of SchemaNode
41              * 3. whole Module
42              */
43             final String moduleBody = yangTemplateForModule.render(module).body();
44             //FIXME: don't do it this way, only for very first attempt to show results
45             System.out.println("module ".concat(module.getName()).concat(":").concat(moduleBody));
46
47             //TODO: finish following sections
48             for (DataSchemaNode dataSchemaNode : module.getChildNodes()) {
49                 final String nodeBody = yangTemplateForNode.render(dataSchemaNode).body();
50             }
51
52             final String rpcsBody = yangTemplateForNodes.render(module.getRpcs()).body();
53             final String notificationsBody = yangTemplateForNodes.render(module.getNotifications()).body();
54
55             //////////
56         }
57
58     }
59 }