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