Introduce Identifiables
[yangtools.git] / code-generator / binding-generator-impl / src / test / java / org / opendaylight / yangtools / sal / binding / generator / impl / ControllerTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.sal.binding.generator.impl;
9
10
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.io.File;
15 import java.net.URISyntaxException;
16 import java.net.URL;
17 import java.util.ArrayList;
18 import java.util.List;
19 import java.util.Set;
20
21 import org.junit.BeforeClass;
22 import org.junit.Test;
23 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
24 import org.opendaylight.yangtools.sal.binding.model.api.Type;
25 import org.opendaylight.yangtools.yang.model.api.Module;
26 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
27 import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
28 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
29
30 public class ControllerTest {
31
32     private final static List<File> controllerModels = new ArrayList<>();
33     private final static URL controllerModelsFolderPath = ControllerTest.class
34             .getResource("/controller-models");
35
36     @BeforeClass
37     public static void loadTestResources() throws URISyntaxException {
38         final File ctrlFolder = new File(controllerModelsFolderPath.toURI());
39
40         for (final File fileEntry : ctrlFolder.listFiles()) {
41             if (fileEntry.isFile()) {
42                 controllerModels.add(fileEntry);
43             }
44         }
45     }
46
47     @Test
48     public void controllerAugmentationTest() {
49         final YangModelParser parser = new YangParserImpl();
50         final Set<Module> modules = parser.parseYangModels(controllerModels);
51         final SchemaContext context = parser.resolveSchemaContext(modules);
52
53         assertNotNull(context);
54         final BindingGenerator bindingGen = new BindingGeneratorImpl();
55         final List<Type> genTypes = bindingGen.generateTypes(context);
56
57         assertNotNull(genTypes);
58         assertTrue(!genTypes.isEmpty());
59     }
60 }