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.net.URISyntaxException;
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;
24 public class YangTemplateTest {
26 private Set<Module> modules;
29 public void setup() throws URISyntaxException, ReactorException {
30 modules = TestUtils.loadModules(getClass().getResource("/yang-template").toURI());
34 public void printYangSnippetForModule() {
35 for (Module module : modules) {
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
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));
47 //TODO: finish following sections
48 for (DataSchemaNode dataSchemaNode : module.getChildNodes()) {
49 final String nodeBody = yangTemplateForNode.render(dataSchemaNode).body();
52 final String rpcsBody = yangTemplateForNodes.render(module.getRpcs()).body();
53 final String notificationsBody = yangTemplateForNodes.render(module.getNotifications()).body();