Delete netconf
[controller.git] / opendaylight / md-sal / sal-rest-docgen / src / test / java / org / opendaylight / controller / sal / rest / doc / impl / ModelGeneratorTest.java
1 /*
2  * Copyright (c) 2014, 2015 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
9 package org.opendaylight.controller.sal.rest.doc.impl;
10
11 import com.google.common.base.Preconditions;
12 import org.json.JSONObject;
13 import org.junit.Assert;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
19
20 import java.io.File;
21 import java.util.HashSet;
22 import java.util.Map;
23
24
25 public class ModelGeneratorTest {
26
27     private DocGenTestHelper helper;
28     private SchemaContext schemaContext;
29
30     @Before
31     public void setUp() throws Exception {
32         helper = new DocGenTestHelper();
33         helper.setUp();
34         schemaContext = new YangParserImpl().resolveSchemaContext(new HashSet<Module>(helper.getModules().values()));
35     }
36
37     @Test
38     public void testConvertToJsonSchema() throws Exception {
39
40         Preconditions.checkArgument(helper.getModules() != null, "No modules found");
41
42         ModelGenerator generator = new ModelGenerator();
43
44         for (Map.Entry<File, Module> m : helper.getModules().entrySet()) {
45             if (m.getKey().getAbsolutePath().endsWith("opflex.yang")) {
46
47                 JSONObject jsonObject = generator.convertToJsonSchema(m.getValue(), schemaContext);
48                 Assert.assertNotNull(jsonObject);
49             }
50         }
51
52     }
53 }