Fix netconf-connector-config groupId
[netconf.git] / opendaylight / restconf / 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.netconf.sal.rest.doc.impl.ModelGenerator;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
20
21 import java.io.File;
22 import java.util.HashSet;
23 import java.util.Map;
24
25
26 public class ModelGeneratorTest {
27
28     private DocGenTestHelper helper;
29     private SchemaContext schemaContext;
30
31     @Before
32     public void setUp() throws Exception {
33         helper = new DocGenTestHelper();
34         helper.setUp();
35         schemaContext = new YangParserImpl().resolveSchemaContext(new HashSet<Module>(helper.getModules().values()));
36     }
37
38     @Test
39     public void testConvertToJsonSchema() throws Exception {
40
41         Preconditions.checkArgument(helper.getModules() != null, "No modules found");
42
43         ModelGenerator generator = new ModelGenerator();
44
45         for (Map.Entry<File, Module> m : helper.getModules().entrySet()) {
46             if (m.getKey().getAbsolutePath().endsWith("opflex.yang")) {
47
48                 JSONObject jsonObject = generator.convertToJsonSchema(m.getValue(), schemaContext);
49                 Assert.assertNotNull(jsonObject);
50             }
51         }
52
53     }
54 }