/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
import com.google.common.base.Optional;
+
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
-import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
import org.opendaylight.yangtools.yang.model.util.Decimal64;
import org.opendaylight.yangtools.yang.model.util.StringType;
import org.opendaylight.yangtools.yang.model.util.Uint16;
import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class BindingGeneratorUtilTest {
/**
* Tests methods:
- * <ul>
- * <li>moduleNamespaceToPackageName</li> - with revision
- * <li>packageNameForGeneratedType</li>
- * <ul>
- * <li>validateJavaPackage</li>
- * </ul>
- * <li>packageNameForTypeDefinition</li> <li>moduleNamespaceToPackageName</li>
- * - without revision </ul>
+ * <ul>
+ * <li>moduleNamespaceToPackageName</li> - with revision
+ * <li>packageNameForGeneratedType</li>
+ * <ul>
+ * <li>validateJavaPackage</li>
+ * </ul>
+ * <li>packageNameForTypeDefinition</li> <li>moduleNamespaceToPackageName</li>
+ * - without revision </ul>
+ * @throws ReactorException Reactor exception
+ * @throws SourceException Source exception
*/
@Test
- public void testBindingGeneratorUtilMethods() throws IOException {
+ public void testBindingGeneratorUtilMethods() throws IOException, SourceException, ReactorException {
List<File> testModels = loadTestResources("/module.yang");
- final YangContextParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseFiles(testModels).getModules();
+
+ final Set<Module> modules = RetestUtils.parseYangSources(testModels).getModules();
String packageName = "";
Module module = null;
for (Module m : modules) {
/**
* Test for the method
- * <ul>
- * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition()
- * packageNameForTypeDefinition()}</li>
- * </ul>
+ * <ul>
+ * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition(String, TypeDefinition)
+ * packageNameForTypeDefinition(String, TypeDefinition)}</li>
+ * </ul>
*/
@Test
+ @Deprecated
public void testPackageNameForTypeDefinitionNullBasePackageName() {
expectedEx.expect(IllegalArgumentException.class);
expectedEx.expectMessage("Base Package Name cannot be NULL!");
/**
* Test for the method
- * <ul>
- * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition()
- * packageNameForTypeDefinition()}</li>
- * </ul>
+ * <ul>
+ * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition(String, TypeDefinition)
+ * packageNameForTypeDefinition(String, TypeDefinition)}</li>
+ * </ul>
*/
@Test
+ @Deprecated
public void testPackageNameForTypeDefinitionNullTypeDefinition() {
expectedEx.expect(IllegalArgumentException.class);
expectedEx.expectMessage("Type Definition reference cannot be NULL!");
/**
* Test for the method
- * <ul>
- * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType()
- * packageNameForGeneratedType()}</li>
- * </ul>
+ * <ul>
+ * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType(String, SchemaPath)
+ * packageNameForGeneratedType(String, SchemaPath)}</li>
+ * </ul>
*/
@Test
public void testPackageNameForGeneratedTypeNullBasePackageName() {
/**
* Test for the method
- * <ul>
- * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType()
- * packageNameForGeneratedType()}</li>
- * </ul>
+ * <ul>
+ * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType(String, SchemaPath)
+ * packageNameForGeneratedType(String, SchemaPath)}</li>
+ * </ul>
*/
@Test
public void testPackageNameForGeneratedTypeNullSchemaPath() {
/**
* Test for the method
- * <ul>
- * <li>{@link BindingGeneratorUtil#parseToClassName()
- * parseToClassName()}</li>
- * </ul>
+ * <ul>
+ * <li>{@link BindingGeneratorUtil#parseToClassName(String)
+ * parseToClassName(String)}</li>
+ * </ul>
*/
@Test
public void testParseToClassNameNullValue() {
/**
* Test for the method
- * <ul>
- * <li>{@link BindingGeneratorUtil#parseToClassName()
- * parseToClassName()}</li>
- * </ul>
+ * <ul>
+ * <li>{@link BindingGeneratorUtil#parseToClassName(String)
+ * parseToClassName(String)}</li>
+ * </ul>
*/
@Test
public void testParseToClassNameEmptyValue() {
/**
* Test for the method
- * <ul>
- * <li>{@link BindingGeneratorUtil#validateParameterName()
- * validateParameterName()}</li>
- * <ul>
+ * <ul>
+ * <li>{@link BindingGeneratorUtil#resolveJavaReservedWordEquivalency(String)
+ * resolveJavaReservedWordEquivalency(String)}</li>
+ * <ul>
*/
@Test
public void testValidateParameterName() {
/**
* Tests the methods:
- * <ul>
- * <li>parseToClassName</li>
- * <ul>
- * <li>parseToCamelCase</li>
- * <ul>
- * <li>replaceWithCamelCase</li>
- * </ul>
- * </ul> <li>parseToValidParamName</li>
- * <ul>
- * <li>parseToCamelCase</li>
- * <ul>
- * <li>replaceWithCamelCase</li>
- * </ul>
- * </ul>
- * <ul>
+ * <ul>
+ * <li>parseToClassName</li>
+ * <ul>
+ * <li>parseToCamelCase</li>
+ * <ul>
+ * <li>replaceWithCamelCase</li>
+ * </ul>
+ * </ul> <li>parseToValidParamName</li>
+ * <ul>
+ * <li>parseToCamelCase</li>
+ * <ul>
+ * <li>replaceWithCamelCase</li>
+ * </ul>
+ * </ul>
+ * <ul>
*/
@Test
public void testParsingMethods() {