import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import com.google.common.collect.ImmutableList;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
import java.util.List;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.generator.impl.BindingGeneratorImpl;
import org.opendaylight.mdsal.binding.model.api.GeneratedType;
import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class BindingGeneratorImplTest {
@Test
- public void isisTotpologyStatementParserTest() throws IOException,
- URISyntaxException, ReactorException {
- final InputStream topo = getClass().getResourceAsStream("/isis-topology/network-topology@2013-10-21.yang");
- final InputStream isis = getClass().getResourceAsStream("/isis-topology/isis-topology@2013-10-21.yang");
- final InputStream l3 = getClass().getResourceAsStream("/isis-topology/l3-unicast-igp-topology@2013-10-21.yang");
+ public void isisTotpologyStatementParserTest() throws Exception {
+ final File topo = new File(getClass().getResource("/isis-topology/network-topology@2013-10-21.yang").toURI());
+ final File isis = new File(getClass().getResource("/isis-topology/isis-topology@2013-10-21.yang").toURI());
+ final File l3 =
+ new File(getClass().getResource("/isis-topology/l3-unicast-igp-topology@2013-10-21.yang").toURI());
- SchemaContext context = YangParserTestUtils.parseYangStreams(ImmutableList.of(isis, l3, topo));
+ final SchemaContext context = YangParserTestUtils.parseYangFiles(ImmutableList.of(isis, l3, topo));
assertNotNull(context);
- List<Type> generateTypes = new BindingGeneratorImpl(false)
+ final List<Type> generateTypes = new BindingGeneratorImpl(false)
.generateTypes(context);
assertFalse(generateTypes.isEmpty());
}
@Test
- public void choiceNodeGenerationTest() throws IOException,
- URISyntaxException, ReactorException {
- File resourceFile = new File(getClass().getResource(
+ public void choiceNodeGenerationTest() throws Exception {
+ final File resourceFile = new File(getClass().getResource(
"/binding-generator-impl-test/choice-test.yang").toURI());
- SchemaContext context = YangParserTestUtils.parseYangSources(resourceFile);
+ final SchemaContext context = YangParserTestUtils.parseYangFiles(resourceFile);
- List<Type> generateTypes = new BindingGeneratorImpl(false)
+ final List<Type> generateTypes = new BindingGeneratorImpl(false)
.generateTypes(context);
GeneratedType choiceTestData = null;
GeneratedType myList2 = null;
GeneratedType myContainer2 = null;
- for (Type type : generateTypes) {
+ for (final Type type : generateTypes) {
switch (type.getName()) {
case "ChoiceTestData":
choiceTestData = (GeneratedType) type;
List<Type> implements1 = myContainer.getImplements();
Type childOfParamType = null;
- for (Type type : implements1) {
+ for (final Type type : implements1) {
if (type.getName().equals("ChildOf")) {
childOfParamType = ((ParameterizedType) type)
.getActualTypeArguments()[0];
implements1 = myList.getImplements();
childOfParamType = null;
- for (Type type : implements1) {
+ for (final Type type : implements1) {
if (type.getName().equals("ChildOf")) {
childOfParamType = ((ParameterizedType) type)
.getActualTypeArguments()[0];
implements1 = myContainer2.getImplements();
childOfParamType = null;
- for (Type type : implements1) {
+ for (final Type type : implements1) {
if (type.getName().equals("ChildOf")) {
childOfParamType = ((ParameterizedType) type)
.getActualTypeArguments()[0];
implements1 = myList2.getImplements();
childOfParamType = null;
- for (Type type : implements1) {
+ for (final Type type : implements1) {
if (type.getName().equals("ChildOf")) {
childOfParamType = ((ParameterizedType) type)
.getActualTypeArguments()[0];
}
@Test
- public void notificationGenerationTest() throws IOException, URISyntaxException, ReactorException {
- File resourceFile = new File(getClass().getResource(
+ public void notificationGenerationTest() throws Exception {
+ final File resourceFile = new File(getClass().getResource(
"/binding-generator-impl-test/notification-test.yang").toURI());
- SchemaContext context = YangParserTestUtils.parseYangSources(resourceFile);
+ final SchemaContext context = YangParserTestUtils.parseYangFiles(resourceFile);
- List<Type> generateTypes = new BindingGeneratorImpl(false)
+ final List<Type> generateTypes = new BindingGeneratorImpl(false)
.generateTypes(context);
GeneratedType foo = null;
- for (Type type : generateTypes) {
+ for (final Type type : generateTypes) {
if (type.getName().equals("Foo")) {
foo = (GeneratedType) type;
break;
Type childOf = null;
Type dataObject = null;
- List<Type> impl = foo.getImplements();
- for (Type type : impl) {
+ final List<Type> impl = foo.getImplements();
+ for (final Type type : impl) {
switch (type.getName()) {
case "ChildOf":
childOf = type;