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
9 package org.opendaylight.mdsal.binding2;
11 import com.google.common.annotations.Beta;
12 import java.io.FileNotFoundException;
13 import java.net.URISyntaxException;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.mdsal.binding2.txt.yangTemplateForModule;
18 import org.opendaylight.mdsal.binding2.txt.yangTemplateForNode;
19 import org.opendaylight.mdsal.binding2.txt.yangTemplateForNodes;
20 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.Module;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
23 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
26 public class YangTemplateTest {
28 private Set<Module> modules;
31 public void setup() throws URISyntaxException, ReactorException, FileNotFoundException {
32 modules = YangParserTestUtils.parseYangSources("/yang-template").getModules();
36 public void printYangSnippetForModule() {
37 for (Module module : modules) {
39 * We should be able to call Scala render method from Binding Generator implementation
40 * for 3 different inputs:
41 * 1. single SchemaNode
42 * 2. set of SchemaNode
45 final String moduleBody = yangTemplateForModule.render(module).body();
46 //FIXME: don't do it this way, only for very first attempt to show results
47 System.out.println("module ".concat(module.getName()).concat(":").concat(moduleBody));
49 //TODO: finish following sections
50 for (DataSchemaNode dataSchemaNode : module.getChildNodes()) {
51 final String nodeBody = yangTemplateForNode.render(dataSchemaNode).body();
54 final String rpcsBody = yangTemplateForNodes.render(module.getRpcs()).body();
55 final String notificationsBody = yangTemplateForNodes.render(module.getNotifications()).body();