import static org.junit.Assert.assertNull;
import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-
import org.junit.Test;
+import org.opendaylight.yangtools.yang.binding.BindingMapping;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
private static List<File> loadTestResources(String testFile) {
final List<File> testModels = new ArrayList<File>();
- final File listModelFile = new File(BindingGeneratorUtilTest.class.getResource(testFile).getPath());
+ File listModelFile;
+ try {
+ listModelFile = new File(BindingGeneratorUtilTest.class.getResource(testFile).toURI());
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Failed to load sources from " + testFile);
+ }
testModels.add(listModelFile);
return testModels;
}
* - without revision </ul>
*/
@Test
- public void testBindingGeneratorUtilMethods() {
+ public void testBindingGeneratorUtilMethods() throws IOException {
List<File> testModels = loadTestResources("/module.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
+ final YangContextParser parser = new YangParserImpl();
+ final Set<Module> modules = parser.parseFiles(testModels).getModules();
String packageName = "";
Module module = null;
for (Module m : modules) {
subPackageNameForTypeDefinition);
// test of exception part of the method moduleNamespaceToPackageName()
- ModuleBuilder moduleBuilder = new ModuleBuilder("module-withut-revision");
+ ModuleBuilder moduleBuilder = new ModuleBuilder("module-withut-revision", null);
+ moduleBuilder.setSource("");
Module moduleWithoutRevision = moduleBuilder.build();
boolean passedSuccesfully = false;
try {
public void testParsingMethods() {
// parseToClassName method testing
assertEquals("Class name has incorrect format", "SomeTestingClassName",
- BindingGeneratorUtil.parseToClassName(" some-testing_class name "));
+ BindingMapping.getClassName(" some-testing_class name "));
assertEquals("Class name has incorrect format", "_0SomeTestingClassName",
- BindingGeneratorUtil.parseToClassName(" 0 some-testing_class name "));
+ BindingMapping.getClassName(" 0 some-testing_class name "));
// parseToValidParamName
assertEquals("Parameter name has incorrect format", "someTestingParameterName",